@@ -37,7 +37,7 @@ https://cakebuild.net
3737
3838[CmdletBinding ()]
3939Param (
40- [string ]$Script = " build.cake " ,
40+ [string ]$Script ,
4141 [string ]$Target ,
4242 [string ]$Configuration ,
4343 [ValidateSet (" Quiet" , " Minimal" , " Normal" , " Verbose" , " Diagnostic" )]
@@ -50,6 +50,11 @@ Param(
5050 [string []]$ScriptArgs
5151)
5252
53+ # This is an automatic variable in PowerShell Core, but not in Windows PowerShell 5.x
54+ if (-not (Test-Path variable:global:IsCoreCLR)) {
55+ $IsCoreCLR = $false
56+ }
57+
5358# Attempt to set highest encryption available for SecurityProtocol.
5459# PowerShell will not set this by default (until maybe .NET 4.6.x). This
5560# will typically produce a message for PowerShell v2 (just an info
@@ -107,6 +112,9 @@ if(!$PSScriptRoot){
107112 $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path - Parent
108113}
109114
115+ if (! $Script ){
116+ $Script = Join-Path $PSScriptRoot " build.cake"
117+ }
110118$TOOLS_DIR = Join-Path $PSScriptRoot " tools"
111119$ADDINS_DIR = Join-Path $TOOLS_DIR " Addins"
112120$MODULES_DIR = Join-Path $TOOLS_DIR " Modules"
@@ -118,6 +126,10 @@ $PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum"
118126$ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR " packages.config"
119127$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR " packages.config"
120128
129+ $env: CAKE_PATHS_TOOLS = $TOOLS_DIR
130+ $env: CAKE_PATHS_ADDINS = $ADDINS_DIR
131+ $env: CAKE_PATHS_MODULES = $MODULES_DIR
132+
121133# Make sure tools folder exists
122134if ((Test-Path $PSScriptRoot ) -and ! (Test-Path $TOOLS_DIR )) {
123135 Write-Verbose - Message " Creating tools directory..."
@@ -157,6 +169,12 @@ if (!(Test-Path $NUGET_EXE)) {
157169 }
158170}
159171
172+ # These are automatic variables in PowerShell Core, but not in Windows PowerShell 5.x
173+ if (-not (Test-Path variable:global:ismacos)) {
174+ $IsLinux = $false
175+ $IsMacOS = $false
176+ }
177+
160178# Save nuget.exe path to environment to be available to child processed
161179$env: NUGET_EXE = $NUGET_EXE
162180$env: NUGET_EXE_INVOCATION = if ($IsLinux -or $IsMacOS ) {
@@ -180,7 +198,7 @@ if(-Not $SkipToolPackageRestore.IsPresent) {
180198 }
181199
182200 Write-Verbose - Message " Restoring tools from NuGet..."
183-
201+
184202 $NuGetOutput = Invoke-Expression " & $env: NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `" $TOOLS_DIR `" "
185203
186204 if ($LASTEXITCODE -ne 0 ) {
@@ -243,11 +261,11 @@ $CAKE_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
243261 # Build an array (not a string) of Cake arguments to be joined later
244262$cakeArguments = @ ()
245263if ($Script ) { $cakeArguments += " `" $Script `" " }
246- if ($Target ) { $cakeArguments += " -target=`" $Target `" " }
247- if ($Configuration ) { $cakeArguments += " -configuration=$Configuration " }
248- if ($Verbosity ) { $cakeArguments += " -verbosity=$Verbosity " }
249- if ($ShowDescription ) { $cakeArguments += " -showdescription" }
250- if ($DryRun ) { $cakeArguments += " -dryrun" }
264+ if ($Target ) { $cakeArguments += " -- target=`" $Target `" " }
265+ if ($Configuration ) { $cakeArguments += " -- configuration=$Configuration " }
266+ if ($Verbosity ) { $cakeArguments += " -- verbosity=$Verbosity " }
267+ if ($ShowDescription ) { $cakeArguments += " -- showdescription" }
268+ if ($DryRun ) { $cakeArguments += " -- dryrun" }
251269$cakeArguments += $ScriptArgs
252270
253271# Start Cake
0 commit comments