|
@@ -4,9 +4,9 @@ Param(
|
|
[string[]]$BuildArguments
|
|
[string[]]$BuildArguments
|
|
)
|
|
)
|
|
|
|
|
|
-Write-Output "Windows PowerShell $($Host.Version)"
|
|
|
|
|
|
+Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)"
|
|
|
|
|
|
-Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { exit 1 }
|
|
|
|
|
|
+Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 }
|
|
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
|
|
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
|
|
|
|
|
|
###########################################################################
|
|
###########################################################################
|
|
@@ -14,14 +14,15 @@ $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
|
|
###########################################################################
|
|
###########################################################################
|
|
|
|
|
|
$BuildProjectFile = "$PSScriptRoot\build\_build.csproj"
|
|
$BuildProjectFile = "$PSScriptRoot\build\_build.csproj"
|
|
-$TempDirectory = "$PSScriptRoot\\.tmp"
|
|
|
|
|
|
+$TempDirectory = "$PSScriptRoot\\.nuke\temp"
|
|
|
|
|
|
$DotNetGlobalFile = "$PSScriptRoot\\global.json"
|
|
$DotNetGlobalFile = "$PSScriptRoot\\global.json"
|
|
-$DotNetInstallUrl = "https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1"
|
|
|
|
|
|
+$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
|
|
$DotNetChannel = "Current"
|
|
$DotNetChannel = "Current"
|
|
|
|
|
|
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
|
|
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
|
|
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
|
|
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
|
|
|
|
+$env:DOTNET_MULTILEVEL_LOOKUP = 0
|
|
|
|
|
|
###########################################################################
|
|
###########################################################################
|
|
# EXECUTION
|
|
# EXECUTION
|
|
@@ -32,37 +33,37 @@ function ExecSafe([scriptblock] $cmd) {
|
|
if ($LASTEXITCODE) { exit $LASTEXITCODE }
|
|
if ($LASTEXITCODE) { exit $LASTEXITCODE }
|
|
}
|
|
}
|
|
|
|
|
|
-# If global.json exists, load expected version
|
|
|
|
-if (Test-Path $DotNetGlobalFile) {
|
|
|
|
- $DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json)
|
|
|
|
- if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) {
|
|
|
|
- $DotNetVersion = $DotNetGlobal.sdk.version
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-# If dotnet is installed locally, and expected version is not set or installation matches the expected version
|
|
|
|
-if ((Get-Command "dotnet" -ErrorAction SilentlyContinue) -ne $null -and `
|
|
|
|
- (!(Test-Path variable:DotNetVersion) -or $(& dotnet --version) -eq $DotNetVersion)) {
|
|
|
|
|
|
+# If dotnet CLI is installed globally and it matches requested version, use for execution
|
|
|
|
+if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and `
|
|
|
|
+ $(dotnet --version) -and $LASTEXITCODE -eq 0) {
|
|
$env:DOTNET_EXE = (Get-Command "dotnet").Path
|
|
$env:DOTNET_EXE = (Get-Command "dotnet").Path
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- $DotNetDirectory = "$TempDirectory\dotnet-win"
|
|
|
|
- $env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
|
|
|
|
-
|
|
|
|
# Download install script
|
|
# Download install script
|
|
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
|
|
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
|
|
- md -force $TempDirectory > $null
|
|
|
|
|
|
+ New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null
|
|
|
|
+ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
|
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)
|
|
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)
|
|
|
|
|
|
|
|
+ # If global.json exists, load expected version
|
|
|
|
+ if (Test-Path $DotNetGlobalFile) {
|
|
|
|
+ $DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json)
|
|
|
|
+ if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) {
|
|
|
|
+ $DotNetVersion = $DotNetGlobal.sdk.version
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
# Install by channel or version
|
|
# Install by channel or version
|
|
|
|
+ $DotNetDirectory = "$TempDirectory\dotnet-win"
|
|
if (!(Test-Path variable:DotNetVersion)) {
|
|
if (!(Test-Path variable:DotNetVersion)) {
|
|
- ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
|
|
|
|
|
|
+ ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
|
|
} else {
|
|
} else {
|
|
- ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
|
|
|
|
|
|
+ ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
|
|
}
|
|
}
|
|
|
|
+ $env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
|
|
}
|
|
}
|
|
|
|
|
|
-Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)"
|
|
|
|
|
|
+Write-Output "Microsoft (R) .NET SDK version $(& $env:DOTNET_EXE --version)"
|
|
|
|
|
|
-ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false }
|
|
|
|
|
|
+ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet }
|
|
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }
|
|
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }
|