@@ -14,14 +14,15 @@ $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
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
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,38 +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
36
+ # If dotnet CLI is installed globally and it matches requested version, use for execution
44
37
if ($null -ne (Get-Command " dotnet" - ErrorAction SilentlyContinue) -and `
45
- ( ! ( Test-Path variable:DotNetVersion) -or $ ( & dotnet -- version) -eq $DotNetVersion ) ) {
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
44
New-Item - ItemType Directory - Path $TempDirectory - Force | Out-Null
55
45
[Net.ServicePointManager ]::SecurityProtocol = [Net.SecurityProtocolType ]::Tls12
56
46
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl , $DotNetInstallFile )
57
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
+
58
56
# Install by channel or version
57
+ $DotNetDirectory = " $TempDirectory \dotnet-win"
59
58
if (! (Test-Path variable:DotNetVersion)) {
60
- ExecSafe { & $DotNetInstallFile - InstallDir $DotNetDirectory - Channel $DotNetChannel - NoPath }
59
+ ExecSafe { & powershell $DotNetInstallFile - InstallDir $DotNetDirectory - Channel $DotNetChannel - NoPath }
61
60
} else {
62
- ExecSafe { & $DotNetInstallFile - InstallDir $DotNetDirectory - Version $DotNetVersion - NoPath }
61
+ ExecSafe { & powershell $DotNetInstallFile - InstallDir $DotNetDirectory - Version $DotNetVersion - NoPath }
63
62
}
63
+ $env: DOTNET_EXE = " $DotNetDirectory \dotnet.exe"
64
64
}
65
65
66
66
Write-Output " Microsoft (R) .NET Core SDK version $ ( & $env: DOTNET_EXE -- version) "
67
67
68
- ExecSafe { & $env: DOTNET_EXE build $BuildProjectFile / nodeReuse:false - nologo - clp:NoSummary -- verbosity quiet }
68
+ ExecSafe { & $env: DOTNET_EXE build $BuildProjectFile / nodeReuse:false / p:UseSharedCompilation = false - nologo - clp:NoSummary -- verbosity quiet }
69
69
ExecSafe { & $env: DOTNET_EXE run -- project $BuildProjectFile -- no- build -- $BuildArguments }
0 commit comments