- I have a project A that produces a nuget N.
- I have a project B that uses N.
- I have a debug configuration for B, i.e. I can step through the code of B.
I also want to step through the code of A during debugging B, but it does not work just like this.
Since I build N from A myself, I can generate a symbols
package and/or a pdb
file, so I think I do have all that is needed. I just don't know how I can connect these pieces to allow me debugging the A-code from within the B-debugging-session.
CodePudding user response:
Did you check this?
https://github.com/dotnet/sourcelink#githubcom-and-github-enterprise
You need to add this in your csproj file.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<!-- Optional: Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<!-- Optional: Embed source files that are not tracked by the source control manager in the PDB -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<!-- Optional: Build symbol package (.snupkg) to distribute the PDB containing Source Link -->
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<!-- Add PackageReference specific for your source control provider (see below) -->
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
</ItemGroup>
</Project>
CodePudding user response:
Setting <DebugType>portable</DebugType>
in my csproj
files (both for A and B) did the trick.
I did not even need to copy the pdb
file from A anywhere; it just worked on its own.
Might be that this is just due to my current setup: I have a nuget.config
for project B where the path to project A is specified, because the nuget N is built there. And since it is project A's folder, its pdb
is in there as well (in bin/Debug/frameworkVersion). Might be that VScode just checks the folder from where the nuget was retrieved, as well as all subfolders.
Anyway, if that won't work for a different setup, it seems it is enough to just copy the pdb
of the code I want to debug (so, of project A's code) into the output folder of the project I'm currently debugging (project B). This can be achieved automatically by adding the pdb
to the nuget as well as a corresponding target
to copy the pdb
to the output directory.