Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include a referenced assembly in a package?

I have a project (A.csproj) which references an assembly (B.DLL) that is not part of the .NET framework.

Packing the project with nuget pack a.csproj effectively builds the package but when testing the package it doesn't contain the B.DLL and obviously it is not added as a reference.

I've tried to use nuget spec but nothing related to that reference could be found in the generated nuspec file.

I've also tried to use the Create New NuGet Package From Project After Each Build 1.7.3 package but it didn't help.

What are the steps needed for including and referencing an assembly in a NuGet package ?

like image 798
aybe Avatar asked Dec 17 '25 15:12

aybe


2 Answers

if you need fine-grained control over the layout and content of your NuGet package, then you should create a nuspec file and use that to create the package. Then you can add files with the following syntax, for example:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
   <metadata schemaVersion="2">
     ...
   </metadata>
   <files>
     <file src="Foo.dll" target="lib\net45" />
     ...
   </files>
</package>
like image 70
Martin Costello Avatar answered Dec 19 '25 13:12

Martin Costello


Have you tried using the -IncludeReferencedProjects attribute with your nuget pack statement?

like image 28
techcase Avatar answered Dec 19 '25 11:12

techcase



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!