Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I've following structure for a .NET Framework project:
-->ProjectSoln
-------->ClassLibraryProj1
-------->ClassLibraryProj2
-------->ConsumerLibraryProj3

ConsumerLibraryProj3 has project reference to ClassLibraryProj1 and ClassLibraryProj2.
When I'm trying to generate Nuget Package for the ConsumerLibraryProj3, the package doesn't include dependent dll's (ClassLibraryProj1 & ClassLibraryProj2). It doesn't include any of the dll's that are referenced by ClassLibraryProj1 and ClassLibraryProj2.

I tried to add the following for both the above two projects
<referenceoutputassembly>true
<includeassets>ClassLibraryProj1.dll
to ConsumerLibraryProj3.proj file. But this doesn't work in my case. The Nuget package contains only ConsumerLibraryProj3.dll.
I verified the above settings for a .NET Standard project and it works. But for .NET Framework type project I'm unable to get it done. Any help will be appreciated.
Thanks!

What I have tried:

I tried to add
the following for both the above two projects
<referenceoutputassembly>true
<includeassets>ClassLibraryProj1.dll
to ConsumerLibraryProj3.proj file. But this doesn't work in my case.
Posted
Updated 11-Feb-21 19:42pm
v3

1 solution

If NuGet fails to see the dependencies, you can override the behavior by changing the .nuspec file.
Below information is taken from: .nuspec File Reference for NuGet | Microsoft Docs[^]
Quote:
To bypass this automatic behavior and explicitly control which files are included in a package, place a <files> element as a child of <package> (and a sibling of <metadata>), identifying each file with a separate <file> element.
Example:
<files>
    <file src="bin\Debug\*.dll" target="lib" />
    <file src="bin\Debug\*.pdb" target="lib" />
    <file src="tools\**\*.*" exclude="**\*.log" />
</files>


I used this to create a NuGet package with both x86 and x64 dll's:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
    <metadata>
        <id>BuildXXXXX</id>
        <version>1.0.0</version>
        <authors>XXXXX</authors>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>XXXXX 32 amd 64 bits</description>
    </metadata>
    <files>
        <file src="x64\Release\xxxxx.dll" target="lib/net47/x64" />
        <file src="x64\Release\xxxxx.pdb" target="lib/net47/x64" />
        <file src="x86\Release\xxxxx.dll" target="lib/net47/x86" />
        <file src="x86\Release\xxxxx.pdb" target="lib/net47/x86" />
    </files>
</package>
 
Share this answer
 
v2
Comments
Maciej Los 12-Feb-21 6:32am    
5ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900