1

I have a project (SDK style) with several target frameworks:

<PropertyGroup>
    <TargetFrameworks>net48;netcoreapp3.1;net5.0-windows;net6.0-windows</TargetFrameworks>
</PropertyGroup>

When I build it, a pdb file is generated for each target framework. I want to include these pdb files in the nuget next to their corresponding dll (so, in \lib\targetFramework\).

I am able to do it for one specific framework:

<ItemGroup>
    <Content Include="bin\$(Configuration)\net48\*.pdb" Pack="true" PackagePath="lib\net48" />
</ItemGroup>

How can I specify this for all TargetFrameworks without hard-coding?


I can do it generically if I have the collection of all TargetFrameworks transformed in a certain way:

<ItemGroup>
  <!-- hard-coded collection -->
  <PDBFile Include="bin\$(Configuration)\net48\$(AssemblyName).pdb">
    <NugetFramework>net48</NugetFramework>
  </PDBFile>
  <PDBFile Include="bin\$(Configuration)\netcoreapp3.1\$(AssemblyName).pdb">
    <NugetFramework>netcoreapp3.1</NugetFramework>
  </PDBFile>
  <PDBFile Include="bin\$(Configuration)\net5.0-windows\$(AssemblyName).pdb">
    <NugetFramework>net5.0-windows7.0</NugetFramework>
  </PDBFile>
  <PDBFile Include="bin\$(Configuration)\net6.0-windows\$(AssemblyName).pdb">
    <NugetFramework>net6.0-windows7.0</NugetFramework>
  </PDBFile>

  <!-- generic usage of the collection -->
  <Content Include="@(PDBFile)" Pack="true" PackagePath="lib\%(NugetFramework)"/>
</ItemGroup>

But I still don't know how to define the PDBFile collection in a less hard-coded way...

Kjara
  • 2,504
  • 15
  • 42
  • 1
    Are you specifically asking about including the pdb or arbitrary files in general? For PDBs there already is a question https://stackoverflow.com/questions/41713693/include-pdb-files-into-my-nuget-nupkg-files – Martin Ullrich Feb 18 '22 at 16:26
  • @MartinUllrich Both. I'll try the approach you linked, but I might need to copy arbitrary files at some point. One goal of my question is to learn more about the MSbuild language. – Kjara Feb 18 '22 at 20:14

0 Answers0