NuGet version: 4.5.1.4879
When using "project-driven" NuGet package building (i.e., passing the .csproj file to the nuget pack
command), I thought I understood how NuGet will determine the version to use in the generated package. Specifically, that it will use AssemblyInformationalVersion
if it exists in the AssemblyInfo, or AssemblyVersion
if AssemblyInformationalVersion
is not present.
That seems to work as expected in some of my assemblies (I have a simple 1:1 relationship between assemblies and packages - 1 assembly produces 1 package of the same name), but not in others.
In a problematic assembly, the AssemblyInfo includes this:
[assembly: AssemblyVersion("2.0.0.0")][assembly: AssemblyFileVersion("2.0.0.0")][assembly: AssemblyInformationalVersion("2.0.0")]
In the .csproj file I also have this, among other stuff (note the <Version>
tag):
<PropertyGroup><Configuration Condition=" '$(Configuration)' == ''">Debug</Configuration><Platform Condition=" '$(Platform)' == ''">AnyCPU</Platform><ProjectGuid>{E233E8E2-EB9E-461F-80C2-63F9AFCC425D}</ProjectGuid><OutputType>Library</OutputType><AppDesignerFolder>Properties</AppDesignerFolder><RootNamespace>XYZ.Core.Messaging</RootNamespace><AssemblyName>XYZ.Core.Messaging</AssemblyName><TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion><FileAlignment>512</FileAlignment><Version>2.0.0</Version><NuGetPackageImportStamp></NuGetPackageImportStamp><TargetFrameworkProfile /></PropertyGroup>
BTW, I have no .nuspec file.
Despite those settings, when I try to build the package, using this command:
nuget pack XYZ.Core.Messaging.csproj -OutputDirectory "c:\build\nuget-local" -Suffix "local"
It builds the package as XYZ.Core.Messaging.1.0.0-local.nupkg
.
For some other packages I build with a similar command (just a different .csproj file), with the same AssemblyInfo contents, those build the package with version 2.0.0 correctly.
So where could NuGet be getting the 1.0.0 version from?