How to create a multi-targeting nuget package from multiple projects

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to create a multi-targeting nuget package from multiple projects



I have a bunch of helper classes for web applications that we want to use across .NET Framework applications, Standard assemblies and .NET Core applications.



I'd like to build these as a Nuget package that can be installed anywhere, and brings across the correct references for the consuming application's target framework.



I've tried the following in the nuspec file:


<files>
<file src="**.dll" target="lib" />
<file src="..Utils.Web.CorebinRelease*.dll" target="libnetcoreapp2.1" />
<file src="..Utils.Web.FxbinRelease*.dll" target="libnet461" />
</files>

<references>
<group targetFramework="netstandard2.0">
<reference file="Utils.Web.dll" />
</group>
<group targetFramework="net461">
<reference file="Utils.Web.Fx.dll" />
<reference file="Utils.Web.dll" />
</group>
<group targetFramework="netcore45">
<reference file="Utils.Web.Core.dll" />
<reference file="Utils.Web.dll" />
</group>-->
</references>



What I think this should do is copy the right dlls to the right target .lib folders and reference those assemblies. However the nupkg at the end does not contain any .lib folder.



Is what I am trying to do possible, and what am I missing?




1 Answer
1



grouping the references can not be intermixed with file list, please look at the schema definition of nuget spec file,



.nuspec reference - Explicit assembly reference



The group format cannot be intermixed with a flat list.



I could be able to create and use nuget pacakge using the below spec,


<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>package_id</id>
<!-- other metadata element -->
<references>
<group targetFramework="net461">
<reference file="Utils.Web.dll" />
<reference file="Utils.Web.Fx.dll" />
</group>
<group targetFramework="netcoreapp2">
<reference file="Utils.Web.dll" />
<reference file="Utils.Web.Core.dll" />
</group>
</references>
</metadata>
<files>
<file src="binDebugnetcoreapp2Utils.Web.Core.dll" target="lib" />
<file src="binDebugnet461Utils.Web.Fx.dll" target="lib" />
<file src="binDebugUtils.Web.dll" target="lib" />
</files>
</package>



consider using either target attribute of file element or **group them explicitly using references **.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard