简体   繁体   中英

Visual studio won't read .pdb from my nupkg

I have generated some nuget packages containing .pdbs with the following:

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

I have verified the .pdbs are within the .nupkg generated in the lib/*/ folder next to the dll's.

However, when I consume these nuget packages in Visual Studio 2017, it only extracts the .dll's and not the .pdb's. Leaving me unable to debug into the package.

What am I doing incorrectly?

Since you can make sure the .nupkg contains the .pdb file. please make sure both the projects are in debug mode.

Consuming a nuget package locally sometimes has some difference from installing it from nuget.org. The .pdb source won't be found in solution. By default, the .pdb will locate under path like : C:\\Users\\xxx\\.nuget\\packages\\PackageName\\xxx .

Update:

  1. If the nuget package project and the project which consumes it is on the same machine. The AllowedOutputExtensionsInPackageBuildOutputFolder property is enough. Since you have source files on same machine, and the debug engine can easily find it so that you can step into it.

  2. But if for a scenario like this: You developed the nuget package. And share it to other team members. To make them can Step into you should embed the xx.cs files into the .nupkg.

Under this circumstances, the AllowedOutputExtensionsInPackageBuildOutputFolder may not work. I can't find a way to embed source files using it. You may need to use a nuget pack command like this issue . Actually, the way Stephan packed the project is correct. I've checked it work and will embed the source files and .dll and .pdb into the .nupkg. Of course, in this way you need to add the path to source files repo by Solution=>Properties=>Debug Source files: 在此输入图像描述

In addition: You can add the nuget pack command in a post-build event , so that every time you build a project successfully, it will package for you.

Also, you can consider source links as source control so that you won't configure the source path by Solution=>properties.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM