Skip to content

Commit

Permalink
Improve user experience of restoring/building/testing (#2261)
Browse files Browse the repository at this point in the history
Add open-vs.cmd, restore.sh and restore.cmd. Fix build.cmd, test.cmd
and test.sh.

We will now always try to install the Windows 10 SDK except if the
-skipInstallWindowsSdk switch is provided. This should reduce the
number of issues linked to this SDK being missing.

Provides a script to allow opening the solution ensuring that the
local SDK is used. It won't prevent users to see issue if they open
the sln directly but this should reduce friction, especially after
the contributing readme is up to date.
  • Loading branch information
Evangelink authored Feb 6, 2024
1 parent 2a1ef22 commit 19b77bf
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Build.cmd
Original file line number Diff line number Diff line change
@@ -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%
2 changes: 1 addition & 1 deletion Test.cmd
Original file line number Diff line number Diff line change
@@ -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%
10 changes: 1 addition & 9 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 0 additions & 16 deletions eng/Install-WindowsSDK.ps1

This file was deleted.

70 changes: 70 additions & 0 deletions eng/build.ps1
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions eng/install-windows-sdk.ps1
Original file line number Diff line number Diff line change
@@ -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))"
}
}
2 changes: 2 additions & 0 deletions open-vs.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\build.ps1""" -vs %*"
2 changes: 2 additions & 0 deletions restore.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\Build.ps1""" -installWindowsSdk -restore %*"
16 changes: 16 additions & 0 deletions restore.sh
Original file line number Diff line number Diff line change
@@ -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 $@
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ while [[ -h $source ]]; do
done

scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
"$scriptroot/eng/common/build.sh" --test $@
"$scriptroot/eng/common/build.sh" --test --integrationTest $@

0 comments on commit 19b77bf

Please sign in to comment.