How to create symbols for multi-project Nuget package?
Asked Answered
D

1

15

So I'm really struggling to figure this out.

I have a solution with a few projects, say, A, B, and C. A references and uses B and C (both project references). I wanted to create a Nuget package from A, and I did so, successfully, although I had to jump a few hoops, using things like this:

<ProjectReference Include="..." PrivateAssets="All" />
...
<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences">
  <ItemGroup>
    <BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference')->WithMetadataValue('PrivateAssets', 'All'))" />
  </ItemGroup>
</Target>

However, I would like to also debug through my Nuget package, so I found a few tricks to do so. One would be to copy the pdb into the nupkg, although that's not recommended. It supposedly works with this line in your csproj file. That adds the pdb to the nupkg, but only A.pdb is added.

Otherwise one could/should create a A.symbols.nupkg file. I tried doing that using tags like DebugSymbols, DebugType, EmbedSources, and IncludeSymbolsInPackage, but to no avail.

I also tried > dotnet pack A.csproj --include-symbols --include-source, and that generates a A.nupkg and a A.symbols.nupkg, but within the symbols, only A.pdb and not B.pdb and C.pdb.

So I guess my question is: How to create a nuget package from a multi-project solution which you can debug into (so including either pdb's or symbols/sources, not one, but from all referenced projects)?

TLDR: I've already seen a lot of potential solutions, but so far, none worked.

Some of my last resorts may be: just adding all contents of B and C to A, so that there's only one project left, or creating a powershell script to manually add all the pdb's in the the A.symbols.nupkg. Of course, I'd like a more straightforward solution, if there is any.

Dragelin answered 25/9, 2018 at 6:55 Comment(4)
What are B and C? Nuget packages, project references or binary referencesMarci
@Marci project referencesDragelin
You could try with Nuget packages (A references B and C as Nuget packages) and generate packages with symbols for A, B and CMarci
What type of project do you have? .NET Core? Which version?Monique
G
1

The steps that should work:

  1. Ensure that the references are indeed project references and not referencing the built DLLs directly.

  2. Ensure that all of the PDBs are being copied to the output folder after building.

  3. Use either of the methods you have tried (symbols package or hardcoding the inclusion of the .pdb extension).

If this is not working as expected, I would recommend providing additional details such as the csproj file for 'A' and any nuspecs tried.

Gnomon answered 3/10, 2018 at 18:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.