Update build scripts and targets to use 2.0.x build tools

This commit is contained in:
Nate McMaster 2017-10-11 11:00:53 -07:00
parent c770f287a5
commit 4d9bacd3f1
17 changed files with 130 additions and 104 deletions

View File

@ -7,6 +7,7 @@ branches:
- master
- release
- dev
- /^rel\/.*/
- /^(.*\/)?ci-.*$/
build_script:
- ps: .\build.ps1

1
.gitignore vendored
View File

@ -38,4 +38,3 @@ node_modules
.testPublish/
.vscode
global.json
korebuild-lock.txt

View File

@ -1,8 +1,4 @@
<Project>
<Import Project="version.xml" />
<Import Project="version.props" />
<Import Project="TemplateDependencies.props" />
<PropertyGroup>
<VersionSuffix Condition="'$(VersionSuffix)'!='' AND '$(BuildNumber)' != ''">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
</PropertyGroup>
</Project>

View File

@ -1,14 +1,4 @@
<Project InitialTargets="EnsureKoreBuildRestored">
<Target Name="EnsureKoreBuildRestored" Condition=" '$(KoreBuildRestoreTargetsImported)' != 'true' AND '$(MSBuildProjectName)' != 'BenchmarkDotNet.Autogenerated'">
<PropertyGroup>
<_BootstrapperFile Condition=" $([MSBuild]::IsOSUnixLike()) ">build.sh</_BootstrapperFile>
<_BootstrapperFile Condition="! $([MSBuild]::IsOSUnixLike()) ">build.cmd</_BootstrapperFile>
<_BootstrapperError>
Package references have not been pinned. Run './$(_BootstrapperFile) /t:Pin'.
Also, you can run './$(_BootstrapperFile) /t:Restore' which will pin *and* restore packages. '$(_BootstrapperFile)' can be found in '$(MSBuildThisFileDirectory)'.
</_BootstrapperError>
</PropertyGroup>
<Error Code="KRB1001" Text="$(_BootstrapperError.Trim())" />
</Target>
<Project>
<Import Project="build\sources.props" />
<Import Project="build\dependencies.props" />
</Project>

View File

@ -24,7 +24,7 @@ The base url where build tools can be downloaded. Overrides the value from the c
Updates KoreBuild to the latest version even if a lock file is present.
.PARAMETER ConfigFile
The path to the configuration file that stores values. Defaults to version.xml.
The path to the configuration file that stores values. Defaults to version.props.
.PARAMETER MSBuildArgs
Arguments to be passed to MSBuild
@ -33,18 +33,17 @@ Arguments to be passed to MSBuild
This function will create a file $PSScriptRoot/korebuild-lock.txt. This lock file can be committed to source, but does not have to be.
When the lockfile is not present, KoreBuild will create one using latest available version from $Channel.
The $ConfigFile is expected to be an XML file. It is optional, and the configuration values in it are optional as well.
The $ConfigFile is expected to be an JSON file. It is optional, and the configuration values in it are optional as well. Any options set
in the file are overridden by command line parameters.
.EXAMPLE
Example config file:
```xml
<!-- version.xml -->
<Project>
<PropertyGroup>
<KoreBuildChannel>dev</KoreBuildChannel>
<KoreBuildToolsSource>https://aspnetcore.blob.core.windows.net/buildtools</KoreBuildToolsSource>
</PropertyGroup>
</Project>
```json
{
"$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/dev/tools/korebuild.schema.json",
"channel": "dev",
"toolsSource": "https://aspnetcore.blob.core.windows.net/buildtools"
}
```
#>
[CmdletBinding(PositionalBinding = $false)]
@ -58,7 +57,7 @@ param(
[string]$ToolsSource,
[Alias('u')]
[switch]$Update,
[string]$ConfigFile = (Join-Path $PSScriptRoot 'version.xml'),
[string]$ConfigFile = $null,
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$MSBuildArgs
)
@ -104,11 +103,11 @@ function Get-KoreBuild {
}
}
catch {
Remove-Item -Recurse -Force $korebuildPath -ErrorAction Ignore
remove-item -Recurse -Force $korebuildPath -ErrorAction Ignore
throw
}
finally {
Remove-Item $tmpfile -ErrorAction Ignore
remove-item $tmpfile -ErrorAction Ignore
}
}
@ -147,10 +146,20 @@ function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) {
# Load configuration or set defaults
$Path = Resolve-Path $Path
if (!$ConfigFile) { $ConfigFile = Join-Path $Path 'korebuild.json' }
if (Test-Path $ConfigFile) {
[xml] $config = Get-Content $ConfigFile
if (!($Channel)) { [string] $Channel = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildChannel' }
if (!($ToolsSource)) { [string] $ToolsSource = Select-Xml -Xml $config -XPath '/Project/PropertyGroup/KoreBuildToolsSource' }
try {
$config = Get-Content -Raw -Encoding UTF8 -Path $ConfigFile | ConvertFrom-Json
if ($config) {
if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel }
if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource}
}
} catch {
Write-Warning "$ConfigFile could not be read. Its settings will be ignored."
Write-Warning $Error[0]
}
}
if (!$DotNetHome) {

View File

@ -8,10 +8,11 @@ set -euo pipefail
RESET="\033[0m"
RED="\033[0;31m"
YELLOW="\033[0;33m"
MAGENTA="\033[0;95m"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
[ -z "${DOTNET_HOME:-}" ] && DOTNET_HOME="$HOME/.dotnet"
config_file="$DIR/version.xml"
config_file="$DIR/korebuild.json"
verbose=false
update=false
repo_path="$DIR"
@ -30,7 +31,7 @@ __usage() {
echo "Options:"
echo " --verbose Show verbose output."
echo " -c|--channel <CHANNEL> The channel of KoreBuild to download. Overrides the value from the config file.."
echo " --config-file <FILE> TThe path to the configuration file that stores values. Defaults to version.xml."
echo " --config-file <FILE> The path to the configuration file that stores values. Defaults to korebuild.json."
echo " -d|--dotnet-home <DIR> The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet."
echo " --path <PATH> The directory to build. Defaults to the directory containing the script."
echo " -s|--tools-source <URL> The base url where build tools can be downloaded. Overrides the value from the config file."
@ -82,7 +83,11 @@ get_korebuild() {
}
__error() {
echo -e "${RED}$*${RESET}" 1>&2
echo -e "${RED}error: $*${RESET}" 1>&2
}
__warn() {
echo -e "${YELLOW}warning: $*${RESET}"
}
__machine_has() {
@ -117,8 +122,6 @@ __get_remote_file() {
fi
}
__read_dom () { local IFS=\> ; read -r -d \< ENTITY CONTENT ;}
#
# main
#
@ -138,6 +141,10 @@ while [[ $# -gt 0 ]]; do
shift
config_file="${1:-}"
[ -z "$config_file" ] && __usage
if [ ! -f "$config_file" ]; then
__error "Invalid value for --config-file. $config_file does not exist."
exit 1
fi
;;
-d|--dotnet-home|-DotNetHome)
shift
@ -181,14 +188,28 @@ if ! __machine_has curl && ! __machine_has wget; then
exit 1
fi
[ -z "${config_file:-}" ] && config_file="$repo_path/korebuild.json"
if [ -f "$config_file" ]; then
comment=false
while __read_dom; do
if [ "$comment" = true ]; then [[ $CONTENT == *'-->'* ]] && comment=false ; continue; fi
if [[ $ENTITY == '!--'* ]]; then comment=true; continue; fi
if [ -z "$channel" ] && [[ $ENTITY == "KoreBuildChannel" ]]; then channel=$CONTENT; fi
if [ -z "$tools_source" ] && [[ $ENTITY == "KoreBuildToolsSource" ]]; then tools_source=$CONTENT; fi
done < "$config_file"
if __machine_has jq ; then
if jq '.' "$config_file" >/dev/null ; then
config_channel="$(jq -r 'select(.channel!=null) | .channel' "$config_file")"
config_tools_source="$(jq -r 'select(.toolsSource!=null) | .toolsSource' "$config_file")"
else
__warn "$config_file is invalid JSON. Its settings will be ignored."
fi
elif __machine_has python ; then
if python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'))" >/dev/null ; then
config_channel="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')")"
config_tools_source="$(python -c "import json,codecs;obj=json.load(codecs.open('$config_file', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')")"
else
__warn "$config_file is invalid JSON. Its settings will be ignored."
fi
else
__warn 'Missing required command: jq or pyton. Could not parse the JSON file. Its settings will be ignored.'
fi
[ ! -z "${config_channel:-}" ] && channel="$config_channel"
[ ! -z "${config_tools_source:-}" ] && tools_source="$config_tools_source"
fi
[ -z "$channel" ] && channel='dev'

19
build/dependencies.props Normal file
View File

@ -0,0 +1,19 @@
<Project>
<PropertyGroup>
<InternalAspNetCoreSdkPackageVersion>2.0.2-beta-15522</InternalAspNetCoreSdkPackageVersion>
<MicrosoftBuildFrameworkPackageVersion>15.3.409</MicrosoftBuildFrameworkPackageVersion>
<MicrosoftBuildUtilitiesCorePackageVersion>15.3.409</MicrosoftBuildUtilitiesCorePackageVersion>
<MicrosoftNETTestSdkPackageVersion>15.3.0</MicrosoftNETTestSdkPackageVersion>
<OctokitPackageVersion>0.26.0</OctokitPackageVersion>
<SeleniumFirefoxWebDriverPackageVersion>0.18.0</SeleniumFirefoxWebDriverPackageVersion>
<SeleniumSupportPackageVersion>3.4.0</SeleniumSupportPackageVersion>
<SeleniumWebDriverMicrosoftDriverPackageVersion>15.15063.0</SeleniumWebDriverMicrosoftDriverPackageVersion>
<SeleniumWebDriverPackageVersion>3.4.0</SeleniumWebDriverPackageVersion>
<SystemSecurityPermissionsPackageVersion>4.4.0</SystemSecurityPermissionsPackageVersion>
<XunitAnalyzersPackageVersion>0.7.0</XunitAnalyzersPackageVersion>
<XunitPackageVersion>2.3.0</XunitPackageVersion>
<XunitRunnerVisualStudioPackageVersion>2.3.0</XunitRunnerVisualStudioPackageVersion>
</PropertyGroup>
<Import Project="$(DotNetPackageVersionPropsPath)" Condition=" '$(DotNetPackageVersionPropsPath)' != '' " />
</Project>

View File

@ -1,23 +0,0 @@
<Project>
<ItemGroup>
<PackageLineup Include="Internal.AspNetCore.Universe.Lineup" Version="2.1.0-*" />
<PackageLineup Include="Internal.AspNetCore.Partners.Lineup" Version="2.1.0-*" />
</ItemGroup>
<PropertyGroup>
<NuGetPublishFeed>https://dotnet.myget.org/f/aspnetcore-ci-dev</NuGetPublishFeed>
</PropertyGroup>
<!--
If this build has a .deps dir supplied by the CI system, use that (and *only* that)
// to obtain the package lineup. This ensures we're building and testing against the
// specific Coherence build that this Templating repo build is chained to.
-->
<PropertyGroup Condition="Exists('$(RepositoryRoot).deps\lineups')">
<PolicyRestoreSources>$(RepositoryRoot).deps\lineups</PolicyRestoreSources>
</PropertyGroup>
<ItemGroup Condition="Exists('$(RepositoryRoot).deps\build')">
<AdditionalRestoreSources Include="$(RepositoryRoot).deps\build" />
</ItemGroup>
</Project>

View File

@ -5,13 +5,6 @@
TaskName="PullRequestSubmitter.PullRequestTask"
AssemblyFile="$(MSBuildThisFileDirectory)..\tools\PullRequestSubmitter\bin\Release\netcoreapp2.0\PullRequestSubmitter.dll" />
<Target Name="PushNuGetPackages">
<ItemGroup>
<PackagesToPublish Include="$(BuildDir)*.nupkg" />
</ItemGroup>
<PushNuGetPackages Packages="@(PackagesToPublish)" Feed="$(NuGetPublishFeed)" ApiKey="$(ApiKey)" />
</Target>
<Target Name="SendPullRequestToCliRepo">
<PropertyGroup>
<!-- Read the ASP.NET Core package version from a .deps.json file, because

17
build/sources.props Normal file
View File

@ -0,0 +1,17 @@
<Project>
<Import Project="$(DotNetRestoreSourcePropsPath)" Condition="'$(DotNetRestoreSourcePropsPath)' != ''"/>
<PropertyGroup>
<RestoreSources>$(DotNetRestoreSources)</RestoreSources>
<RestoreSources Condition="'$(DotNetBuildOffline)' != 'true' AND '$(AspNetUniverseBuildOffline)' != 'true' ">
$(RestoreSources);
https://dotnet.myget.org/F/aspnet-2-0-2-october2017-patch/api/v3/index.json;
https://dotnet.myget.org/F/aspnetcore-master/api/v3/index.json;
https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json;
</RestoreSources>
<RestoreSources Condition="'$(DotNetBuildOffline)' != 'true'">
$(RestoreSources);
https://api.nuget.org/v3/index.json;
</RestoreSources>
</PropertyGroup>
</Project>

2
korebuild-lock.txt Normal file
View File

@ -0,0 +1,2 @@
version:2.0.2-beta-15522
commithash:f26cb086ebd8b5a187381bb9a431794f11d69025

4
korebuild.json Normal file
View File

@ -0,0 +1,4 @@
{
"$schema": "https://raw.githubusercontent.com/aspnet/BuildTools/rel/2.0.2/tools/korebuild.schema.json",
"channel": "rel/2.0.2"
}

View File

@ -2,22 +2,19 @@
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<!-- Workaround for https://github.com/aspnet/BuildTools/issues/392 -->
<DisablePackageReferenceVersionRestrictions>true</DisablePackageReferenceVersionRestrictions>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Security.Permissions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Internal.AspNetCore.Sdk" PrivateAssets="All" />
<PackageReference Include="Selenium.Firefox.WebDriver" Version="0.18.0" NoWarn="KRB4002" />
<PackageReference Include="Selenium.Support" Version="3.4.0" NoWarn="NU1701" />
<PackageReference Include="Selenium.WebDriver" Version="3.4.0" NoWarn="NU1701" />
<PackageReference Include="Selenium.WebDriver.MicrosoftDriver" Version="15.15063.0" NoWarn="KRB4002" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.analyzers" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="System.Security.Permissions" Version="$(SystemSecurityPermissionsPackageVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
<PackageReference Include="Internal.AspNetCore.Sdk" Version="$(InternalAspNetCoreSdkPackageVersion)" PrivateAssets="All" />
<PackageReference Include="Selenium.Firefox.WebDriver" Version="$(SeleniumFirefoxWebDriverPackageVersion)" />
<PackageReference Include="Selenium.Support" Version="$(SeleniumSupportPackageVersion)" NoWarn="NU1701" />
<PackageReference Include="Selenium.WebDriver" Version="$(SeleniumWebDriverPackageVersion)" NoWarn="NU1701" />
<PackageReference Include="Selenium.WebDriver.MicrosoftDriver" Version="$(SeleniumWebDriverMicrosoftDriverPackageVersion)" />
<PackageReference Include="xunit" Version="$(XunitPackageVersion)" />
<PackageReference Include="xunit.analyzers" Version="$(XunitAnalyzersPackageVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioPackageVersion)" />
</ItemGroup>
</Project>

View File

@ -6,7 +6,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build.Framework" />
<PackageReference Include="Microsoft.Build.Utilities.Core" />
<PackageReference Include="Microsoft.Build.Framework" Version="$(MicrosoftBuildFrameworkPackageVersion)" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="$(MicrosoftBuildUtilitiesCorePackageVersion)" />
</ItemGroup>
</Project>
</Project>

View File

@ -6,9 +6,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build.Framework" />
<PackageReference Include="Microsoft.Build.Utilities.Core" />
<PackageReference Include="Octokit" Version="0.26.0" NoWarn="KRB4002" />
<PackageReference Include="Microsoft.Build.Framework" Version="$(MicrosoftBuildFrameworkPackageVersion)" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="$(MicrosoftBuildUtilitiesCorePackageVersion)" />
<PackageReference Include="Octokit" Version="$(OctokitPackageVersion)" />
</ItemGroup>
</Project>

9
version.props Normal file
View File

@ -0,0 +1,9 @@
<Project>
<PropertyGroup>
<VersionPrefix>2.0.3</VersionPrefix>
<VersionSuffix>rtm</VersionSuffix>
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' == 'rtm' ">$(VersionPrefix)</PackageVersion>
<PackageVersion Condition="'$(IsFinalBuild)' == 'true' AND '$(VersionSuffix)' != 'rtm' ">$(VersionPrefix)-$(VersionSuffix)-final</PackageVersion>
<VersionSuffix Condition="'$(VersionSuffix)' != '' And '$(BuildNumber)' != ''">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
</PropertyGroup>
</Project>

View File

@ -1,8 +0,0 @@
<!-- This file may be overwritten by automation. -->
<Project>
<PropertyGroup>
<KoreBuildChannel>dev</KoreBuildChannel>
<VersionPrefix>2.1.0</VersionPrefix>
<VersionSuffix>preview1</VersionSuffix>
</PropertyGroup>
</Project>