NuGet pack is ignoring assembly info

AJ Richardson picture AJ Richardson · Jun 29, 2015 · Viewed 7.3k times · Source

When I run nuget pack MyProject.csproj from the command line, I get the following error:

The replacement token 'author' has no value.

I checked my AssemblyInfo, and the AssemblyCompany is specified as "AJ Richardson". I tried manually replacing $author$ with AJ Richardson in my nuspec file, but then I got a slightly different error:

The replacement token 'description' has no value.

But the AssemblyDescription is also specified. It seems that NuGet is not reading anything from my AssemblyInfo. I have verified that AssemblyInfo is included in my project and the build action is set to Compile.

I have made a couple of NuGet packages before and did not have any issues. The only difference between this package and my previous packages is that this one has dependencies.

For reference, here is my nuspec:

<?xml version="1.0"?>
<package>
  <metadata>
    <id>$id$</id>
    <version>1.0.0</version>
    <title>$title$</title>
    <authors>$author$</authors>
    <owners>$author$</owners>
    <licenseUrl>https://github.com/my/repo/blob/master/LICENSE</licenseUrl>
    <projectUrl>https://github.com/my/repo</projectUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>$description$</description>
    <releaseNotes>Initial release.</releaseNotes>
    <copyright>Copyright AJ Richardson 2015</copyright>
    <tags></tags>
  </metadata>
  <dependencies>
    <dependency id="Newtonsoft.Json" version="6.0.1" />
  </dependencies>
</package>

So my question is, why isn't NuGet reading my AssemblyInfo, and how do I convince it to do that?

Answer

ne1410s picture ne1410s · Jan 24, 2018

I was also experiencing issues in this regard; my updates to AssemblyInfo didn't seem to be being picked up - despite me building and rebuilding, etc.

I was able to resolve the issue by explicitly telling NuGet to build (in my case in Release, with pdb symbols):

nuget pack foo.csproj -Build -Symbols -Properties Configuration=Release