1

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.Core\bin\Release\*.dll" target="lib\netcoreapp2.1" />
    <file src="..\Utils.Web.Fx\bin\Release\*.dll" target="lib\net461" />
</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

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="bin\Debug\netcoreapp2\Utils.Web.Core.dll" target="lib" />
    <file src="bin\Debug\net461\Utils.Web.Fx.dll" target="lib" />
    <file src="bin\Debug\Utils.Web.dll" target="lib" />
  </files>
</package>

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.