forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestore-toolset.ps1
74 lines (59 loc) · 2.26 KB
/
restore-toolset.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
function InitializeCustomSDKToolset {
if ($env:TestFullMSBuild -eq "true") {
$env:DOTNET_SDK_TEST_MSBUILD_PATH = InitializeVisualStudioMSBuild -install:$true -vsRequirements:$GlobalJson.tools.'vs-opt'
Write-Host "INFO: Tests will run against full MSBuild in $env:DOTNET_SDK_TEST_MSBUILD_PATH"
}
if (-not $restore) {
return
}
# The following frameworks and tools are used only for testing.
# Do not attempt to install them in source build.
if ($env:DotNetBuildFromSource -eq "true") {
return
}
$cli = InitializeDotnetCli -install:$true
InstallDotNetSharedFramework "1.0.5"
InstallDotNetSharedFramework "1.1.2"
InstallDotNetSharedFramework "2.1.0"
InstallDotNetSharedFramework "2.2.8"
InstallDotNetSharedFramework "3.1.0"
CreateBuildEnvScript
InstallNuget
}
function InstallNuGet {
$NugetInstallDir = Join-Path $ArtifactsDir ".nuget"
$NugetExe = Join-Path $NugetInstallDir "nuget.exe"
if (!(Test-Path -Path $NugetExe)) {
Create-Directory $NugetInstallDir
Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -UseBasicParsing -OutFile $NugetExe
}
}
function CreateBuildEnvScript()
{
Create-Directory $ArtifactsDir
$scriptPath = Join-Path $ArtifactsDir "sdk-build-env.bat"
$scriptContents = @"
@echo off
title SDK Build ($RepoRoot)
set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
set DOTNET_MULTILEVEL_LOOKUP=0
set DOTNET_ROOT=$env:DOTNET_INSTALL_DIR
set DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR=$env:DOTNET_INSTALL_DIR
set PATH=$env:DOTNET_INSTALL_DIR;%PATH%
set NUGET_PACKAGES=$env:NUGET_PACKAGES
DOSKEY killdotnet=taskkill /F /IM dotnet.exe /T ^& taskkill /F /IM VSTest.Console.exe /T ^& taskkill /F /IM msbuild.exe /T
"@
Out-File -FilePath $scriptPath -InputObject $scriptContents -Encoding ASCII
}
function InstallDotNetSharedFramework([string]$version) {
$dotnetRoot = $env:DOTNET_INSTALL_DIR
$fxDir = Join-Path $dotnetRoot "shared\Microsoft.NETCore.App\$version"
if (!(Test-Path $fxDir)) {
$installScript = GetDotNetInstallScript $dotnetRoot
& $installScript -Version $version -InstallDir $dotnetRoot -Runtime "dotnet"
if($lastExitCode -ne 0) {
throw "Failed to install shared Framework $version to '$dotnetRoot' (exit code '$lastExitCode')."
}
}
}
InitializeCustomSDKToolset