1

Closed

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

description

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

<version>$version$</version>

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("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.0")]
Closed Mar 14 at 10:08 PM by RanjiniM

comments

pranavkm wrote Dec 14, 2011 at 5: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 1: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 7: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 6: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:
<files>
<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" />
</files>

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("1.0.0.0")]

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

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.1.0.0.0.nupkg'.

The NuGet package has version number 1.0.0.0, but the DLLs in the package are 1.2.1.0. 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 5:50 AM

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

andyn3 wrote Dec 23, 2011 at 5: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 1.2.0.0, then a Release build 1.3.0.0, and do the nuget pack as part of the release post build, it will mark it version 1.2.0.0 (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.