0

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
Richard Barraclough
  • 2,625
  • 3
  • 36
  • 54
  • I guess using windows agent is a good way in your issue. .snupkg symbol packages have [some limitations](https://github.com/dotnet/sourcelink#alternative-pdb-distribution) and thus you should consider switching to Portable PDBs by setting DebugType property to portable. – Antonia Wu-MSFT Dec 30 '22 at 06:14
  • [From this official doc](https://learn.microsoft.com/en-us/azure/devops/pipelines/artifacts/symbols?view=azure-devops#publish-portable-pdbs-to-azure-artifacts-symbol-server),Portable PDBs are symbol files that can be created and used on all platforms unlike the traditional PDBs which are used on Windows only. So if you publish portable PDBs to Azure Artifacts symbol server, it is supposed to work in all platforms. – Antonia Wu-MSFT Dec 30 '22 at 06:14
  • But for visual studio set up may involve before consume symbols from Azure Artifacts symbol server, if you use windows self agent to run the Azure debops build pipeline and the visual studio in local, it would be easier to do set up in visual studio, I think. For Visual Studio for Mac does not support provide support debugging using symbol servers. – Antonia Wu-MSFT Dec 30 '22 at 06:14
  • I also find a [discussion](https://developercommunity.visualstudio.com/t/add-snupkg-support-to-azure-devops-artifacts/657354#T-N1247260) similar to your issue, you could also have a look. – Antonia Wu-MSFT Dec 30 '22 at 06:27

0 Answers0