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
4
  • I guess using windows agent is a good way in your issue. .snupkg symbol packages have some limitations and thus you should consider switching to Portable PDBs by setting DebugType property to portable. Commented Dec 30, 2022 at 6:14
  • From this official doc,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. Commented Dec 30, 2022 at 6: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. Commented Dec 30, 2022 at 6:14
  • I also find a discussion similar to your issue, you could also have a look. Commented Dec 30, 2022 at 6:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.