Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet pack is ignoring assembly info

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?

like image 715
AJ Richardson Avatar asked Jun 29 '15 03:06

AJ Richardson


2 Answers

I think the problem was that I hadn't built my project since modifying the AssemblyInfo. I did a rebuild and it's working now.

(As a side note, I also had the <dependencies> in the wrong section - it should be inside of <metadata> - but that was not causing the error in my question.)

like image 42
AJ Richardson Avatar answered Nov 12 '22 18:11

AJ Richardson


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

like image 175
ne1410s Avatar answered Nov 12 '22 18:11

ne1410s