Skip to content

Commit 1ddc56f

Browse files
committed
(maint) Update Cake Bootstrappers
1 parent a774065 commit 1ddc56f

File tree

2 files changed

+46
-142
lines changed

2 files changed

+46
-142
lines changed

build.ps1

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ Specifies the amount of information to be displayed.
2525
Shows description about tasks.
2626
.PARAMETER DryRun
2727
Performs a dry run.
28-
.PARAMETER Experimental
29-
Uses the nightly builds of the Roslyn script engine.
30-
.PARAMETER Mono
31-
Uses the Mono Compiler rather than the Roslyn script engine.
3228
.PARAMETER SkipToolPackageRestore
3329
Skips restoring of packages.
3430
.PARAMETER ScriptArgs
@@ -49,13 +45,28 @@ Param(
4945
[switch]$ShowDescription,
5046
[Alias("WhatIf", "Noop")]
5147
[switch]$DryRun,
52-
[switch]$Experimental,
53-
[switch]$Mono,
5448
[switch]$SkipToolPackageRestore,
5549
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
5650
[string[]]$ScriptArgs
5751
)
5852

53+
# Attempt to set highest encryption available for SecurityProtocol.
54+
# PowerShell will not set this by default (until maybe .NET 4.6.x). This
55+
# will typically produce a message for PowerShell v2 (just an info
56+
# message though)
57+
try {
58+
# Set TLS 1.2 (3072), then TLS 1.1 (768), then TLS 1.0 (192), finally SSL 3.0 (48)
59+
# Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't
60+
# exist in .NET 4.0, even though they are addressable if .NET 4.5+ is
61+
# installed (.NET 4.5 is an in-place upgrade).
62+
# PowerShell Core already has support for TLS 1.2 so we can skip this if running in that.
63+
if (-not $IsCoreCLR) {
64+
[System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48
65+
}
66+
} catch {
67+
Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to upgrade to .NET Framework 4.5+ and PowerShell v3'
68+
}
69+
5970
[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
6071
function MD5HashFile([string] $filePath)
6172
{
@@ -110,15 +121,16 @@ $MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config"
110121
# Make sure tools folder exists
111122
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
112123
Write-Verbose -Message "Creating tools directory..."
113-
New-Item -Path $TOOLS_DIR -Type directory | out-null
124+
New-Item -Path $TOOLS_DIR -Type Directory | Out-Null
114125
}
115126

116127
# Make sure that packages.config exist.
117128
if (!(Test-Path $PACKAGES_CONFIG)) {
118129
Write-Verbose -Message "Downloading packages.config..."
119130
try {
120131
$wc = GetProxyEnabledWebClient
121-
$wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch {
132+
$wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG)
133+
} catch {
122134
Throw "Could not download packages.config."
123135
}
124136
}
@@ -146,24 +158,30 @@ if (!(Test-Path $NUGET_EXE)) {
146158
}
147159

148160
# Save nuget.exe path to environment to be available to child processed
149-
$ENV:NUGET_EXE = $NUGET_EXE
161+
$env:NUGET_EXE = $NUGET_EXE
162+
$env:NUGET_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
163+
"mono `"$NUGET_EXE`""
164+
} else {
165+
"`"$NUGET_EXE`""
166+
}
150167

151168
# Restore tools from NuGet?
152169
if(-Not $SkipToolPackageRestore.IsPresent) {
153170
Push-Location
154171
Set-Location $TOOLS_DIR
155172

156173
# Check for changes in packages.config and remove installed tools if true.
157-
[string] $md5Hash = MD5HashFile($PACKAGES_CONFIG)
174+
[string] $md5Hash = MD5HashFile $PACKAGES_CONFIG
158175
if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
159-
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
176+
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
160177
Write-Verbose -Message "Missing or changed package.config hash..."
161178
Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery |
162-
Remove-Item -Recurse
179+
Remove-Item -Recurse -Force
163180
}
164181

165182
Write-Verbose -Message "Restoring tools from NuGet..."
166-
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
183+
184+
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
167185

168186
if ($LASTEXITCODE -ne 0) {
169187
Throw "An error occurred while restoring NuGet tools."
@@ -172,7 +190,7 @@ if(-Not $SkipToolPackageRestore.IsPresent) {
172190
{
173191
$md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
174192
}
175-
Write-Verbose -Message ($NuGetOutput | out-string)
193+
Write-Verbose -Message ($NuGetOutput | Out-String)
176194

177195
Pop-Location
178196
}
@@ -183,13 +201,13 @@ if (Test-Path $ADDINS_PACKAGES_CONFIG) {
183201
Set-Location $ADDINS_DIR
184202

185203
Write-Verbose -Message "Restoring addins from NuGet..."
186-
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""
204+
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""
187205

188206
if ($LASTEXITCODE -ne 0) {
189207
Throw "An error occurred while restoring NuGet addins."
190208
}
191209

192-
Write-Verbose -Message ($NuGetOutput | out-string)
210+
Write-Verbose -Message ($NuGetOutput | Out-String)
193211

194212
Pop-Location
195213
}
@@ -200,13 +218,13 @@ if (Test-Path $MODULES_PACKAGES_CONFIG) {
200218
Set-Location $MODULES_DIR
201219

202220
Write-Verbose -Message "Restoring modules from NuGet..."
203-
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""
221+
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""
204222

205223
if ($LASTEXITCODE -ne 0) {
206224
Throw "An error occurred while restoring NuGet modules."
207225
}
208226

209-
Write-Verbose -Message ($NuGetOutput | out-string)
227+
Write-Verbose -Message ($NuGetOutput | Out-String)
210228

211229
Pop-Location
212230
}
@@ -216,20 +234,23 @@ if (!(Test-Path $CAKE_EXE)) {
216234
Throw "Could not find Cake.exe at $CAKE_EXE"
217235
}
218236

237+
$CAKE_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
238+
"mono `"$CAKE_EXE`""
239+
} else {
240+
"`"$CAKE_EXE`""
241+
}
219242

220-
221-
# Build Cake arguments
222-
$cakeArguments = @("$Script");
223-
if ($Target) { $cakeArguments += "-target=$Target" }
243+
# Build an array (not a string) of Cake arguments to be joined later
244+
$cakeArguments = @()
245+
if ($Script) { $cakeArguments += "`"$Script`"" }
246+
if ($Target) { $cakeArguments += "-target=`"$Target`"" }
224247
if ($Configuration) { $cakeArguments += "-configuration=$Configuration" }
225248
if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" }
226249
if ($ShowDescription) { $cakeArguments += "-showdescription" }
227250
if ($DryRun) { $cakeArguments += "-dryrun" }
228-
if ($Experimental) { $cakeArguments += "-experimental" }
229-
if ($Mono) { $cakeArguments += "-mono" }
230251
$cakeArguments += $ScriptArgs
231252

232253
# Start Cake
233254
Write-Host "Running build script..."
234-
&$CAKE_EXE $cakeArguments
255+
Invoke-Expression "& $CAKE_EXE_INVOCATION $($cakeArguments -join " ")"
235256
exit $LASTEXITCODE

build.sh

Lines changed: 0 additions & 117 deletions
This file was deleted.

0 commit comments

Comments
 (0)