How to create and publish nuget symbol packages

Create the nuget symbol package

Creating a nuget package with symbols is quite easy.

You have 2 possible methods to create a nuget package with symbols:

  1. From nuspec file. How to create nuspec file.
    nuget pack MyPackage.nuspec -Symbols
    
  2. From project file.
    nuget pack MyProject.csproj -Symbols
    

Both of the commands will create 2 files {identifier}.symbols.nupkg and {identifier}.nupkg.

.Net Core

If you get this error: Unable to cast object of type 'System.String' to type 'NuGet.Frameworks.NuGetFramework' you are probably trying to create a nuget package by using nuget pack on a .NET Core project.

For .Net Core projects please the following command in the folder of your project file:

dotnet pack --include-symbols

Publish the nuget package

Normally I upload nuget package by just using drag&drop on the nuget upload page. This doesn't work with symbol packages, because you have 2 packages in the folder.

To publish symbol and normal package, you must use the nuget cli.

  1. Get and set your Nuget API key.
  2. Create both (normal + symbol) package. See the 2 possible options above.
  3. Run nuget push {identifier}.nupkg -Source https://www.nuget.org/api/v2/package.
    This will upload the {identifier}.nupkg to nuget and {identifier}.symbols.nupkg to the symbol server.

If the uploads were successful, result should look like this:
27936_symbol_package_upload

Part 2 of this tutorial will show how to use the symbol package to debug trough third party code.

Sources:
https://docs.microsoft.com/en-us/nuget/create-packages/symbol-packages
https://docs.microsoft.com/en-us/nuget/create-packages/publish-a-package


comments powered by Disqus