question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Creating a package with .snupkg symbols fails with error NU5005

See original GitHub issue

Repro steps

  1. Create the following project:
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <IncludeSymbols>true</IncludeSymbols>
    <SymbolPackageFormat>snupkg</SymbolPackageFormat>
  </PropertyGroup>
  <Import Project=".paket\Paket.Restore.targets" />
</Project>
  1. paket convert-from-nuget.

  2. dotnet pack

Expected behavior

A .snupkg file would be created alongside with its main .nupkg package file.

Actual behavior

C:\Users\teots\code\paket-bug\.paket\Paket.Restore.targets(304,5): error NU5005: Failed to build package. Ensure 'C:\Users\teots\code\paket-bug\obj\Debug\paket-bug.1.0.0.nuspec' includes source and symbol files. For help on building symbols package, visit https://docs.nuget.org/. [C:\Users\teots\code\paket-bug\paket-bug.csproj]

Additional information

I saw a paket-bug.1.0.0.symbols.nuspec file inside obj/Debug. Was Paket trying to create a legacy .symbols.nupkg file? Maybe my previous fix in #3636 was not enough.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

9reactions
atlemanncommented, Dec 14, 2020

After some trial and error I found out how to make separate .nupkg and .snypkg packages with Paket.

According to the .NET docks, to create a separate symbols package, add the following to the project file:

<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>

But when doing dotnet pack I get the following error:

/home/atle/src/MyNuget/.paket/Paket.Restore.targets(317,5): error NU5005: Failed to build package. Ensure '/home/atle/src/MyNuget/src/MyFsNuget/obj/Debug/MyFsNuget.1.0.0.nuspec' includes source and symbol files. For help on building symbols package, visit https://docs.nuget.org/. [/home/atle/src/MyNuget/src/MyFsNuget/MyFsNuget.fsproj]

In order to make a .nupkg with a separate .snupkg for SourceLink, the .nuspec file should contain paths to both *.dll and *.pdb (and *.xml if you want docs). So if you create a .nuspec file with that you can do

dotnet pack src/MyFsNuget/ -p:NuspecFile=../../MyFsNuget.1.0.0.nuspec -o nuget

and both packages will be created. However, to avoid manually creating the .nuspec file, just add the following line to the project to add the .pdb files to the .nuspec created by dotnet.

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

Now when you do:

dotnet pack path/to/MyProject

you can see the .pdb files being added to the path/to/MyProject/obj/Debug/MyProject.x.y.z.nuspec file and two separate packages will be built.

Note that the two separate packages will only be built if you have the

<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>

options. If not, the .pdb files will be added to the .nupgk package.

So this is an examlpe Directory.Build.props which enables this:

<Project>
  <PropertyGroup>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>

    <Description>Testing symbols</Description>
    <RepositoryUrl>https://github.com/atlemann/MyNuget</RepositoryUrl>
    <RepositoryType>git</RepositoryType>

    <PublishRepositoryUrl>true</PublishRepositoryUrl>

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

    <IncludeSymbols>true</IncludeSymbols>
    <SymbolPackageFormat>snupkg</SymbolPackageFormat>
  </PropertyGroup>
</Project>
0reactions
kropptcommented, Jan 26, 2021

This workaround will not work for .NET Framework projects, because dotnet pack doesn’t work, at least as far as I can tell.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NuGet Error NU5005
Solution. When building a symbols package, ensure that the folder containing the nuspec file contains assembly files for which the symbols need ...
Read more >
Creating symbol packages (.snupkg) - NuGet
How to create NuGet symbol packages (snupkg). ... If a package fails a validation check, its package details page will display an error...
Read more >
c# - How to package and deploy a NuGet ...
I have created a very simple NuGet package from a .net framework visual studio Class Library project, where the class library source is...
Read more >
Exclude authors from valid metadata check when ...
Error NU5005 : Failed to build package. Ensure '/Users/rad/projects/temp/nuget/hello2/Package.nuspec' includes source and symbol files. For help on building ...
Read more >
Untitled
Author ruban abrasif Creating a package with .snupkg symbols fails with error NU5005 … WebJul 19, 2022 · Nuget.Core 1.0.1120.104 MyNuGet NuGet.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found