BendEg BendEg - 1 year ago 143
C# Question

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 >
</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
instead of
. This makes a problem when installing the assembly using nuget, because visual studio is searching in
for the assembly, but it is stored in

Is this a known issue?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download