4
4
[string []]$BuildArguments
5
5
)
6
6
7
- Write-Output " Windows PowerShell $ ( $Host .Version ) "
7
+ Write-Output " PowerShell $ ( $PSVersionTable .PSEdition ) version $ ( $PSVersionTable .PSVersion ) "
8
8
9
- Set-StrictMode - Version 2.0 ; $ErrorActionPreference = " Stop" ; $ConfirmPreference = " None" ; trap { exit 1 }
9
+ Set-StrictMode - Version 2.0 ; $ErrorActionPreference = " Stop" ; $ConfirmPreference = " None" ; trap { Write-Error $_ - ErrorAction Continue ; exit 1 }
10
10
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path - Parent
11
11
12
12
# ##########################################################################
13
13
# CONFIGURATION
14
14
# ##########################################################################
15
15
16
16
$BuildProjectFile = " $PSScriptRoot \.build\.build.csproj"
17
- $TempDirectory = " $PSScriptRoot \\.tmp "
17
+ $TempDirectory = " $PSScriptRoot \\.nuke\temp "
18
18
19
19
$DotNetGlobalFile = " $PSScriptRoot \\global.json"
20
- $DotNetInstallUrl = " https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain /dotnet-install.ps1"
20
+ $DotNetInstallUrl = " https://dot.net/v1 /dotnet-install.ps1"
21
21
$DotNetChannel = " Current"
22
22
23
23
$env: DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
24
24
$env: DOTNET_CLI_TELEMETRY_OPTOUT = 1
25
+ $env: DOTNET_MULTILEVEL_LOOKUP = 0
25
26
26
27
# ##########################################################################
27
28
# EXECUTION
@@ -32,37 +33,37 @@ function ExecSafe([scriptblock] $cmd) {
32
33
if ($LASTEXITCODE ) { exit $LASTEXITCODE }
33
34
}
34
35
35
- # If global.json exists, load expected version
36
- if (Test-Path $DotNetGlobalFile ) {
37
- $DotNetGlobal = $ (Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json )
38
- if ($DotNetGlobal.PSObject.Properties [" sdk" ] -and $DotNetGlobal.sdk.PSObject.Properties [" version" ]) {
39
- $DotNetVersion = $DotNetGlobal.sdk.version
40
- }
41
- }
42
-
43
- # If dotnet is installed locally, and expected version is not set or installation matches the expected version
44
- if ((Get-Command " dotnet" - ErrorAction SilentlyContinue) -ne $null -and `
45
- (! (Test-Path variable:DotNetVersion) -or $ (& dotnet -- version) -eq $DotNetVersion )) {
36
+ # If dotnet CLI is installed globally and it matches requested version, use for execution
37
+ if ($null -ne (Get-Command " dotnet" - ErrorAction SilentlyContinue) -and `
38
+ $ (dotnet -- version) -and $LASTEXITCODE -eq 0 ) {
46
39
$env: DOTNET_EXE = (Get-Command " dotnet" ).Path
47
40
}
48
41
else {
49
- $DotNetDirectory = " $TempDirectory \dotnet-win"
50
- $env: DOTNET_EXE = " $DotNetDirectory \dotnet.exe"
51
-
52
42
# Download install script
53
43
$DotNetInstallFile = " $TempDirectory \dotnet-install.ps1"
54
- md - force $TempDirectory > $null
44
+ New-Item - ItemType Directory - Path $TempDirectory - Force | Out-Null
45
+ [Net.ServicePointManager ]::SecurityProtocol = [Net.SecurityProtocolType ]::Tls12
55
46
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl , $DotNetInstallFile )
56
47
48
+ # If global.json exists, load expected version
49
+ if (Test-Path $DotNetGlobalFile ) {
50
+ $DotNetGlobal = $ (Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json )
51
+ if ($DotNetGlobal.PSObject.Properties [" sdk" ] -and $DotNetGlobal.sdk.PSObject.Properties [" version" ]) {
52
+ $DotNetVersion = $DotNetGlobal.sdk.version
53
+ }
54
+ }
55
+
57
56
# Install by channel or version
57
+ $DotNetDirectory = " $TempDirectory \dotnet-win"
58
58
if (! (Test-Path variable:DotNetVersion)) {
59
59
ExecSafe { & $DotNetInstallFile - InstallDir $DotNetDirectory - Channel $DotNetChannel - NoPath }
60
60
} else {
61
61
ExecSafe { & $DotNetInstallFile - InstallDir $DotNetDirectory - Version $DotNetVersion - NoPath }
62
62
}
63
+ $env: DOTNET_EXE = " $DotNetDirectory \dotnet.exe"
63
64
}
64
65
65
66
Write-Output " Microsoft (R) .NET Core SDK version $ ( & $env: DOTNET_EXE -- version) "
66
67
67
- ExecSafe { & $env: DOTNET_EXE build $BuildProjectFile / nodeReuse:false }
68
+ ExecSafe { & $env: DOTNET_EXE build $BuildProjectFile / nodeReuse:false / p:UseSharedCompilation = false - nologo - clp:NoSummary -- verbosity quiet }
68
69
ExecSafe { & $env: DOTNET_EXE run -- project $BuildProjectFile -- no- build -- $BuildArguments }
0 commit comments