I have a .nuspec file for my project, which references a third-party DLL that the project including my package needs to reference.
<?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>Locked against log4net 1.2 - less than 1.2.11 which has breaking changes</releaseNotes>
<copyright>Copyright 2012 blah blah</copyright>
<dependencies>
<dependency id="log4net" version="[1.2,1.2.11)" />
<dependency id="My.Other.Project" />
</dependencies>
<references>
<reference file="Third.Party.dll" />
</references>
If I try to run nuget.exe pack My.Project.csproj from the directory with the .csproj and the .nuspec file, I get
Invalid assembly reference 'Third.Party.dll'. Ensure that a file named 'Third.Party.dll' exists in the lib directory.
I have created .\lib .\bin\Debug\lib .\obj\lib
and the file is in all three places. Where does it REALLY want the lib folder?
The <references> element defines the references that will be added to the project when your package is installed. What you are missing is the part that defines the files that are part of your package which is done with the <files> element. So your .nuspec file should look something like the following:
<?xml version="1.0"?>
<package>
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>Locked against log4net 1.2 - less than 1.2.11 which has breaking changes</releaseNotes>
<copyright>Copyright 2012 blah blah</copyright>
<dependencies>
<dependency id="log4net" version="[1.2,1.2.11)" />
<dependency id="My.Other.Project" />
</dependencies>
<references>
<reference file="Third.Party.dll" />
</references>
</metadata>
<files>
<file src="lib\Third.Party.dll" target="lib"/>
</files>
</package>
The only difference is the files element after the metadata element.