Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

Include file in nuget, when multitargeting frameworks

$
0
0

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.

enter image description here

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.

enter image description here

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>

enter image description here

If anyone can help me to embed the dll file in the specified targed folder, i would be grateful.

Thank you.


Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>