diff --git a/Build.cmd b/Build.cmd index 4afad04714..664d302108 100644 --- a/Build.cmd +++ b/Build.cmd @@ -1,3 +1,3 @@ @echo off -powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\common\Build.ps1""" -restore -build %*" +powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\build.ps1""" -installWindowsSdk -restore -build %*" exit /b %ErrorLevel% diff --git a/Test.cmd b/Test.cmd index 594b62985f..bb57dc6e0a 100644 --- a/Test.cmd +++ b/Test.cmd @@ -1,3 +1,3 @@ @echo off -powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\common\Build.ps1""" -test -integrationTest %*" +powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\build.ps1""" -test -integrationTest %*" exit /b %ErrorLevel% diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4e8f9b6fb7..ad216a4339 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -120,18 +120,10 @@ stages: displayName: 'Install Windows SDK' inputs: targetType: filePath - filePath: './eng/Install-WindowsSDK.ps1' + filePath: './eng/install-windows-sdk.ps1' failOnStderr: true showWarnings: true - # This steps help to understand versions of .NET runtime installed on the machine, - # which is useful to diagnose some governance issues. - - task: DotNetCoreCLI@2 - displayName: 'dotnet --info' - inputs: - command: custom - custom: '--info' - - script: eng\common\CIBuild.cmd -configuration $(_BuildConfig) -prepareMachine diff --git a/eng/Install-WindowsSDK.ps1 b/eng/Install-WindowsSDK.ps1 deleted file mode 100644 index 4cb1cf4a0d..0000000000 --- a/eng/Install-WindowsSDK.ps1 +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT license. See LICENSE file in the project root for full license information. - -Write-Host "Downloading Windows SDK 10.0.16299..." -ForegroundColor Green -Invoke-WebRequest -Method Get -Uri https://go.microsoft.com/fwlink/p/?linkid=864422 -OutFile sdksetup.exe -UseBasicParsing - -Write-Host "Installing Windows SDK, if setup requests elevation please approve." -ForegroundColor Green -$process = Start-Process -Wait sdksetup.exe -ArgumentList "/quiet", "/norestart", "/ceip off", "/features OptionId.UWPManaged" -PassThru - -if ($process.ExitCode -eq 0) { - Remove-Item sdksetup.exe -Force - Write-Host "Done" -ForegroundColor Green -} -else { - Write-Error "Failed to install Windows SDK (Exit code: $($process.ExitCode))" -} diff --git a/eng/build.ps1 b/eng/build.ps1 new file mode 100644 index 0000000000..68294d3487 --- /dev/null +++ b/eng/build.ps1 @@ -0,0 +1,70 @@ +[CmdletBinding(PositionalBinding=$false)] +Param( + [string][Alias('c')]$configuration = "Debug", + [string]$platform = $null, + [string] $projects, + [string][Alias('v')]$verbosity = "minimal", + [string] $msbuildEngine = $null, + [bool] $warnAsError = $true, + [bool] $nodeReuse = $true, + [switch][Alias('r')]$restore, + [switch] $deployDeps, + [switch][Alias('b')]$build, + [switch] $rebuild, + [switch] $deploy, + [switch][Alias('t')]$test, + [switch] $integrationTest, + [switch] $performanceTest, + [switch] $sign, + [switch] $pack, + [switch] $publish, + [switch] $clean, + [switch][Alias('bl')]$binaryLog, + [switch][Alias('nobl')]$excludeCIBinarylog, + [switch] $ci, + [switch] $prepareMachine, + [string] $runtimeSourceFeed = '', + [string] $runtimeSourceFeedKey = '', + [switch] $excludePrereleaseVS, + [switch] $nativeToolsOnMachine, + [switch] $help, + [switch] $vs, + [switch] $installWindowsSdk, + [Parameter(ValueFromRemainingArguments=$true)][String[]]$properties +) + +if ($vs) { + . $PSScriptRoot\common\tools.ps1 + + # This tells .NET Core to use the bootstrapped runtime + $env:DOTNET_ROOT=InitializeDotNetCli -install:$true -createSdkLocationFile:$true + + # This tells MSBuild to load the SDK from the directory of the bootstrapped SDK + $env:DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR=$env:DOTNET_ROOT + + # This tells .NET Core not to go looking for .NET Core in other places + $env:DOTNET_MULTILEVEL_LOOKUP=0; + + # Put our local dotnet.exe on PATH first so Visual Studio knows which one to use + $env:PATH=($env:DOTNET_ROOT + ";" + $env:PATH); + + # Disable .NET runtime signature validation errors which errors for local builds + $env:VSDebugger_ValidateDotnetDebugLibSignatures=0; + + # Launch Visual Studio with the locally defined environment variables + & "$PSScriptRoot\..\TestFx.sln" + + return +} + +if ($installWindowsSdk) { + & $PSScriptRoot\install-windows-sdk.ps1 +} else { + Write-Host "Skipping Windows SDK installation" +} + +# Remove extra parameters that are not used by the common build script +$null = $PSBoundParameters.Remove("vs") +$null = $PSBoundParameters.Remove("installWindowsSdk") + +& $PSScriptRoot\common\Build.ps1 @PSBoundParameters diff --git a/eng/install-windows-sdk.ps1 b/eng/install-windows-sdk.ps1 new file mode 100644 index 0000000000..cdce09e5e8 --- /dev/null +++ b/eng/install-windows-sdk.ps1 @@ -0,0 +1,17 @@ +if (Test-Path "${env:ProgramFiles(x86)}\Windows Kits\10\UnionMetadata\10.0.16299.0") { + Write-Host "Windows SDK 10.0.16299 is already installed, skipping..." +} else { + Write-Host "Downloading Windows SDK 10.0.16299..." + Invoke-WebRequest -Method Get -Uri https://go.microsoft.com/fwlink/p/?linkid=864422 -OutFile sdksetup.exe -UseBasicParsing + + Write-Host "Installing Windows SDK, if setup requests elevation please approve." -ForegroundColor Green + $process = Start-Process -Wait sdksetup.exe -ArgumentList "/quiet", "/norestart", "/ceip off", "/features OptionId.UWPManaged" -PassThru + + if ($process.ExitCode -eq 0) { + Remove-Item sdksetup.exe -Force + Write-Host "Installation succeeded" + } + else { + Write-Error "Failed to install Windows SDK (Exit code: $($process.ExitCode))" + } +} diff --git a/open-vs.cmd b/open-vs.cmd new file mode 100644 index 0000000000..d143957db8 --- /dev/null +++ b/open-vs.cmd @@ -0,0 +1,2 @@ +@echo off +powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\build.ps1""" -vs %*" \ No newline at end of file diff --git a/restore.cmd b/restore.cmd new file mode 100644 index 0000000000..7af1b52c68 --- /dev/null +++ b/restore.cmd @@ -0,0 +1,2 @@ +@echo off +powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\Build.ps1""" -installWindowsSdk -restore %*" \ No newline at end of file diff --git a/restore.sh b/restore.sh new file mode 100755 index 0000000000..260efcf5ad --- /dev/null +++ b/restore.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +source="${BASH_SOURCE[0]}" + +# resolve $SOURCE until the file is no longer a symlink +while [[ -h $source ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + + # if $source was a relative symlink, we need to resolve it relative to the path where the + # symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done + +scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" +"$scriptroot/eng/common/build.sh" --restore $@ \ No newline at end of file diff --git a/test.sh b/test.sh index 69c2db38d3..43c12f55bc 100755 --- a/test.sh +++ b/test.sh @@ -13,4 +13,4 @@ while [[ -h $source ]]; do done scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" -"$scriptroot/eng/common/build.sh" --test $@ \ No newline at end of file +"$scriptroot/eng/common/build.sh" --test --integrationTest $@ \ No newline at end of file