NuGet add external reference

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="https://stackoverflow.com/questions/8764236/lib\Third.Party.dll" target="lib"/>
  </files>
</package>

The only difference is the files element after the metadata element.

Leave a Comment

tech