BendEg
BendEg

Reputation: 21128

Generating nuget package using .csproj cause wrong version number

Currently I'm creating a nuget package using a *.csproj and a nuspec file. In the nuspec file I'm declaring the assembly/package version like this:

<package >
  <metadata>
    <id>$id$</id>
    <version>$version$</version>
    ...
  </metadata>
</package >

In the assembly the version is declared like this:

[assembly: AssemblyVersion("6.0.0")]
[assembly: AssemblyFileVersion("6.0.0")]

The problem is, that when I create the package using nuget pack xxx.csproj, it creates a package with the version 6.0.0.0 instead of 6.0.0. This makes a problem when installing the assembly using nuget, because visual studio is searching in package/.../6.0.0 for the assembly, but it is stored in packages/.../6.0.0.

Is this a known issue?

Upvotes: 1

Views: 2021

Answers (1)

SERWare
SERWare

Reputation: 392

NuGet uses other attribute to generate the version replaced in $version$:

[assembly: AssemblyInformationalVersion("6.0.0")]

As said in how to version assemblies destined for Nuget NuGet uses this attribute because nothing else seems to care about it :) the AssemblyInformationalVersion attribute is a literal one that can be used for semantic versions

Upvotes: 1

Related Questions