I need to embed specific dll in my nuget package. I know how to do it when my project targets only one framework, but i can't make it work when my project targets 2 frameworks.I'm using dotnet pack
to create my package.
Here is a minimal reproducing case:
First
<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFramework>netstandard2.0</TargetFramework></PropertyGroup><ItemGroup><Content Include="C:\Data\file.dll" ><PackagePath>lib\$(TargetFramework)\</PackagePath><Pack>true</Pack></Content></ItemGroup></Project>
With this simple project, all is working as expected, i can embed a file.
Second
<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks></PropertyGroup><ItemGroup><Content Include="C:\Data\file.dll" ><PackagePath>lib\$(TargetFramework)\</PackagePath><Pack>true</Pack></Content></ItemGroup></Project>
Here, i'm trying to target 2 frameworks, you can see that the file.dll is copied, but in a empty folder.
Third
Finally, my last try end up with none files copied anywhere.
<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks></PropertyGroup><ItemGroup Condition="'$(TargetFramework)' == 'net6.0'"><Content Include="C:\Data\file.dll" ><PackagePath>lib\net6.0\</PackagePath><Pack>true</Pack></Content></ItemGroup><ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'"><Content Include="C:\Data\file.dll" ><PackagePath>lib\netstandard2.0\</PackagePath><Pack>true</Pack></Content></ItemGroup></Project>
If anyone can help me to embed the dll file in the specified targed folder, i would be grateful.
Thank you.