Home: Generate NuGet package on build does not use the correct package version

Created on 21 Nov 2018  路  10Comments  路  Source: NuGet/Home

Details about Problem

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): VS UI

NuGet version (4.9.0):
dotnet.exe --version: 2.1.4
VS version: 2017.9.2

Worked before? If so, with which NuGet version: No

Detailed repro steps so we can see the same problem

  1. Clone: https://github.com/jbe2277/waf/tree/6a973162d5256afc908e0c36b8d24ec2ffdd7e55 (Commit: 6a973162d5256afc908e0c36b8d24ec2ffdd7e55)
  2. Build in Release configuration
  3. All .nupkg are created with Version 1.0.0 (Packages are generated on build)

Expected:
They should be created with Package Version 5.0.0-alpha1. Visual Studio shows this version in the "Package" UI. See System.Waf.Core project.

Note:
The package version is defined by the AssemblyInformationVersionAttribute instead of the PackageVersion MSBuild property.

Pack VisualStudioUI Project-System 2 BlockedByExternal External

Most helpful comment

quick solution here. just right click on your project file and edit it. there 2 versions
<PackageVersion>1.0.1</PackageVersion>

and
<Version>1.0.1</Version>

Looks like PackageVersion is used to generate nuget version but VS settings are updating Version tag. I have no idea what is it for. It still an issue with VS and please move it to VS issues.

All 10 comments

The package version is not generated with the AssemblyInformationVersionAttribute property.

If you look at the targets here, there's no mention of it
https://github.com/NuGet/NuGet.Client/blob/release-4.9.1-rtm/src/NuGet.Core/NuGet.Build.Tasks.Pack/NuGet.Build.Tasks.Pack.targets

You need to use PackageVersion.

It is inconsistent with

  1. NuGet.exe CLI supports the AssemblyInformationVersionAttribute.
  2. The Visual Studio 2017.9 UI shows the correct version number (see image below) but it generates a .nupkg with Version 1.0.0

nuget-pack-version-issue

Same issue with Package Description and the AssemblyDescriptionAttribute.

@jbe2277
That looks like an issue in the UI, which is not handled directly by NuGet.
The expectation by pack is that the PackageVersion/Version are used.

Please refer to https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets for more details.

In the meantime, consider using PackageVersion and Description in some of the directory.build.props through your project.
//cc @NuGet/nuget-client @cartermp

Did you find a solution for that? i think that you should move your issue to Visual Studio github repository issues. it is not probably related to Nuget but more Visual Studio and msbuild

quick solution here. just right click on your project file and edit it. there 2 versions
<PackageVersion>1.0.1</PackageVersion>

and
<Version>1.0.1</Version>

Looks like PackageVersion is used to generate nuget version but VS settings are updating Version tag. I have no idea what is it for. It still an issue with VS and please move it to VS issues.

I discovered this bug (and the "edit the csproj file manually" workaround) a while back. I agree that it's a VS UI issue. So if this GH issue tracker isn't responsible for the UI, then have we raised this in the VS Issue Tracker?

Thanks for tagging @nkolev92 - this should go under https://github.com/dotnet/project-system

I don't have permissions to move the issue though

I've raised an Issue over on project system:
https://github.com/dotnet/project-system/issues/5678

Wehn I tested this in detail. I found that the Pack-on-build functionality, does use the <Version> tag ... but only if the <PackageVersion> tag is entirely absent.
If they're both present then it uses \, and ignores \.

So if you create a blank project, and never manually edit the .csproj, it should all work I think.

Not sure how my projects came to have a \ ... possibly and earlier version of the Packer _didn't_ use \? So I had to add \ by hand? Which then "breaks" the UI.

So I suppose that they could argue that the UI is doing what it's supposed to, and that the Packer is bugged (in that \ shouldn't exist and it's a bug that the Packer is paying any attention to it.)?

Thanks @cartermp and @Brondahl

Closing this as external.

Was this page helpful?
0 / 5 - 0 ratings