<version>$version$</version> no longer works in nuget 1.6


Having a nuspec file that identifies the version number should come from the assemblyinfo of the project


This is now ignored in version 1.6 of the command line exe.

Nuget.exe pack myproj.csproj -Build -Verbose -OutputDirectory .\bin\ -Properties Configuration=Release

When the nuspec is configured as: <version>$version$</version>

The resulting output is MyProj 1.0

If I manually set the version in the nuspec file it will generate the correct version.

For reference, my assembly info has the following attributes:

[assembly: AssemblyVersion("")]
[assembly: AssemblyInformationalVersion("1.0")]
Closed Mar 14 at 9:08 PM by RanjiniM


pranavkm wrote Dec 14, 2011 at 4:30 PM

Could we get a copy of your project file and nuspec? I can't seem to repro this.

dotnetchris wrote Dec 15, 2011 at 12:54 PM

With further discussion with @pranavkm on Jabbr we concluded that the issue was that the changes about using AssemblyInformationalVersion to be the Nuget $version$ target if it's parsable as a SemVer was never communicated outside of the discussion forums.

pranavkm wrote Dec 15, 2011 at 6:02 PM

@Howard, could we make a note in our docs\release notes that says something to this effect?

andyn3 wrote Dec 16, 2011 at 5:52 AM

I just encountered a similar problem - I can't tell if it's the same problem as @dotnetchris is having, but the symptoms are similar. In my case, I tracked it down to the following. In my .nuspec file, I'm referencing files like:
<file src="bin\Release\MyLib.dll" target="lib\net40" />
<file src="bin\Release\MyLib.pdb" target="lib\net40" />
<file src="bin\Release\MyLib.xml" target="lib\net40" />

However, nuget.exe (1.6) (run in Package Manager Console with VS 2010 in release configuration) seems to be pulling my version info from the AssemblyVersion attribute of bin\Debug\MyLib.dll (which had an old build and therefore old number).

An easy way for me to repro - switch to Debug configuration and edit AssemblyInfo.cs to:
[assembly: AssemblyVersion("")]

Do a rebuild all (debug). Then switch to Release configuration and edit AssemblyInfo.cs to:
[assembly: AssemblyVersion("")]

Do a rebuild all (release). Then, in Package Manager Console, run "nuget pack MyLib\MyLib.csproj". I get the following output:

PM> nuget pack MyLib\MyLib.csproj
Attempting to build package from 'MyLib.csproj'.
Packing files from 'C:\Projects\MyLib\MyLib\bin\Debug'.
Using 'MyLib.nuspec' for metadata.
Successfully created package 'C:\Projects\MyLib\MyLib.'.

The NuGet package has version number, but the DLLs in the package are I think if the assemblies being packaged are coming out of bin\Release, then $version$ should come from assemblies in bin\Release, not bin\Debug

pranavkm wrote Dec 22, 2011 at 4:50 AM

@andyn3, do you have an AssemblyInformationalVersion attribute specified in your assembly?

andyn3 wrote Dec 23, 2011 at 4:58 AM

No, I don't have an AssemblyInformationalVersion attribute set. It's pulling the right version out of the AssemblyVersion attribute, but for the wrong build (e.g., if I do a Debug build, then a Release build, and do the nuget pack as part of the release post build, it will mark it version (from the Debug build), ignoring the newer (and currently active) Release build. I tend to only pack release builds, so the debug build numbers are meaningless and would hopefully be ignored.