@@ -21,16 +21,6 @@ The build script target to run.
2121The build configuration to use.
2222. PARAMETER Verbosity
2323Specifies the amount of information to be displayed.
24- . PARAMETER ShowDescription
25- Shows description about tasks.
26- . PARAMETER DryRun
27- 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.
32- . PARAMETER SkipToolPackageRestore
33- Skips restoring of packages.
3424. PARAMETER UseDotNetTest
3525Run tests against the .NET SDK build of OmniSharp
3626. PARAMETER ScriptArgs
@@ -43,50 +33,38 @@ https://cakebuild.net
4333
4434[CmdletBinding ()]
4535Param (
46- [parameter (position = 0 )]
36+ [parameter (position = 0 )]
4737 [string ]$Target = " Default" ,
4838 [string ]$Script = " build.cake" ,
4939 [string ]$Configuration ,
5040 [ValidateSet (" Quiet" , " Minimal" , " Normal" , " Verbose" , " Diagnostic" )]
5141 [string ]$Verbosity ,
52- [switch ]$ShowDescription ,
53- [Alias (" WhatIf" , " Noop" )]
54- [switch ]$DryRun ,
55- [switch ]$Experimental ,
56- [switch ]$Mono ,
57- [switch ]$SkipToolPackageRestore ,
5842 [switch ]$UseDotNetTest ,
59- [Parameter (Position = 0 , Mandatory = $false , ValueFromRemainingArguments = $true )]
43+ [Parameter (Position = 0 , Mandatory = $false , ValueFromRemainingArguments = $true )]
6044 [string []]$ScriptArgs
6145)
6246
6347[Reflection.Assembly ]::LoadWithPartialName(" System.Security" ) | Out-Null
64- function MD5HashFile ([string ] $filePath )
65- {
66- if ([string ]::IsNullOrEmpty($filePath ) -or ! (Test-Path $filePath - PathType Leaf))
67- {
48+ function MD5HashFile ([string ] $filePath ) {
49+ if ([string ]::IsNullOrEmpty($filePath ) -or ! (Test-Path $filePath - PathType Leaf)) {
6850 return $null
6951 }
7052
7153 [System.IO.Stream ] $file = $null ;
7254 [System.Security.Cryptography.MD5 ] $md5 = $null ;
73- try
74- {
55+ try {
7556 $md5 = [System.Security.Cryptography.MD5 ]::Create()
7657 $file = [System.IO.File ]::OpenRead($filePath )
7758 return [System.BitConverter ]::ToString($md5.ComputeHash ($file ))
7859 }
79- finally
80- {
81- if ($file -ne $null )
82- {
60+ finally {
61+ if ($file -ne $null ) {
8362 $file.Dispose ()
8463 }
8564 }
8665}
8766
88- function GetProxyEnabledWebClient
89- {
67+ function GetProxyEnabledWebClient {
9068 $wc = New-Object System.Net.WebClient
9169 $proxy = [System.Net.WebRequest ]::GetSystemWebProxy()
9270 $proxy.Credentials = [System.Net.CredentialCache ]::DefaultCredentials
@@ -96,19 +74,15 @@ function GetProxyEnabledWebClient
9674
9775Write-Host " Preparing to run build script..."
9876
99- if (! $PSScriptRoot ){
77+ if (! $PSScriptRoot ) {
10078 $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path - Parent
10179}
10280
10381$TOOLS_DIR = Join-Path $PSScriptRoot " tools"
104- $ADDINS_DIR = Join-Path $TOOLS_DIR " Addins"
105- $MODULES_DIR = Join-Path $TOOLS_DIR " Modules"
10682$NUGET_EXE = Join-Path $TOOLS_DIR " nuget.exe"
10783$NUGET_URL = " https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
10884$PACKAGES_CONFIG = Join-Path $TOOLS_DIR " packages.config"
10985$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR " packages.config.md5sum"
110- $ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR " packages.config"
111- $MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR " packages.config"
11286
11387# Make sure tools folder exists
11488if ((Test-Path $PSScriptRoot ) -and ! (Test-Path $TOOLS_DIR )) {
@@ -121,7 +95,9 @@ if (!(Test-Path $PACKAGES_CONFIG)) {
12195 Write-Verbose - Message " Downloading packages.config..."
12296 try {
12397 $wc = GetProxyEnabledWebClient
124- $wc.DownloadFile (" https://cakebuild.net/download/bootstrapper/packages" , $PACKAGES_CONFIG ) } catch {
98+ $wc.DownloadFile (" https://cakebuild.net/download/bootstrapper/packages" , $PACKAGES_CONFIG )
99+ }
100+ catch {
125101 Throw " Could not download packages.config."
126102 }
127103}
@@ -143,25 +119,26 @@ if (!(Test-Path $NUGET_EXE)) {
143119 try {
144120 $wc = GetProxyEnabledWebClient
145121 $wc.DownloadFile ($NUGET_URL , $NUGET_EXE )
146- } catch {
122+ }
123+ catch {
147124 Throw " Could not download NuGet.exe."
148125 }
149126}
150127
151128# Save nuget.exe path to environment to be available to child processed
152129$ENV: NUGET_EXE = $NUGET_EXE
153130
154- # Restore tools from NuGet?
155- if ( -Not $SkipToolPackageRestore .IsPresent ) {
131+ # Restore tools from NuGet
132+ if ( Test-Path $PACKAGES_CONFIG ) {
156133 Push-Location
157134 Set-Location $TOOLS_DIR
158135
159136 # Check for changes in packages.config and remove installed tools if true.
160137 [string ] $md5Hash = MD5HashFile($PACKAGES_CONFIG )
161- if ((! (Test-Path $PACKAGES_CONFIG_MD5 )) -Or
162- ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
138+ if ((! (Test-Path $PACKAGES_CONFIG_MD5 )) -Or
139+ ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
163140 Write-Verbose - Message " Missing or changed package.config hash..."
164- Remove-Item * - Recurse - Exclude packages.config, nuget.exe
141+ Remove-Item * - Recurse - Exclude packages.config, nuget.exe
165142 }
166143
167144 Write-Verbose - Message " Restoring tools from NuGet..."
@@ -170,60 +147,21 @@ if(-Not $SkipToolPackageRestore.IsPresent) {
170147 if ($LASTEXITCODE -ne 0 ) {
171148 Throw " An error occurred while restoring NuGet tools."
172149 }
173- else
174- {
150+ else {
175151 $md5Hash | Out-File $PACKAGES_CONFIG_MD5 - Encoding " ASCII"
176152 }
177153 Write-Verbose - Message ($NuGetOutput | out-string )
178154
179155 Pop-Location
180156}
181157
182- # Restore addins from NuGet
183- if (Test-Path $ADDINS_PACKAGES_CONFIG ) {
184- Push-Location
185- Set-Location $ADDINS_DIR
186-
187- Write-Verbose - Message " Restoring addins from NuGet..."
188- $NuGetOutput = Invoke-Expression " &`" $NUGET_EXE `" install -ExcludeVersion -OutputDirectory `" $ADDINS_DIR `" "
189-
190- if ($LASTEXITCODE -ne 0 ) {
191- Throw " An error occurred while restoring NuGet addins."
192- }
193-
194- Write-Verbose - Message ($NuGetOutput | out-string )
195-
196- Pop-Location
197- }
198-
199- # Restore modules from NuGet
200- if (Test-Path $MODULES_PACKAGES_CONFIG ) {
201- Push-Location
202- Set-Location $MODULES_DIR
203-
204- Write-Verbose - Message " Restoring modules from NuGet..."
205- $NuGetOutput = Invoke-Expression " &`" $NUGET_EXE `" install -ExcludeVersion -OutputDirectory `" $MODULES_DIR `" "
206-
207- if ($LASTEXITCODE -ne 0 ) {
208- Throw " An error occurred while restoring NuGet modules."
209- }
210-
211- Write-Verbose - Message ($NuGetOutput | out-string )
212-
213- Pop-Location
214- }
215-
216158dotnet tool restore
217159
218160# Build Cake arguments
219161$cakeArguments = @ (" $Script " );
220162if ($Target ) { $cakeArguments += " --target=$Target " }
221163if ($Configuration ) { $cakeArguments += " --configuration=$Configuration " }
222164if ($Verbosity ) { $cakeArguments += " --verbosity=$Verbosity " }
223- if ($ShowDescription ) { $cakeArguments += " --showdescription" }
224- if ($DryRun ) { $cakeArguments += " --dryrun" }
225- if ($Experimental ) { $cakeArguments += " --experimental" }
226- if ($Mono ) { $cakeArguments += " --mono" }
227165if ($UseDotNetTest ) { $cakeArguments += " --use-dotnet-test" }
228166$cakeArguments += $ScriptArgs
229167
0 commit comments