@@ -39,7 +39,7 @@ $helperUri = @(
39
39
' scrthq' # User
40
40
' a99cc06e75eb31769d01b2adddc6d200' # Gist ID
41
41
' raw'
42
- ' 5d9933ff2c7433a1ec415282354fb9503748601f ' # Commit SHA
42
+ ' 958909a13527fa8c345b6bb552a737b0d9862bc0 ' # Commit SHA
43
43
' AzurePipelineHelpers.ps1' # Filename
44
44
) -join ' /'
45
45
$fileUri = $helperUri -replace " [$ ( [RegEx ]::Escape(" $ ( ([System.IO.Path ]::GetInvalidFileNameChars() + [System.IO.Path ]::GetInvalidPathChars()) -join ' ' ) " )) ]" , " _"
@@ -128,188 +128,3 @@ foreach ($item in $moduleDependencies) {
128
128
129
129
Add-Heading " Executing Invoke-Build"
130
130
Invoke-Build - ModuleName $ModuleName @PSBoundParameters
131
-
132
- <#
133
- [cmdletbinding(DefaultParameterSetName = 'task')]
134
- param(
135
- [parameter(ParameterSetName = 'task', Position = 0)]
136
- [ValidateSet('Init','Clean','Update','Build','Import','Full','Test','Deploy')]
137
- [string[]]
138
- $Task,
139
- [Parameter()]
140
- [string]
141
- $ModuleName = (Get-Item $PSScriptRoot).BaseName,
142
- [Parameter()]
143
- [hashtable]
144
- $Dependencies = @{
145
- Configuration = '1.3.1'
146
- PackageManagement = '1.3.1'
147
- PowerShellGet = '2.1.2'
148
- InvokeBuild = '5.5.2'
149
- },
150
- [parameter(ParameterSetName = 'help')]
151
- [switch]$Help,
152
-
153
- [switch]$UpdateModules
154
- )
155
- $helperUri = @(
156
- 'https://gist.githubusercontent.com'
157
- 'scrthq' # User
158
- 'a99cc06e75eb31769d01b2adddc6d200' # Gist ID
159
- 'raw'
160
- '017a0f70ef9f7675119f1dadd4209857a3824ff0' # Commit SHA
161
- 'AzurePipelineHelpers.ps1' # Filename
162
- ) -join '/'
163
- $fileUri = $helperUri -replace "[$([RegEx]::Escape("$(([System.IO.Path]::GetInvalidFileNameChars() + [System.IO.Path]::GetInvalidPathChars()) -join '')"))]","_"
164
- $ciPath = [System.IO.Path]::Combine($PSScriptRoot,'ci')
165
- $localGistPath = [System.IO.Path]::Combine($ciPath,$fileUri)
166
- if (Test-Path $localGistPath) {
167
- Write-Host -ForegroundColor Cyan "##[section] Importing Azure Pipelines Helper from Cached Gist: $localGistPath"
168
- $helperContent = Get-Content $localGistPath -Raw
169
- } else {
170
- Write-Host -ForegroundColor Cyan "##[section] Cleaning out stale Gist scripts from the CI Path"
171
- Get-ChildItem $ciPath -Filter 'https___gist.githubusercontent.com_scrthq*.ps1' | Remove-Item -Force
172
- Write-Host -ForegroundColor Cyan "##[section] Importing Azure Pipelines Helper from Gist: $helperUri"
173
- $helperContent = Invoke-RestMethod -Uri $helperUri
174
- $helperContent | Set-Content $localGistPath -Force
175
- }
176
- .([scriptblock]::Create($helperContent))($ModuleName)
177
- Set-BuildVariables
178
-
179
- # build/init script borrowed from PoshBot x Brandon Olin
180
- Get-PackageProvider -Name Nuget -ForceBootstrap -Verbose:$false | Out-Null
181
- Set-PSRepository -Name PSGallery -InstallationPolicy Trusted -Verbose:$false
182
- $PSDefaultParameterValues = @{
183
- '*-Module:Verbose' = $false
184
- 'Import-Module:ErrorAction' = 'Stop'
185
- 'Import-Module:Force' = $true
186
- 'Import-Module:Verbose' = $false
187
- 'Install-Module:AllowClobber' = $true
188
- 'Install-Module:ErrorAction' = 'Stop'
189
- 'Install-Module:Force' = $true
190
- 'Install-Module:Scope' = 'CurrentUser'
191
- 'Install-Module:Verbose' = $false
192
- }
193
-
194
- function Resolve-Module {
195
- [Cmdletbinding()]
196
- param (
197
- [Parameter(Mandatory, ValueFromPipeline)]
198
- [string[]]$Name,
199
-
200
- [switch]$UpdateModules
201
- )
202
- process {
203
- foreach ($moduleName in $Name) {
204
- $versionToImport = ''
205
-
206
- Write-Verbose -Message "Resolving Module [$($moduleName)]"
207
- if ($Module = Get-Module -Name $moduleName -ListAvailable -Verbose:$false) {
208
- # Determine latest version on PSGallery and warn us if we're out of date
209
- $latestLocalVersion = ($Module | Measure-Object -Property Version -Maximum).Maximum
210
- $latestGalleryVersion = (Find-Module -Name $moduleName -Repository PSGallery |
211
- Measure-Object -Property Version -Maximum).Maximum
212
-
213
- # Out we out of date?
214
- if ($latestLocalVersion -lt $latestGalleryVersion) {
215
- if ($UpdateModules) {
216
- Write-Verbose -Message "$($moduleName) installed version [$($latestLocalVersion.ToString())] is outdated. Installing gallery version [$($latestGalleryVersion.ToString())]"
217
- if ($UpdateModules) {
218
- Install-Module -Name $moduleName -RequiredVersion $latestGalleryVersion
219
- $versionToImport = $latestGalleryVersion
220
- }
221
- } else {
222
- Write-Warning "$($moduleName) is out of date. Latest version on PSGallery is [$latestGalleryVersion]. To update, use the -UpdateModules switch."
223
- }
224
- } else {
225
- $versionToImport = $latestLocalVersion
226
- }
227
- } else {
228
- Write-Verbose -Message "[$($moduleName)] missing. Installing..."
229
- Install-Module -Name $moduleName -Repository PSGallery
230
- $versionToImport = (Get-Module -Name $moduleName -ListAvailable | Measure-Object -Property Version -Maximum).Maximum
231
- }
232
-
233
- Write-Verbose -Message "$($moduleName) installed. Importing..."
234
- if (-not [string]::IsNullOrEmpty($versionToImport)) {
235
- Import-module -Name $moduleName -RequiredVersion $versionToImport
236
- } else {
237
- Import-module -Name $moduleName
238
- }
239
- }
240
- }
241
- }
242
-
243
- $update = @{}
244
- $verbose = @{}
245
- if ($PSBoundParameters.ContainsKey('UpdateModules')) {
246
- $update['UpdateModules'] = $PSBoundParameters['UpdateModules']
247
- }
248
- if ($PSBoundParameters.ContainsKey('Verbose')) {
249
- $verbose['Verbose'] = $PSBoundParameters['Verbose']
250
- }
251
-
252
- if ($Help) {
253
- 'psake' | Resolve-Module @update -Verbose
254
- Get-PSakeScriptTasks -buildFile "$PSScriptRoot\psake.ps1" |
255
- Sort-Object -Property Name |
256
- Format-Table -Property Name, Description, Alias, DependsOn
257
- }
258
- else {
259
- if (
260
- $Task -eq 'Deploy' -and -not $Force -and (
261
- $ENV:BUILD_BUILDURI -notlike 'vstfs:*' -or
262
- $env:BUILD_SOURCEBRANCH -like '*pull*' -or
263
- $env:BUILD_SOURCEVERSIONMESSAGE -notmatch '!deploy' -or
264
- $env:BUILD_SOURCEBRANCHNAME -ne 'master' -or
265
- $PSVersionTable.PSVersion.Major -ne 5 -or
266
- $null -eq $env:NugetApiKey
267
- )
268
- ) {
269
- "Task is 'Deploy', but conditions are not correct for deployment:`n" +
270
- " + Current build system is VSTS : $($env:BUILD_BUILDURI -like 'vstfs:*') [$env:BUILD_BUILDURI]`n" +
271
- " + Current branch is master : $($env:BUILD_SOURCEBRANCHNAME -eq 'master') [$env:BUILD_SOURCEBRANCHNAME]`n" +
272
- " + Source is not a pull request : $($env:BUILD_SOURCEBRANCH -notlike '*pull*') [$env:BUILD_SOURCEBRANCH]`n" +
273
- " + Current PS major version is 5 : $($PSVersionTable.PSVersion.Major -eq 5) [$($PSVersionTable.PSVersion.ToString())]`n" +
274
- " + NuGet API key is not null : $($null -ne $env:NugetApiKey)`n" +
275
- " + Build script is not Force ran : $($Force)`n" +
276
- " + Commit message matches '!deploy' : $($env:BUILD_SOURCEVERSIONMESSAGE -match '!deploy') [$env:BUILD_SOURCEVERSIONMESSAGE]`n" +
277
- "Skipping psake for this job!" | Write-Host -ForegroundColor Yellow
278
- exit 0
279
- }
280
- else {
281
- if ($Task -eq 'Deploy') {
282
- "Task is 'Deploy' and conditions are correct for deployment:`n" +
283
- " + Build script is Force ran : $($Force)`n" +
284
- " + Current build system is VSTS : $($env:BUILD_BUILDURI -like 'vstfs:*') [$env:BUILD_BUILDURI]`n" +
285
- " + Current branch is master : $($env:BUILD_SOURCEBRANCHNAME -eq 'master') [$env:BUILD_SOURCEBRANCHNAME]`n" +
286
- " + Source is not a pull request : $($env:BUILD_SOURCEBRANCH -notlike '*pull*') [$env:BUILD_SOURCEBRANCH]`n" +
287
- " + Current PS major version is 5 : $($PSVersionTable.PSVersion.Major -eq 5) [$($PSVersionTable.PSVersion.ToString())]`n" +
288
- " + NuGet API key is not null : $($null -ne $env:NugetApiKey)`n" +
289
- " + Commit message matches '!deploy' : $($env:BUILD_SOURCEVERSIONMESSAGE -match '!deploy') [$env:BUILD_SOURCEVERSIONMESSAGE]"| Write-Host -ForegroundColor Green
290
- }
291
- 'psake' | Resolve-Module @update -Verbose
292
- Set-BuildEnvironment -Force
293
- Write-Host -ForegroundColor Green "Modules successfully resolved..."
294
- $psakeParams = @{
295
- nologo = $true
296
- buildFile = "$PSScriptRoot\psake.ps1"
297
- }
298
- if ($PSBoundParameters.ContainsKey('Task')) {
299
- Write-Host -ForegroundColor Green "Invoking psake with task list: [ $($Task -join ', ') ]`n"
300
- $psakeParams['taskList'] = $Task
301
- }
302
- if ($Force) {
303
- $global:ForceDeploy = $true
304
- }
305
- else {
306
- $global:ForceDeploy = $false
307
- }
308
- Invoke-psake @psakeParams @verbose
309
- if ($Task -contains 'Import' -and $psake.build_success) {
310
- Import-Module ([System.IO.Path]::Combine($env:BHBuildOutput,$env:BHProjectName)) -Verbose:$false
311
- }
312
- exit ( [int]( -not $psake.build_success ) )
313
- }
314
- }
315
- #>
0 commit comments