21

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?

Pang
  • 9,564
  • 146
  • 81
  • 122
AJ Richardson
  • 6,610
  • 1
  • 49
  • 59

3 Answers3

18

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

ne1410s
  • 6,864
  • 6
  • 55
  • 61
  • Your answer drew to my attention a detail that I had forgotten since the last time I built a NuGet package, which was 3 years ago. Since my solution was already built, and I didn't want to create yet another build just for the package, I deduced correctly that I could omit the -Build argment, but that I needed the -Configuration switch. – David A. Gray Apr 30 '19 at 20:17
15

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.)

AJ Richardson
  • 6,610
  • 1
  • 49
  • 59
  • 1
    What was the NuGet version that you were using? I'm having the same problem with NuGet v3.5.0 and a VS2015 project. Its not able to pick up the Author value, even though the project was rebuilt. – EndlessSpace Dec 17 '16 at 21:12
  • @EndlessSpace I can't remember exactly since this was a year and a half ago. It would have been v3.x (maybe 3.0 or 3.1?) – AJ Richardson Dec 18 '16 at 17:40
  • 1
    Also, be sure that you are building in the same configuration as `nuget pack` is using. – AJ Richardson Jan 10 '17 at 20:23
  • 1
    @EndlessSpace Same issue here. It does pick up ID, version and title from the assembly info, but not author or description. – Livven Jan 30 '17 at 14:23
  • 1
    If this answer doesn't work for you, there's a bug report and discussion on Github https://github.com/NuGet/Home/issues/4234 @EndlessSpace – Livven Mar 29 '17 at 17:42
  • @Liven - Doesn't look like it's going to be fixed. – dcp Jul 13 '18 at 12:35
0

Same problem here, but it turns out that someone introduced a signing key, and I was referencing assemblies that didn't have a strong name.

Weird that I didn't get a different error.

rugg
  • 531
  • 3
  • 9