Skip to content

Commit 51ad769

Browse files
claudeHeyItsGilbert
authored andcommitted
Fix Azure Pipelines documentation inaccuracies
Corrected several technical inaccuracies in the Azure Pipelines integration guide: - Fixed code coverage tool from JaCoCo (Java) to Cobertura for .NET projects - Rewrote PowerShell version matrix section to use proper PowerShell@2 task syntax with pwsh parameter instead of incorrect custom variable approach - Fixed Coverlet output path to use directory instead of file path - Updated deprecated PublishBuildArtifacts@1 to modern publish shortcut - Standardized cache key naming from 'psake' to 'psmodules' for consistency
1 parent d14d528 commit 51ad769

File tree

1 file changed

+34
-20
lines changed

1 file changed

+34
-20
lines changed

docs/ci-examples/azure-pipelines.md

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ Speed up builds by caching the PowerShell modules directory:
8080
```yaml
8181
- task: Cache@2
8282
inputs:
83-
key: 'psake | "$(Agent.OS)" | requirements.psd1'
83+
key: 'psmodules | "$(Agent.OS)" | requirements.psd1'
8484
restoreKeys: |
85-
psake | "$(Agent.OS)"
86-
psake
85+
psmodules | "$(Agent.OS)"
86+
psmodules
8787
path: $(Pipeline.Workspace)/.psmodules
8888
displayName: 'Cache PowerShell modules'
8989
@@ -182,7 +182,7 @@ stages:
182182
- task: PublishCodeCoverageResults@2
183183
condition: succeededOrFailed()
184184
inputs:
185-
codeCoverageTool: 'JaCoCo'
185+
codeCoverageTool: 'Cobertura'
186186
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
187187
displayName: 'Publish code coverage'
188188

@@ -273,41 +273,55 @@ strategy:
273273
matrix:
274274
Windows_PS7:
275275
imageName: 'windows-latest'
276-
pwshVersion: '7.4'
276+
psTask: 'pwsh'
277277
Linux_PS7:
278278
imageName: 'ubuntu-latest'
279-
pwshVersion: '7.4'
279+
psTask: 'pwsh'
280280
macOS_PS7:
281281
imageName: 'macOS-latest'
282-
pwshVersion: '7.4'
282+
psTask: 'pwsh'
283283
Windows_PS51:
284284
imageName: 'windows-2019'
285-
pwshVersion: '5.1'
285+
psTask: 'powershell'
286286

287287
pool:
288288
vmImage: $(imageName)
289289

290290
steps:
291-
- pwsh: |
292-
Write-Host "OS: $(imageName)"
293-
Write-Host "PowerShell Version: $($PSVersionTable.PSVersion)"
291+
- task: PowerShell@2
292+
inputs:
293+
targetType: 'inline'
294+
pwsh: ${{ eq(variables.psTask, 'pwsh') }}
295+
script: |
296+
Write-Host "OS: $env:AGENT_OS"
297+
Write-Host "PowerShell Version: $($PSVersionTable.PSVersion)"
294298
displayName: 'Display environment info'
295299

296-
- pwsh: |
297-
Install-Module -Name psake -Scope CurrentUser -Force
300+
- task: PowerShell@2
301+
inputs:
302+
targetType: 'inline'
303+
pwsh: ${{ eq(variables.psTask, 'pwsh') }}
304+
script: |
305+
Install-Module -Name psake -Scope CurrentUser -Force
298306
displayName: 'Install psake'
299307

300-
- pwsh: |
301-
Invoke-psake -buildFile .\psakefile.ps1 -taskList Build, Test
308+
- task: PowerShell@2
309+
inputs:
310+
targetType: 'inline'
311+
pwsh: ${{ eq(variables.psTask, 'pwsh') }}
312+
script: |
313+
Invoke-psake -buildFile .\psakefile.ps1 -taskList Build, Test
302314
displayName: 'Run psake build'
303315

304-
- task: PublishBuildArtifacts@1
305-
inputs:
306-
pathToPublish: '$(System.DefaultWorkingDirectory)/build'
307-
artifactName: 'build-$(imageName)-ps$(pwshVersion)'
316+
- publish: '$(System.DefaultWorkingDirectory)/build'
317+
artifact: 'build-$(imageName)'
308318
displayName: 'Upload artifacts'
309319
```
310320
321+
**Note:** The `pwsh` parameter in PowerShell@2 task controls which PowerShell version runs:
322+
- `pwsh: true` = PowerShell 7+ (cross-platform)
323+
- `pwsh: false` = Windows PowerShell 5.1 (Windows only)
324+
311325
## Variable Groups and Secrets
312326

313327
Azure Pipelines provides variable groups for managing secrets and configuration.
@@ -490,7 +504,7 @@ Task Test -depends Build {
490504
--results-directory "$BuildDir/TestResults" `
491505
/p:CollectCoverage=true `
492506
/p:CoverletOutputFormat=cobertura `
493-
/p:CoverletOutput="$BuildDir/coverage.xml"
507+
/p:CoverletOutput="$BuildDir/"
494508
}
495509
}
496510

0 commit comments

Comments
 (0)