Have I got it right that AzureDevOps doesn't support snupkg therefore you have to use the PublishSymbols
task which only works on Agent.OS -equals Windows_NT
?
- task: PowerShell@2
displayName: 'dotnet pack'
condition: ne(variables['projectsToPack'], '')
inputs:
targetType: 'inline'
script: |
$packVersionSuffix = '$(packVersionSuffix)'
$bo = '$(Build.ArtifactStagingDirectory)' # 'artifact' (sic).
$projectsToPack = '$(projectsToPack)'.Split(';')
$projectsToPush = '$(projectsToPush)'.Split(';')
foreach( $csproj in Get-ChildItem -Recurse -Filter *.csproj ) {
if($projectsToPack.Contains($csproj.Name)) {
$outputDirectory = "$bo\pack"
if( -Not $projectsToPush.Contains($csproj.Name)) {
$outputDirectory = "$bo\pack_no_push"
}
$csprojFullName = $csproj.FullName
if('$(packVersionSuffix)' -ne '')
{
dotnet pack --no-restore --no-build --configuration $(buildConfiguration) --include-source --include-symbols --version-suffix "$packVersionSuffix" --output "$outputDirectory" "$csprojFullName"
}
else {
dotnet pack --no-restore --no-build --configuration $(buildConfiguration) --include-source --include-symbols --output "$outputDirectory" "$csprojFullName" # Fuck knows why .FullName not only isn't needed but moreover doesn't work.
}
# -p:SymbolPackageFormat=snupkg
}
}
if (Test-Path "$bo\pack_no_push") {
Remove-Item -Force -Recurse "$bo\pack_no_push"
}
- task: NuGetCommand@2
displayName: 'Push packages'
condition: and( succeeded(), ne(variables['projectsToPush'], ''), ne(variables['Build.SourceBranchName'], 'merge')) # Don't push a package for PR builds.
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/pack/**/*.symbols.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: 'Company'
allowPackageConflicts: false
#skipDuplicates isn't supported :( Hence all the faff with projectsToPush.
- task: PowerShell@2
displayName: 'Windows_NT for PublishSymbols@2'
condition: and( succeeded(), ne(variables['projectsToPush'], ''), ne(variables['Build.SourceBranchName'], 'merge'), ne(variables['Agent.OS'], 'Windows_NT'))
inputs:
targetType: 'inline'
script: |
echo "Task 'PublishSymbols@2' requires Agent.OS -equals Windows_NT (add this demand to your job)."
exit 1
- task: PublishSymbols@2
displayName: 'Push symbols'
condition: and( succeeded(), ne(variables['projectsToPush'], ''), ne(variables['Build.SourceBranchName'], 'merge')) # Don't push a package for PR builds.
inputs:
SearchPattern: '**/bin/**/*.pdb' # Includes pakcages that haven't been published, but 'should be' identical to previous symbols.
SymbolServerType: 'TeamServices'
IndexSources: false # Not needed when using SourceLink https://learn.microsoft.com/en-us/azure/devops/pipelines/artifacts/symbols?view=azure-devops&viewFallbackFrom=vsts