@@ -21,13 +21,10 @@ The build script target to run.
21
21
The build configuration to use.
22
22
. PARAMETER Verbosity
23
23
Specifies the amount of information to be displayed.
24
- . PARAMETER Experimental
25
- Tells Cake to use the latest Roslyn release.
26
- . PARAMETER WhatIf
27
- Performs a dry run of the build script.
28
- No tasks will be executed.
29
- . PARAMETER Mono
30
- Tells Cake to use the Mono scripting engine.
24
+ . PARAMETER ShowDescription
25
+ Shows description about tasks.
26
+ . PARAMETER DryRun
27
+ Performs a dry run.
31
28
. PARAMETER SkipToolPackageRestore
32
29
Skips restoring of packages.
33
30
. PARAMETER ScriptArgs
@@ -40,21 +37,33 @@ https://cakebuild.net
40
37
41
38
[CmdletBinding ()]
42
39
Param (
43
- [string ]$Script = " setup.cake" ,
44
- [string ]$Target = " Default" ,
45
- [ValidateSet (" Release" , " Debug" )]
46
- [string ]$Configuration = " Release" ,
40
+ [string ]$Script = " recipe.cake" ,
41
+ [string ]$Target ,
42
+ [string ]$Configuration ,
47
43
[ValidateSet (" Quiet" , " Minimal" , " Normal" , " Verbose" , " Diagnostic" )]
48
- [string ]$Verbosity = " Verbose" ,
49
- [switch ]$Experimental ,
50
- [Alias (" DryRun" , " Noop" )]
51
- [switch ]$WhatIf ,
52
- [switch ]$Mono ,
44
+ [string ]$Verbosity ,
45
+ [switch ]$ShowDescription ,
46
+ [Alias (" WhatIf" , " Noop" )]
47
+ [switch ]$DryRun ,
53
48
[switch ]$SkipToolPackageRestore ,
54
49
[Parameter (Position = 0 , Mandatory = $false , ValueFromRemainingArguments = $true )]
55
50
[string []]$ScriptArgs
56
51
)
57
52
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
+ [System.Net.ServicePointManager ]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48
63
+ } catch {
64
+ 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'
65
+ }
66
+
58
67
[Reflection.Assembly ]::LoadWithPartialName(" System.Security" ) | Out-Null
59
68
function MD5HashFile ([string ] $filePath )
60
69
{
@@ -80,38 +89,31 @@ function MD5HashFile([string] $filePath)
80
89
}
81
90
}
82
91
92
+ function GetProxyEnabledWebClient
93
+ {
94
+ $wc = New-Object System.Net.WebClient
95
+ $proxy = [System.Net.WebRequest ]::GetSystemWebProxy()
96
+ $proxy.Credentials = [System.Net.CredentialCache ]::DefaultCredentials
97
+ $wc.Proxy = $proxy
98
+ return $wc
99
+ }
100
+
83
101
Write-Host " Preparing to run build script..."
84
102
85
103
if (! $PSScriptRoot ){
86
104
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path - Parent
87
105
}
88
106
89
107
$TOOLS_DIR = Join-Path $PSScriptRoot " tools"
108
+ $ADDINS_DIR = Join-Path $TOOLS_DIR " Addins"
109
+ $MODULES_DIR = Join-Path $TOOLS_DIR " Modules"
90
110
$NUGET_EXE = Join-Path $TOOLS_DIR " nuget.exe"
91
111
$CAKE_EXE = Join-Path $TOOLS_DIR " Cake/Cake.exe"
92
112
$NUGET_URL = " https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
93
113
$PACKAGES_CONFIG = Join-Path $TOOLS_DIR " packages.config"
94
114
$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR " packages.config.md5sum"
95
-
96
- # Should we use mono?
97
- $UseMono = " " ;
98
- if ($Mono.IsPresent ) {
99
- Write-Verbose - Message " Using the Mono based scripting engine."
100
- $UseMono = " -mono"
101
- }
102
-
103
- # Should we use the new Roslyn?
104
- $UseExperimental = " " ;
105
- if ($Experimental.IsPresent -and ! ($Mono.IsPresent )) {
106
- Write-Verbose - Message " Using experimental version of Roslyn."
107
- $UseExperimental = " -experimental"
108
- }
109
-
110
- # Is this a dry run?
111
- $UseDryRun = " " ;
112
- if ($WhatIf.IsPresent ) {
113
- $UseDryRun = " -dryrun"
114
- }
115
+ $ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR " packages.config"
116
+ $MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR " packages.config"
115
117
116
118
# Make sure tools folder exists
117
119
if ((Test-Path $PSScriptRoot ) -and ! (Test-Path $TOOLS_DIR )) {
@@ -122,7 +124,10 @@ if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
122
124
# Make sure that packages.config exist.
123
125
if (! (Test-Path $PACKAGES_CONFIG )) {
124
126
Write-Verbose - Message " Downloading packages.config..."
125
- try { (New-Object System.Net.WebClient).DownloadFile(" https://cakebuild.net/download/bootstrapper/packages" , $PACKAGES_CONFIG ) } catch {
127
+ try {
128
+ $wc = GetProxyEnabledWebClient
129
+ $wc.DownloadFile (" https://cakebuild.net/download/bootstrapper/packages" , $PACKAGES_CONFIG )
130
+ } catch {
126
131
Throw " Could not download packages.config."
127
132
}
128
133
}
@@ -142,7 +147,8 @@ if (!(Test-Path $NUGET_EXE)) {
142
147
if (! (Test-Path $NUGET_EXE )) {
143
148
Write-Verbose - Message " Downloading NuGet.exe..."
144
149
try {
145
- (New-Object System.Net.WebClient).DownloadFile($NUGET_URL , $NUGET_EXE )
150
+ $wc = GetProxyEnabledWebClient
151
+ $wc.DownloadFile ($NUGET_URL , $NUGET_EXE )
146
152
} catch {
147
153
Throw " Could not download NuGet.exe."
148
154
}
@@ -161,20 +167,56 @@ if(-Not $SkipToolPackageRestore.IsPresent) {
161
167
if ((! (Test-Path $PACKAGES_CONFIG_MD5 )) -Or
162
168
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
163
169
Write-Verbose - Message " Missing or changed package.config hash..."
164
- Remove-Item * - Recurse - Exclude packages.config, nuget.exe
170
+ Get-ChildItem - Exclude packages.config, nuget.exe , Cake.Bakery |
171
+ Remove-Item - Recurse
165
172
}
166
173
167
174
Write-Verbose - Message " Restoring tools from NuGet..."
168
175
$NuGetOutput = Invoke-Expression " &`" $NUGET_EXE `" install -ExcludeVersion -OutputDirectory `" $TOOLS_DIR `" "
169
176
170
177
if ($LASTEXITCODE -ne 0 ) {
171
- Throw " An error occured while restoring NuGet tools."
178
+ Throw " An error occurred while restoring NuGet tools."
172
179
}
173
180
else
174
181
{
175
182
$md5Hash | Out-File $PACKAGES_CONFIG_MD5 - Encoding " ASCII"
176
183
}
177
184
Write-Verbose - Message ($NuGetOutput | out-string )
185
+
186
+ Pop-Location
187
+ }
188
+
189
+ # Restore addins from NuGet
190
+ if (Test-Path $ADDINS_PACKAGES_CONFIG ) {
191
+ Push-Location
192
+ Set-Location $ADDINS_DIR
193
+
194
+ Write-Verbose - Message " Restoring addins from NuGet..."
195
+ $NuGetOutput = Invoke-Expression " &`" $NUGET_EXE `" install -ExcludeVersion -OutputDirectory `" $ADDINS_DIR `" "
196
+
197
+ if ($LASTEXITCODE -ne 0 ) {
198
+ Throw " An error occurred while restoring NuGet addins."
199
+ }
200
+
201
+ Write-Verbose - Message ($NuGetOutput | out-string )
202
+
203
+ Pop-Location
204
+ }
205
+
206
+ # Restore modules from NuGet
207
+ if (Test-Path $MODULES_PACKAGES_CONFIG ) {
208
+ Push-Location
209
+ Set-Location $MODULES_DIR
210
+
211
+ Write-Verbose - Message " Restoring modules from NuGet..."
212
+ $NuGetOutput = Invoke-Expression " &`" $NUGET_EXE `" install -ExcludeVersion -OutputDirectory `" $MODULES_DIR `" "
213
+
214
+ if ($LASTEXITCODE -ne 0 ) {
215
+ Throw " An error occurred while restoring NuGet modules."
216
+ }
217
+
218
+ Write-Verbose - Message ($NuGetOutput | out-string )
219
+
178
220
Pop-Location
179
221
}
180
222
@@ -183,7 +225,18 @@ if (!(Test-Path $CAKE_EXE)) {
183
225
Throw " Could not find Cake.exe at $CAKE_EXE "
184
226
}
185
227
228
+
229
+
230
+ # Build Cake arguments
231
+ $cakeArguments = @ (" $Script " );
232
+ if ($Target ) { $cakeArguments += " -target=$Target " }
233
+ if ($Configuration ) { $cakeArguments += " -configuration=$Configuration " }
234
+ if ($Verbosity ) { $cakeArguments += " -verbosity=$Verbosity " }
235
+ if ($ShowDescription ) { $cakeArguments += " -showdescription" }
236
+ if ($DryRun ) { $cakeArguments += " -dryrun" }
237
+ $cakeArguments += $ScriptArgs
238
+
186
239
# Start Cake
187
240
Write-Host " Running build script..."
188
- Invoke-Expression " & `" $CAKE_EXE `" `" $Script `" -target= `" $Target `" -configuration= `" $Configuration `" -verbosity= `" $Verbosity `" $UseMono $UseDryRun $UseExperimental $ScriptArgs "
189
- exit $LASTEXITCODE
241
+ & $CAKE_EXE $cakeArguments
242
+ exit $LASTEXITCODE
0 commit comments