1

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?

1 Answer 1

1

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

4
  • Why does nuget replace it in $id$ and not in $version$?
    – BendEg
    Nov 28, 2016 at 17:52
  • Sorry, it is a mistake, is $version$ not $id$
    – SERWare
    Nov 28, 2016 at 17:54
  • Ok, creating the package seems to work, but why does msbuild tries to find the assembly under .6.0.0.0\lib\net451` and not under .6.0.0\lib\net451`? I'm restoring it using nuget restore ...sln. Thanks a lot :)
    – BendEg
    Nov 28, 2016 at 17:56
  • 1
    NET and Msbuild uses AssemblyVersion attribute to link assemblies. AssemblyFileVersion is just for informational purposes about your builds and if you use AssemblyInformationalVersion for NuGet semantic versions, you should keep the same AssemblyVersion attribute "6.0.0.0" while there are not breaking changes in your lib API and change only AssemblyInformationalVersion minor and build numbers. I'll elaborate it a little in my answer, For now you can read the "real solution" paragraph in the article I have referenced.
    – SERWare
    Nov 29, 2016 at 8:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.