Permalink
Browse files

Use Arcade bootstrapping scripts (#30498)

* Use Arcade dotnet install scripts

* Update roslyn-tools build tasks to 1.0.0-beta3.18523.2

* DotNet version check, remove LocateDotNet.
  • Loading branch information...
tmat committed Oct 30, 2018
1 parent 06943b0 commit 00384a0bd240aa17746050ad7d0da9f9e9634489
@@ -15,6 +15,7 @@
x64/
[Bb]in/
[Oo]bj/
.dotnet/
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
!packages/*/build/
@@ -118,17 +118,16 @@
DestinationFolder="$(OutDir)" />
</Target>
<!-- Guard against MSBuild picking the wrong SDK version. Its resolver does not always properly enforce
the SDK specified in global.json
https://github.com/dotnet/core-setup/issues/3805
-->
<Target Name="BeforeBuild" Condition="'$(MSBuildRuntimeType)' != 'Core'">
<ValidateBuildEnvironment
MSBuildBinPath="$(MSBuildBinPath)"
MSBuildMinimumFileVersion="15.7.0"
MSBuildMinimumDisplayVersion="MSBuild 15.7"
/>
<UsingTask TaskName="Microsoft.DotNet.Arcade.Sdk.CompareVersions" AssemblyFile="$(RoslynToolsBuildTasksAssembly)" />
<UsingTask TaskName="Microsoft.DotNet.Arcade.Sdk.SingleError" AssemblyFile="$(RoslynToolsBuildTasksAssembly)" />
<Target Name="_CheckRequiredMSBuildVersion" BeforeTargets="BeforeBuild">
<CompareVersions Left="$(MSBuildVersion)" Right="$(MinimumMSBuildVersion)">
<Output TaskParameter="Result" PropertyName="_VersionComparisonResult"/>
</CompareVersions>
<SingleError Text="The msbuild version $(MSBuildVersion) is below the minimum required version $(MinimumMSBuildVersion)"
Condition="$(_VersionComparisonResult) &lt; 0"/>
</Target>
<Target Name="DisableAnalyzers"
@@ -162,16 +162,15 @@
<NuGetVisualStudioVersion>4.0.0-rc-2048</NuGetVisualStudioVersion>
<MicrosoftDiaSymReaderPdb2PdbVersion>1.1.0-beta1-62506-02</MicrosoftDiaSymReaderPdb2PdbVersion>
<RestSharpVersion>105.2.3</RestSharpVersion>
<RoslynBuildUtilVersion>0.9.8-beta</RoslynBuildUtilVersion>
<RoslynDependenciesOptimizationDataVersion>2.11.0-beta1-63312-06</RoslynDependenciesOptimizationDataVersion>
<RoslynDiagnosticsAnalyzersVersion>$(RoslynDiagnosticsNugetPackageVersion)</RoslynDiagnosticsAnalyzersVersion>
<RoslynToolsMicrosoftLocateVSVersion>0.2.4-beta</RoslynToolsMicrosoftLocateVSVersion>
<RoslynToolsVSIXExpInstallerVersion>1.0.0-beta2-63222-01</RoslynToolsVSIXExpInstallerVersion>
<RoslynToolsModifyVsixManifestVersion>1.0.0-beta2-63222-01</RoslynToolsModifyVsixManifestVersion>
<RoslynToolsMSBuildVersion>0.5.0-alpha</RoslynToolsMSBuildVersion>
<RoslynToolsNuGetRepackVersion>1.0.0-beta2-63223-01</RoslynToolsNuGetRepackVersion>
<RoslynToolsNuGetRepackVersion>1.0.0-beta3.18523.2</RoslynToolsNuGetRepackVersion>
<RoslynToolsReferenceAssembliesVersion>0.1.3</RoslynToolsReferenceAssembliesVersion>
<RoslynToolsBuildTasksVersion>1.0.0-beta3.18513.2</RoslynToolsBuildTasksVersion>
<RoslynToolsBuildTasksVersion>1.0.0-beta3.18525.2</RoslynToolsBuildTasksVersion>
<RoslynToolsLightUpSystemRuntimeLoaderFixedVersion>4.3.0</RoslynToolsLightUpSystemRuntimeLoaderFixedVersion>
<RoslynMicrosoftVisualStudioExtensionManagerVersion>0.0.4</RoslynMicrosoftVisualStudioExtensionManagerVersion>
<StreamJsonRpcVersion>1.3.23</StreamJsonRpcVersion>
@@ -6,8 +6,8 @@
</PropertyGroup>
<PropertyGroup>
<_NuGetRepackAssembly Condition="'$(MSBuildRuntimeType)' != 'Core'">$(NuGetPackageRoot)roslyntools.nugetrepack.buildtasks\$(RoslynToolsNuGetRepackVersion)\tools\net461\RoslynTools.NuGetRepack.BuildTasks.dll</_NuGetRepackAssembly>
<_NuGetRepackAssembly Condition="'$(MSBuildRuntimeType)' == 'Core'">$(NuGetPackageRoot)roslyntools.nugetrepack.buildtasks\$(RoslynToolsNuGetRepackVersion)\tools\netcoreapp2.0\RoslynTools.NuGetRepack.BuildTasks.dll</_NuGetRepackAssembly>
<_NuGetRepackAssembly Condition="'$(MSBuildRuntimeType)' != 'Core'">$(NuGetPackageRoot)roslyntools.nugetrepack.buildtasks\$(RoslynToolsNuGetRepackVersion)\tools\net472\RoslynTools.NuGetRepack.BuildTasks.dll</_NuGetRepackAssembly>
<_NuGetRepackAssembly Condition="'$(MSBuildRuntimeType)' == 'Core'">$(NuGetPackageRoot)roslyntools.nugetrepack.buildtasks\$(RoslynToolsNuGetRepackVersion)\tools\netcoreapp2.1\RoslynTools.NuGetRepack.BuildTasks.dll</_NuGetRepackAssembly>
</PropertyGroup>
<UsingTask TaskName="Roslyn.Tools.UpdatePackageVersionTask" AssemblyFile="$(_NuGetRepackAssembly)" />
@@ -5,7 +5,7 @@
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<PropertyGroup>
<RoslynToolsBuildTasksAssembly Condition="'$(MSBuildRuntimeType)' != 'Core'">$(NuGetPackageRoot)roslyntools.buildtasks\$(RoslynToolsBuildTasksVersion)\tools\net461\RoslynTools.BuildTasks.dll</RoslynToolsBuildTasksAssembly>
<RoslynToolsBuildTasksAssembly Condition="'$(MSBuildRuntimeType)' == 'Core'">$(NuGetPackageRoot)roslyntools.buildtasks\$(RoslynToolsBuildTasksVersion)\tools\netcoreapp2.0\RoslynTools.BuildTasks.dll</RoslynToolsBuildTasksAssembly>
<RoslynToolsBuildTasksAssembly Condition="'$(MSBuildRuntimeType)' != 'Core'">$(NuGetPackageRoot)roslyntools.buildtasks\$(RoslynToolsBuildTasksVersion)\tools\net472\RoslynTools.BuildTasks.dll</RoslynToolsBuildTasksAssembly>
<RoslynToolsBuildTasksAssembly Condition="'$(MSBuildRuntimeType)' == 'Core'">$(NuGetPackageRoot)roslyntools.buildtasks\$(RoslynToolsBuildTasksVersion)\tools\netcoreapp2.1\RoslynTools.BuildTasks.dll</RoslynToolsBuildTasksAssembly>
</PropertyGroup>
</Project>
@@ -19,7 +19,22 @@
<PropertyGroup>
<RepoRoot Condition="'$(RepoRoot)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'global.json'))\</RepoRoot>
</PropertyGroup>
<PropertyGroup>
<!-- Respect environment variable for the .NET install directory if set; otherwise, use the repo default location -->
<_DotNetRoot>$(DOTNET_INSTALL_DIR)</_DotNetRoot>
<_DotNetRoot Condition="'$(_DotNetRoot)' == ''">$(RepoRoot).dotnet\</_DotNetRoot>
<_DotNetRoot Condition="!HasTrailingSlash('$(_DotNetRoot)')">$(_DotNetRoot)\</_DotNetRoot>
<!-- Let the exec task find dotnet on PATH -->
<_DotNetRoot Condition="!Exists($(_DotNetRoot))"/>
<DotNetTool Condition="'$(OS)' == 'Windows_NT'">$(_DotNetRoot)dotnet.exe</DotNetTool>
<DotNetTool Condition="'$(OS)' != 'Windows_NT'">$(_DotNetRoot)dotnet</DotNetTool>
</PropertyGroup>
<PropertyGroup>
<!--
TODO: values differ from RepoToolset
-->
@@ -37,4 +37,11 @@
<AssemblyVersion Condition="'$(AssemblyVersion)' == ''">42.42.42.42</AssemblyVersion>
</PropertyGroup>
</Target>
<UsingTask TaskName="Microsoft.DotNet.Arcade.Sdk.CheckRequiredDotNetVersion" AssemblyFile="$(RoslynToolsBuildTasksAssembly)" />
<Target Name="_CheckRequiredDotNetVersion" BeforeTargets="BeforeBuild">
<Microsoft.DotNet.Arcade.Sdk.CheckRequiredDotNetVersion RepositoryRoot="$(RepoRoot)" SdkVersion="$(NETCoreSdkVersion)" />
</Target>
</Project>
@@ -18,6 +18,7 @@
<Import Project="RepoToolset\ProjectLayout.props" />
<Import Project="RepoToolset\DefaultVersions.props"/>
<Import Project="RepoToolset\ProjectDefaults.props" />
<Import Project="RepoToolset\BuildTasks.props" />
<Import Project="RepoToolset\StrongName.props" />
<Import Project="RepoToolset\VisualStudio.props"/>
<Import Project="Tools.props" />
@@ -46,6 +47,7 @@
<VisualStudioReferenceMajorVersion Condition="'$(VisualStudioReferenceMajorVersion)' == ''">$(VisualStudioVersion.Substring($([System.Convert]::ToInt32(0)), $(VisualStudioVersion.IndexOf('.'))))</VisualStudioReferenceMajorVersion>
<VisualStudioReferenceAssemblyVersion Condition="'$(VisualStudioReferenceAssemblyVersion)' == ''">$(VisualStudioReferenceMajorVersion).0.0.0</VisualStudioReferenceAssemblyVersion>
<MinimumVisualStudioVersion>$(VisualStudioVersion)</MinimumVisualStudioVersion>
<MinimumMSBuildVersion>15.7.0</MinimumMSBuildVersion>
<!-- Disable AppX packaging for the Roslyn source. Not setting this to false has the side effect
that any builds of portable projects end up in a sub folder of $(OutputPath). Search for this flag in
@@ -137,12 +139,6 @@
<UsingTask TaskName="Microsoft.CodeAnalysis.BuildTasks.ValidateBootstrap"
AssemblyFile="$(RoslynToolsetDirectory)tools\Microsoft.Build.Tasks.CodeAnalysis.dll"
Condition="'$(BootstrapBuildPath)' != ''" />
<UsingTask TaskName="Roslyn.MSBuild.Util.FindNuGetAssetsForVsix"
AssemblyFile="$(NuGetPackageRoot)Roslyn.Build.Util\$(RoslynBuildUtilVersion)\lib\net46\Roslyn.MSBuild.Util.dll"
Condition="'$(OS)' == 'Windows_NT'" />
<UsingTask TaskName="Roslyn.MSBuild.Util.ValidateBuildEnvironment"
AssemblyFile="$(NuGetPackageRoot)Roslyn.Build.Util\$(RoslynBuildUtilVersion)\lib\net46\Roslyn.MSBuild.Util.dll"
Condition="'$(OS)' == 'Windows_NT'" />
<ItemGroup>
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="$(MicrosoftCodeQualityAnalyzersVersion)" PrivateAssets="all" />
@@ -27,7 +27,6 @@
<PackageReference Include="Microsoft.DiaSymReader.Native" Version="$(MicrosoftDiaSymReaderNativeVersion)" ExcludeAssets="all" />
<PackageReference Include="Microsoft.Net.Compilers" Version="$(MicrosoftNetCompilersVersion)" ExcludeAssets="all" />
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="$(MicrosoftVSSDKBuildToolsVersion)" ExcludeAssets="all" />
<PackageReference Include="Roslyn.Build.Util" Version="$(RoslynBuildUtilVersion)" ExcludeAssets="all" />
<PackageReference Include="RoslynDependencies.OptimizationData" Version="$(RoslynDependenciesOptimizationDataVersion)" ExcludeAssets="all" />
<PackageReference Include="RoslynTools.Microsoft.LocateVS" Version="$(RoslynToolsMicrosoftLocateVSVersion)" ExcludeAssets="all" />
<PackageReference Include="RoslynTools.VSIXExpInstaller" Version="$(RoslynToolsVSIXExpInstallerVersion)" ExcludeAssets="all" />
@@ -3,9 +3,10 @@
Set-StrictMode -version 2.0
$ErrorActionPreference="Stop"
# Declare a number of useful variables for other scripts to use
[string]$repoDir = Resolve-Path (Join-Path $PSScriptRoot "..\..")
[string]$binariesDir = Join-Path $repoDir "Binaries"
# Import Arcade functions
. (Join-Path $PSScriptRoot "tools.ps1")
[string]$binariesDir = Join-Path $RepoRoot "Binaries"
# Handy function for executing a command in powershell and throwing if it
# fails.
@@ -62,7 +63,7 @@ function Exec-CommandCore([string]$command, [string]$commandArgs, [switch]$useCo
if ($useConsole) {
$exitCode = Exec-Process $command $commandArgs
if ($exitCode -ne 0) {
throw "Command failed to execute with exit code $($process.ExitCode): $command $commandArgs"
throw "Command failed to execute with exit code $($exitCode): $command $commandArgs"
}
return
}
@@ -144,57 +145,12 @@ function Exec-Script([string]$script, [string]$scriptArgs = "") {
# Ensure the proper SDK in installed in our %PATH%. This is how MSBuild locates the
# SDK. Returns the location to the dotnet exe
function Ensure-DotnetSdk() {
# Check to see if the specified dotnet installations meets our build requirements
function Test-DotnetDir([string]$dotnetDir, [string]$runtimeVersion, [string]$sdkVersion) {
$sdkPath = Join-Path $dotnetDir "sdk\$sdkVersion"
$runtimePath = Join-Path $dotnetDir "shared\Microsoft.NETCore.App\$runtimeVersion"
return (Test-Path $sdkPath) -and (Test-Path $runtimePath)
}
$sdkVersion = Get-ToolVersion "dotnetSdk"
$runtimeVersion = Get-ToolVersion "dotnetRuntime"
# Get the path to dotnet.exe. This is the first path on %PATH% that contains the
# dotnet.exe instance. Many SDK tools use this to locate items like the SDK.
function Get-DotnetDir() {
foreach ($part in ${env:PATH}.Split(';', [System.StringSplitOptions]::RemoveEmptyEntries)) {
$dotnetExe = Join-Path $part "dotnet.exe"
if (Test-Path $dotnetExe) {
return $part
}
}
return $null
}
if (-not (Test-Path global:_dotNetExe)) {
$global:_dotNetExe = Join-Path (InitializeDotNetCli -install:$true) "dotnet.exe"
}
# First check that dotnet is already on the path with the correct SDK version
$dotnetDir = Get-DotnetDir
if (($dotnetDir -ne $null) -and (Test-DotnetDir $dotnetDir $runtimeVersion $sdkVersion)) {
return (Join-Path $dotnetDir "dotnet.exe")
}
# Ensure the downloaded dotnet of the appropriate version is located in the
# Binaries\Tools directory
$toolsDir = Join-Path $binariesDir "Tools"
$cliDir = Join-Path $toolsDir "dotnet"
if (-not (Test-DotnetDir $cliDir $runtimeVersion $sdkVersion)) {
Write-Host "Downloading CLI $sdkVersion"
Create-Directory $cliDir
Create-Directory $toolsDir
$destFile = Join-Path $toolsDir "dotnet-install.ps1"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$webClient = New-Object -TypeName "System.Net.WebClient"
$webClient.DownloadFile("https://dot.net/v1/dotnet-install.ps1", $destFile)
Exec-Block { & $destFile -Version $sdkVersion -InstallDir $cliDir } | Out-Null
Exec-Block { & $destFile -Version $runtimeVersion -SharedRuntime -InstallDir $cliDir } | Out-Null
}
else {
${env:PATH} = "$cliDir;${env:PATH}"
}
return (Join-Path $cliDir "dotnet.exe")
return $global:_dotNetExe
}
# Ensure a basic tool used for building our Repo is installed and
# return the path to it.
function Ensure-BasicTool([string]$name, [string]$version = "") {
@@ -204,10 +160,9 @@ function Ensure-BasicTool([string]$name, [string]$version = "") {
$p = Join-Path (Get-PackagesDir) "$($name)\$($version)"
if (-not (Test-Path $p)) {
$toolsetProject = Join-Path $repoDir "build\ToolsetPackages\RoslynToolset.csproj"
$dotnet = Ensure-DotnetSdk
$toolsetProject = Join-Path $RepoRoot "build\ToolsetPackages\RoslynToolset.csproj"
Write-Host "Downloading $name"
Restore-Project $dotnet $toolsetProject
Restore-Project $toolsetProject
}
return $p
@@ -227,9 +182,7 @@ function Ensure-MSBuild([switch]$xcopy = $false) {
}
}
$p = Join-Path $msbuildDir "msbuild.exe"
$dotnetExe = Ensure-DotnetSdk
return $p
return Join-Path $msbuildDir "msbuild.exe"
}
# Returns the msbuild exe path and directory as a single return. This makes it easy
@@ -267,12 +220,12 @@ function Get-VersionCore([string]$name, [string]$versionFile) {
# Return the version of the NuGet package as used in this repo
function Get-PackageVersion([string]$name) {
return Get-VersionCore $name (Join-Path $repoDir "build\Targets\Packages.props")
return Get-VersionCore $name (Join-Path $RepoRoot "build\Targets\Packages.props")
}
# Return the version of the specified tool
function Get-ToolVersion([string]$name) {
return Get-VersionCore $name (Join-Path $repoDir "build\Targets\Tools.props")
return Get-VersionCore $name (Join-Path $RepoRoot "build\Targets\Tools.props")
}
# Locate the directory where our NuGet packages will be deployed. Needs to be kept in sync
@@ -425,18 +378,18 @@ function Clear-PackageCache() {
}
# Restore a single project
function Restore-Project([string]$dotnetExe, [string]$projectFileName, [string]$logFilePath = "") {
function Restore-Project([string]$projectFileName, [string]$logFilePath = "") {
$projectFilePath = $projectFileName
if (-not (Test-Path $projectFilePath)) {
$projectFilePath = Join-Path $repoDir $projectFileName
$projectFilePath = Join-Path $RepoRoot $projectFileName
}
$logArg = ""
if ($logFilePath -ne "") {
$logArg = " /bl:$logFilePath"
}
Exec-Console $dotnet "restore --verbosity quiet $projectFilePath $logArg"
Exec-Console (Ensure-DotNetSdk) "restore --verbosity quiet $projectFilePath $logArg"
}
function Unzip-File([string]$zipFilePath, [string]$outputDir) {
@@ -186,15 +186,15 @@ function Restore-Packages() {
Write-Host "Restoring Roslyn Toolset"
$logFilePath = if ($binaryLog) { Join-Path $logsDir "Restore-RoslynToolset.binlog" } else { "" }
Restore-Project $dotnet "build\ToolsetPackages\RoslynToolset.csproj" $logFilePath
Restore-Project "build\ToolsetPackages\RoslynToolset.csproj" $logFilePath
Write-Host "Restoring RepoToolset"
$logFilePath = if ($binaryLog) { Join-Path $logsDir "Restore-RepoToolset.binlog" } else { "" }
Run-MSBuild "build\Targets\RepoToolset\Build.proj" "/p:Restore=true /bl:$logFilePath" -summary:$false
Write-Host "Restoring Roslyn"
$logFilePath = if ($binaryLog) { Join-Path $logsDir "Restore-Roslyn.binlog" } else { "" }
Restore-Project $dotnet "Roslyn.sln" $logFilePath
Restore-Project "Roslyn.sln" $logFilePath
}
# Create a bootstrap build of the compiler. Returns the directory where the bootstrap build
@@ -262,7 +262,7 @@ function Build-Artifacts() {
function Build-InsertionItems() {
$setupDir = Join-Path $repoDir "src\Setup"
$setupDir = Join-Path $RepoRoot "src\Setup"
Push-Location $setupDir
try {
Write-Host "Building VS Insertion artifacts"
@@ -490,11 +490,11 @@ function Ensure-ProcDump() {
function Redirect-Temp() {
$temp = Join-Path $binariesDir "Temp"
Create-Directory $temp
Copy-Item (Join-Path $repoDir "src\Workspaces\CoreTestUtilities\Resources\.editorconfig") $temp
Copy-Item (Join-Path $repoDir "src\Workspaces\CoreTestUtilities\Resources\Directory.Build.props") $temp
Copy-Item (Join-Path $repoDir "src\Workspaces\CoreTestUtilities\Resources\Directory.Build.targets") $temp
Copy-Item (Join-Path $repoDir "src\Workspaces\CoreTestUtilities\Resources\Directory.Build.rsp") $temp
Copy-Item (Join-Path $repoDir "src\Workspaces\CoreTestUtilities\Resources\NuGet.Config") $temp
Copy-Item (Join-Path $RepoRoot "src\Workspaces\CoreTestUtilities\Resources\.editorconfig") $temp
Copy-Item (Join-Path $RepoRoot "src\Workspaces\CoreTestUtilities\Resources\Directory.Build.props") $temp
Copy-Item (Join-Path $RepoRoot "src\Workspaces\CoreTestUtilities\Resources\Directory.Build.targets") $temp
Copy-Item (Join-Path $RepoRoot "src\Workspaces\CoreTestUtilities\Resources\Directory.Build.rsp") $temp
Copy-Item (Join-Path $RepoRoot "src\Workspaces\CoreTestUtilities\Resources\NuGet.Config") $temp
${env:TEMP} = $temp
${env:TMP} = $temp
}
@@ -531,13 +531,14 @@ function Stop-VSProcesses() {
}
try {
. (Join-Path $PSScriptRoot "build-utils.ps1")
Push-Location $repoDir
Process-Arguments
Write-Host "Repo Dir $repoDir"
Write-Host "Binaries Dir $binariesDir"
. (Join-Path $PSScriptRoot "build-utils.ps1")
Process-Arguments
Push-Location $RepoRoot
Write-Host "Repo Dir $RepoRoot"
Write-Host "Binaries Dir $binariesDir"
$msbuild = Ensure-MSBuild
$dotnet = Ensure-DotnetSdk
@@ -142,7 +142,12 @@ then
exit
fi
source "${scriptroot}"/obtain_dotnet.sh
# Import Arcade functions
. $scriptroot/tools.sh
InitializeDotNetCli $restore
export PATH="$DOTNET_INSTALL_DIR:$PATH"
if [[ "$restore" == true ]]
then
@@ -225,5 +230,6 @@ then
else
test_runtime=dotnet
fi
"${scriptroot}"/tests.sh "${build_configuration}" "${test_runtime}"
fi
@@ -34,7 +34,7 @@ $ErrorActionPreference="Stop"
try {
. (Join-Path $PSScriptRoot "build-utils.ps1")
Push-Location $repoDir
Push-Location $RepoRoot
# Find the merge base, then the list of files that changed since then.
$mergeBase = & git merge-base $base $head
Oops, something went wrong.

0 comments on commit 00384a0

Please sign in to comment.