Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet Packing a Nuspec: Value cannot be null or empty string. Parameter name: value

I'm packaging up a bunch of javascript for a website. Here's what my .nuspec looks like.

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
  <metadata>
    <version>$version$</version>
    <authors>Author Person</authors>
    <owners>Company Name</owners>
    <id>PackageNameId</id>
    <title>PackageNameId</title>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Description text stuff</description>
    <copyright>Company Copyright Info</copyright>
  </metadata>
  <files>
    <file src="www\**" target="" />  <!--It just packages everything in the www folder in the same directory as this .nuspec -->
  </files>
</package>

It just packages everything in that www folder. The $version$ token should be getting replaced by the NugetPackage version flag in TFS (what I'm building in).

I don't see anything called value, so I'm really at a loss for why it's throwing an error.

Here's the full error:

Attempting to build package from 'PackageName.nuspec'.

##[error]Value cannot be null or an empty string.

##[error]Parameter name: value
like image 230
user3066571 Avatar asked Nov 20 '17 18:11

user3066571


2 Answers

I suspect you're getting this error running nuget pack on your nuspec file instead of your csproj file.

As I learned from this open NuGet issue, AssemblyInfo token replacement (e.g. <version>$version$</version>) only works if you're calling nuget pack on your .csproj or .vbproj file. Quoting from NuGet documentation:

Using the project file directly is necessary for token replacement because the project is the source of the token values. Token replacement does not happen if you use nuget pack with a .nuspec file.

like image 97
tessafyi Avatar answered Jan 27 '23 07:01

tessafyi


I took an existing package that I am using and removed the version (e.g. <version></version>). The error I got when I tried to run nuget pack mypackage.nuspec:

Attempting to build package from 'mypackage.nuspec'.
Value cannot be null or an empty string.
Parameter name: value

There are 4 required values for a nuspec file:

  • Id
  • Version
  • Authors
  • Description

Since you are getting this error, I would guess that whatever your $version$ token is not being passed appropriately or used correctly.

like image 37
techvice Avatar answered Jan 27 '23 07:01

techvice