Reputation: 531
I'm trying to pack a new version of a custom NuGet package and when I use the pack
command I'm getting a .nupkg
file which has a version number that doesn't match with the one that I've specified in the .nuspec file
.
Example:
nuget pack mypackage.csproj -IncludeReferencedProjects -Prop Configuration=Release
.nuspec
file:
<?xml version="1.0"?>
<package >
<metadata>
<id>mypackage</id>
<version>1.0.1</version>
<authors>me</authors>
<owners>me</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>blah</description>
<releaseNotes></releaseNotes>
<copyright>Copyright 2016</copyright>
<tags>tag1 tag2</tags>
<dependencies>
</dependencies>
</metadata>
</package>
I should get a file named mypackage.1.0.1.nupkg
, but I'm getting a file named mypackage.1.0.0.nupkg
instead
I'm also getting the same result when I try to pack it by using the AssemblyInfo
data included in the Properties\AssemblyInfo.cs
and declaring the version as a variable in the .nuspec
file:
Properties\AssemblyInfo.cs ... [assembly: AssemblyVersion("1.0.1")] ...
Should I look for another properties in my project to update my NuGet package?
SOLUTION: Ignored the .nuspec file and managed the package versions via .csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net451;net452</TargetFrameworks>
...
<AssemblyVersion>1.2.1</AssemblyVersion>
</Project>
Thanks in advance!
Upvotes: 3
Views: 4558
Reputation: 226
I often forget to build my project so it doesn't update the version.
Upvotes: 1
Reputation: 531
Well, I've finally managed to update my version by packing using the AssemblyInfo
version. It seems like my publishing process for this package is completely ignoring the .nuspec file and gets the version from the last compiled source.
Upvotes: -1
Reputation: 8642
I fell foul of this recent as well. You need to use the Properties\AssemblyFileVersion attribute to set the correct value for a nuget package
[assembly: AssemblyFileVersion("1.0.1")]
Upvotes: -1