-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve NuGet package debugging and symbols experience #6104
Comments
Would love to see this! Have had an offline discussion with some other folks, and came up with a dream workflow: The main issue today is that when running “nuget.exe pack -Symbols” on a .NET Standard project, SourceLink is not enabled by default. Which makes a LOT of sense as not everyone is keen on sharing their sources. However: when people do want to have sources support, it’s usually too late and discovered during a debugging/profiling/dump analysis situation where symbols and sources would have been handy… Going out on a limb, perhaps the ideal workflow would be something like this (trying to shape a flow and feature): Package creation/publishing phase
Symbols consumption phase (user wants to fetch symbols and sources)
That seems, for Portable PDB, to give the entire spectrum of embedded + sourcelink, to sourcelink with url mappings, to no sourcelink at all but still have debuggability. |
The way you envision this working, where would the source be uploaded to support these scenarios? It seems like the package author has not uploaded the source in this case? |
That comes from the creation phase:
This is essentially the current NuGet behavior, where the generated package contains sources and a sourcelink file that holds a placeholder URL. That way, a server can serve up symbols based on the embedded sources. Imagine the following scenario that you can do today:
Another option is embedding the sources in the Portable PDB, which would be awesome, except for one thing: there is no user control possible. E.g. if I am a tools vendor and I want only my team to have debugging possibilities and not my clients, how do I prevent one group from using the symbols embedded in the Portabe PDB? For this scenario, having to reach out to the server will make it possible to limit access to PDB and source files. |
@maartenba We are working on making it super easy to enable source link in builds for both public and private repos, as well as embed sources to PDBs that not tracked by a source control server (e.g. sources generated during the build). Our goal is to reduce the number of packages that were not built with source link or embedded sources. That said, we understand that there will be cases where it will be necessary to add sources after the fact. The scenario is valid and we have some ideas how to address it in future. I don't think NuGet is the right tool to implement this support though (by creating source link files or recompiling PDBs). |
I would say we should opt in to publish the symbols and by default only the .nupkg is pushed not the .symbols.nupkg. We are already taking the change to not auto-push package. (See #6113). Lets not randomize :) |
Draft of the spec is now available here: https://github.com/NuGet/Home/wiki/NuGet-Package-Debugging-&-Symbols-Improvements Please let us know any feedback you have in this thread! |
Questions from reading the draft spec:
Requiring 4.7.1 is way too soon for us, and also we'd like to continue using our existing native PDBs as well.
|
Great write-up @diverdan92. Thanks for sharing the plan. I'm trying to better understand the advantages of using a symbol server instead of just including the .pdb files in a normal .nupkg.
So you can't do crash dump debugging or attach to an application with just .pdb files on the filesystem distributed via the normal .nupkg??? |
I had a similar thought- all that complication to save a bit of disk space? Hey, if you're willing to do that, and keep it simple for both authors and consumers, more power to you! |
My PDBs are over 500mb each, and there's 3 CPU architectures, meaning over 1.5gb of PDBs uncompressed! (about 400mb compressed in the nupkg) Currently there's a 250mb limit on nuget.org. |
Excellent questions!
@ctaggart - Great feedback. The issue is trying to debug a crash dump for a .dll you don't necessarily have restored/installed. If it's hosted on a Symbol server and you have it correctly configured, the tooling will automatic fetch the symbols to get meaningful debugging information. If you have everything installed and can locate the Symbols for the debugger, you can still get this to work including the Symbols as a part of the package, it's just not as ideal as it could be. One of the open issues we need to close on is "How do we support preemptively caching symbols for offline scenarios". We do recognize a need for preemptive caching and are looking at the best ways to solve this. Any suggestions? |
@diverdan92, so if you include the .pdb files in the regular .nupkg, are there debugging scenarios that do not work? Wouldn't eliminating the need for Symbol Servers for a large portion of debugging scenarios simplify things for those scenarios? Why not make adding .pdb files to the regular .nupkg the default? |
@ctaggart we don't want to bloat the entire NuGet ecosystem unnecessarily. It impacts nearly everything - from Visual Studio install time, project creation time (for most projects), restore times, and more. We also have evidence that a majority of users won't debug into third party components, so promoting a model where the .pdbs are included in the .nupkg by default, we impact the performance for everyone to support a scenario for more advanced users. |
@diverdan92 As a compromise, can you support a scenario to restore the symbols upfront at the same time that we restore the packages? A |
@ctaggart I was proposing a setting in the nuget.config file for this. I also suggest having the symbol sever endpoint being part of the v3 protocol spec, being part of the feed info itself. Then each NuGet client can discover the symbol server endpoint info. You could enable the per-feed symbols with an on/off setting on the nuget.config feed item element easily then. So you may want symbols from your myget feeds, but not nuget.org. And you'd have a setting in the nuget.config file to pull them on restore as well that's repo-wide. That way you can have a consistent team experience. |
@ctaggart that's where the option issue came from 😊. We will do something for this scenario to support the ability to download symbols upfront. The exact mechanism is TBD. |
I see this is labelled |
Still to be determined. There are several moving pieces (compiler work to embed hashes of .pdbs in .dlls, client changes, spinning up the service, etc...). I would expect it after 15.7, but we may be able to start lighting up certain scenarios between 15.7 and whatever is next. Can't make any promises just yet. |
Yes. The implementation we are working on will support git submodules if that's what you mean by multiple repos. You can even have one dll built from multiple submodules. It will also support sources included from NuGet source packages.
The build task will automatically determine the commit sha from the repository using Git API (or changeset number for TFVC repositories). No need to specify anything. I have done some prototyping of integrating source control features to build. |
@diverdan92 - nuget client has finished the work for 15.9 related to this. trying to clean up this milestone. can we close this issue, or move to future milestone, or other? |
@rrelyea - we should wait until the e2e scenario ships to close the issue. |
I'm new to this proposal, just read on it on the blog. The thing I don't get: what's wrong with adding the PDBs to the original NuGet package? We've done that for years and haven't got any problems with it. Is this discouraged now? |
You're bloating the package for no reason. Also forcing a larger deployment on others who might not care about 3rd party symbols but are only interested in symbols for their own code. |
How do snupkg files relate to package signing? If the main package is signed then should both be signed? Also should this guidance be changed - https://docs.microsoft.com/en-us/dotnet/standard/library-guidance/nuget#symbol-packages Is there any reason to still have PDB files in the main package? |
IMO, PDB's should be in the main package, always. It's much faster to have the pdb's around instead of downloading on-demand. Also, some things like .NET Native need the symbols to be on disk in advance in order to munge the PDB's to match the native output. Symbol server does not work for that scenario. I believe snupkg should only be used for full pdb's, which are bigger, but that's the one type of symbol they don't support. PPDB's are small. Better yet, use embedded as the symbol type and it'll be compressed and put directly in the DLL. No extra symbols to keep track of! :) |
Interesting. I'm going to create a PR in the library guidance. I'll advertise it and see what direction the discussion and consensus goes. |
@JamesNK Can you please post the issue link here when you do? |
Shipped. Closing |
Hi All,
When I try to debug it is asking me for cs file. My understanding of nuget debugging: Any help? |
If it's asking for a source file that means the debugger was able to fetch the PDB from the symbol server. You should be able to confirm that by opening the Modules window (Debug > Windows > Modules) and find the line that corresponds to the library. The PDB does not contain sources by default. There are a few options how to make sources available. In general, we recommend using SourceLink package to link the PDB to the repo. |
Source link is not an option for us. We need to include source files or embed source files into PDB. With new framework first option is not possible. So, embedding source files into PDB is only option for us. I tried below code change:
With this change, I could publish snupkg to nuget, at the time of debug, pdb downloaded to my local symbols folder, but I hit with .cs file not found error I am facing the same issue as this Any help to overcome this issue? |
@chilakamarthi I'd put those properties in an unconditional property group so that e.g. a release build stays consistent with the debug build settings you've shown above. Which version of Roslyn is your build server using? The Embedded source can only be consumed by users with VS2017 Update 5 or newer. |
Right now I am testing it on my dev machine which got Ver 15.9.5 |
I included below two in .csproj, but still don't see cs files in PDB
I read here Source Linking with NuGet Packages
Second point I am looking for and I am not able to create snupkg which includes source code... |
@chilakamarthi I'd first load the DLL up in dotPeek or similar to find out if the PDB is being correctly created. You should look for > Metadata > Portable PDB Metadata > CustomDebugInformation entries with a Kind of EmbeddedSource. If the PDB appears to not have any EmbeddedSource entries, the problem is with the build setup and I'd use http://msbuildlog.com and search the build log for |
I tried what you suggested and it looks normal. Here is the screenshot: And dotpeek shows below log:
|
@chilakamarthi BTW, the package reference |
@chilakamarthi If 'Enable just my code' is checked, it means you don't want to debug into any code outside the current solution. Typically you want to only turn it off briefly. I've found this to be very handy: https://marketplace.visualstudio.com/items?itemName=SamHarwell.JustMyCodeToggle You get a toolbar item and can set a keyboard shortcut. |
Does it work in Visual Studio Code? |
It works finally..
On Oct 25, 2019 1:31 PM, Kerry Jiang <notifications@github.com> wrote:
Does it work in Visual Studio Code?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#6104?email_source=notifications&email_token=AGVIXYRMY2FQ3KM5LSOXBB3QQKRW3A5CNFSM4EA3DIV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECHRKBQ#issuecomment-546247942>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGVIXYVY2ACJQYPPTLTP6MTQQKRW3ANCNFSM4EA3DIVQ>.
|
Is there any document about how to debug into snupkg with VisualStudioCode? I cannot debug into it. |
Pre requisites:
Put nuget in network path and try on another machine to create new project and add test nuget package and try to debug. You will see source code shown in temp location. |
Currently the NuGet package debugging and symbols experience is not streamlined.
Some areas that need improvement are:
This issue will be used for discussion of the spec here.
The text was updated successfully, but these errors were encountered: