12

I want to package and publish a .net standard based code as a nuget package using VSTS build. I have created a private nuget feed (in VSTS Artifacts) to which I would like to publish nuget package along with symbols package.

I tried using dotnet CLI tasks to build and publish but it only publish .nupkg and not *.snupkg to the nuget feed.

I googled alot but I only found articles related to publishing to nuget.org and not to a private feed.

Prado
  • 914
  • 10
  • 21

4 Answers4

8

Publish *.snupkg symbol package to private feed in VSTS

You can publish the .snupkg symbol package to NuGet.org, or to any NuGet server that opts into this experience. But azure devops private feed does not have this experience.

You can get the detailed info from this wiki NuGet Package Debugging & Symbols Improvements:

  • When publishing packages, both the symbols package and the .nupkg will be easily published to NuGet.org, or to any NuGet server that opts into this experience.

Reason:

As we know, when we consume .snupkg in Visual Studio, we add a new symbol server location under Symbol file (.pdb) locations:

enter image description here

But Visual Studio can only parse the symbol file (.pdb) directly rather than the .snupkg package, so we need a NuGet server to help us read the .pdb file from the .snupkg package. Azure devops feed is more inclined to be a shared repository of packages.

So, we have to publish *.snupkg symbol package to NuGet.org, or to any NuGet server that opts into this experience.

If you do not want share your package on the nuget.org, You can host your own NuGet server or you can use a lightweight solution to resolve this issue (You can debug the nuget package with private feed).

Hope this helps.

Leo Liu-MSFT
  • 52,692
  • 7
  • 69
  • 81
  • Thanks for the solution. Can I publish .nupkg file to *.pkgs.visualstudio.com and .snupkg file to nuget.org for the same nuget package code? – Prado Jan 16 '19 at 11:45
  • Also what is the difference between using *.snupkg and using VSTS Symbol Server (using Publish Symbol build task) for dealing with .pdb files of nuget package? – Prado Jan 16 '19 at 11:50
  • @Prado, I am afraid you can not do that. Check the wiki [Symbols Package Requirements](https://github.com/NuGet/Home/wiki/NuGet-Package-Debugging-&-Symbols-Improvements#symbols-package-requirements), "To ensure that the uploaded symbols exactly match the uploaded .dlls, we are working with the compiler teams to store hashes of the .pdbs generated from a .dll in the .dll itself. This will be a requirement for uploading .nupkgs and .snupkgs to NuGet.org". – Leo Liu-MSFT Jan 17 '19 at 01:47
  • 1
    The *.snupkg is used to **debug the nuget package**, the VSTS Symbol Server is used to publish the symbols for debugging. General speaking, one is used to debug the nuget package directly, one is used to publish symbols files. – Leo Liu-MSFT Jan 17 '19 at 01:58
4

Azure Artifacts does not currently support .snupkgs but it does have a symbol server to which you can publish if you're building using Azure Pipelines. This doc walks through setting up a pipeline that publishes symbols.

Alex Mullans
  • 1,600
  • 2
  • 15
  • 34
  • 1
    Actually, you can publish snupkg files to Azure Artifacts - you just cant use them for debugging (at time of writing) – MercifulGiraffe Jan 17 '19 at 22:42
  • I've slightly updated the answer. You're correct that you can publish .snupkgs to the service and they will be accepted. However, they can't be used for debugging in VS and they will also "squat" on the package name/version used by your nupkg, so you'll be unable to publish that and therefore unable to share the bits you're trying to share. – Alex Mullans Jan 18 '19 at 04:48
  • We are currently pushing both nupkg and snupkg files to Azure DevOps and not seeing the "squatting" on the package name/version that you are. Not sure why our experience is different to yours! – MercifulGiraffe Jan 20 '19 at 20:59
  • @AlexMullans the default behaviour is to create a `symbols.nupkg` file rather than a `.snupkg`. This causes the squatting behaviour that you see – Matthew Steeples Mar 05 '21 at 23:34
  • According to the [documentation for SourceLink](https://github.com/dotnet/sourcelink#alternative-pdb-distribution), symbol packages are "not supported by Azure DevOps Artifacts service." – JamesQMurphy Mar 09 '21 at 13:42
3

You can publish the snupkg files to Azure DevOps, but at this point, you cannot consume them from with VS to debug. Here is how I did it:

1) setup a "Use .Net Core" task to upgrade the .net sdk to the version that supports this (as below)

SDK install

2) setup a custom dotnet pack command (as below)

pack command

3) push it to Azure using the dotnet push command (as below)

dotnet push setup

This results in the snupkg being pushed to Azure DevOps Artifacts, thus:

result

  • I managed to achieve that, but when looking at the artifact in AzureDevops Artifacts, there seems to be no symbols available. Did you manage to use them once pushed? – Jo Ham Jul 25 '19 at 17:49
  • @JoHam I have not tried recently, but when I posted this answer, Azure DevOps didn't recognize the artifacts repository as a valid symbols location. Last I heard, this was some way away. – MercifulGiraffe Jul 26 '19 at 02:51
3

You may well want to just embed the symbol PDB in the main NuGet package itself. IMO that's the best approach here today - it's much simpler, removing the need for the symbol server at all and works well with all repository types, private VSTS/Azure DevOps feeds public repos. The only downside is that clients have to download modestly bigger NuGet packages even if they don't use the debug info, but that seems minor.

Adding the PDB in the NuGet package is normally just a matter of adding this to your project file:

<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>

See NuGet #4142 and Include pdb files into my nuget (nupkg) files.

Ian Kemp
  • 24,155
  • 16
  • 97
  • 121