-
Notifications
You must be signed in to change notification settings - Fork 265
Description
dotnet restore currently does not have a switch that would restore PDBs published on symbol servers (e.g. via snupkg) to nuget package cache.
There are at least two scenarios for which such feature would be valuable:
- Restoring local packages
Scenario steps:
- Clone repository that has Source Link enabled on one machine, make changes, push the changes to source server, build and pack.
- Copy the resulting packages over to another machine.
- On this machine restore a project that depends on these packages, has local directory as a feed in its nuget.config.
- F5 in VS/VS Code and able to step into the source code of the package.
- Offline development
Scenario steps:
- Clone repository and restore packages.
- Disconnect from the network.
- Build and debug your application and its dependencies.
The above scenarios should work regardless of whether PDBs are included in nupkg or in a separate snupkg.
Blockers
Fixing dotnet/sdk#1458: “New project system doesn't copy PDBs from packages” is a prerequisite for the above scenarios, but it only works if the symbols are in the nupkg. This fix would make sure that when the PDB is in the package cache next to the dll it will get copied to the output directory, where the debugger can find it.
Proposal
Add --symbols:[all|local] switch to dotnet restore with default value being local.
This would turn on symbol restore from local directories (local) and symbol servers (all = local + servers). The list of symbol servers would be listed in nuget.config. By default if nuget.org feed is listed nuget would also include nuget.org symbol server.
When restoring packages from a local feed NuGet would check if there is a snupkg next to each restored nupkg. If so it should restore the package to the same directory it restored the corresponding nupkg (effectively merging the content of both packages). Since snupkg directory layout mirrors the corresponding nupkg the result would the same layout in the nuget cache as it would be if the nupkg contained the PDBs.
When restoring packages from remote feeds and --symbols:all is specified, nuget would pull PDBs from the symbol server. The restore operation would read the debug directory entry of each DLL included in the restored package that doesn't have PDB next to it already and query the configured symbol servers for the corresponding PDB using Simple Symbol Query Protocol. It would then store the PDB next to the dll in the package cache. Again the result would be the same as if the package contained the PDB.
Fetching sources for scenario [2] (outside of nuget scope)
Symbols are required for debugging dependencies but not sufficient. To get the scenario [2] working end-to-end another tool would be needed that would fetch the sources from the repository the package was built from (this information is available in nuspec repository metadata) and store them locally. In addition, the debugger would need to be able to redirect Source Link links to the local clone. The debugger does not have such capability today. Perhaps this could be implemented by running a local HTTP proxy.
Further possible improvements (lower priority)
Some scenarios, like crash dump debugging require PDBs to be present in the local symbol cache. The debuggers are not aware of NuGet cache and thus having PDBs only in the nuget cache isn't sufficient. It would however be possible for dotnet restore --symbols to also link the downloaded PDBs to debugger cache to make this scenario work. If an additional argument is passed, say dotnet restore --symbols --debug-cache <path> restore would link the downloaded PDBs to the specified debugger cache directory.