SolvedHome Unhelpful error message when incorrectly using nuspec version tag of nuget pack

I was just trying to use:

nuget pack file.nuspec

I was stuck for a while because of the error message:

Value cannot be null or an empty string. Parameter name: value

Turns out this is because I was using <version>$version$</version> in my nuspec, but not explicitly passing the package version. That makes sense, but I struggled to track this down - would it be possible to improve the error message here, and perhaps at least point the user towards the part of the nuspec file causing the issue.

Thanks!

18 Answers

✔️Accepted Answer

This is definitely an error message which could do with some improvement. It seems there are two problems with the message here.

Firstly it refers to a value parameter being null, which doesn't help with identifying that version is invalid. You basically have to resort to systematically editing/removing/replacing each element until the error goes away, which sucks.

The second is that if you run the pack command against a .nuspec which has replacement tokens in it, it'd be much nicer if there was an early exit with a helpful message letting you know that you should be using it against the corresponding csproj.

Other Answers:

@qwertie AssemblyInfo token replacement only works if you are calling nuget.exe pack and specifying your .csproj/.vbproj file to be packed. This behavior is documented here:

These tokens will only be replaced when you execute the pack command with the project file, and not with the nuspec file. The contents of the nuspec file will be located and honored, with the appropriate token replacements executed.

Almost 2 years later, a simple error message improvement bug is still not fixed!

Is there a workaround for this when building a NuGet package for multiple .NET versions, as @qwertie mentioned?

I'm sorry, what's wrong with using <version>$version$</version>? P.S. I'm having this problem too.

Ping! Geez, does anyone actually work on NuGet anymore?