Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate NuGet package on build does not use the correct package version #7542

Closed
jbe2277 opened this issue Nov 21, 2018 · 10 comments

Comments

@jbe2277
Copy link

@jbe2277 jbe2277 commented Nov 21, 2018

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.

@nkolev92

This comment has been minimized.

Copy link
Member

@nkolev92 nkolev92 commented Nov 22, 2018

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.

@jbe2277

This comment has been minimized.

Copy link
Author

@jbe2277 jbe2277 commented Nov 22, 2018

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

@jbe2277

This comment has been minimized.

Copy link
Author

@jbe2277 jbe2277 commented Nov 24, 2018

Same issue with Package Description and the AssemblyDescriptionAttribute.

@nkolev92

This comment has been minimized.

Copy link
Member

@nkolev92 nkolev92 commented Nov 26, 2018

@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

@EmilAlipiev

This comment has been minimized.

Copy link

@EmilAlipiev EmilAlipiev commented May 6, 2019

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

@EmilAlipiev

This comment has been minimized.

Copy link

@EmilAlipiev EmilAlipiev commented May 6, 2019

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.

@Brondahl

This comment has been minimized.

Copy link

@Brondahl Brondahl commented Nov 28, 2019

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?

@cartermp

This comment has been minimized.

Copy link

@cartermp cartermp commented Nov 28, 2019

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

I don't have permissions to move the issue though

@Brondahl

This comment has been minimized.

Copy link

@Brondahl Brondahl commented Nov 28, 2019

I've raised an Issue over on project system:
dotnet/project-system#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 <PV>, and ignores <V>.

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 <PV> ... possibly and earlier version of the Packer didn't use <V>? So I had to add <PV> 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 <PV> shouldn't exist and it's a bug that the Packer is paying any attention to it.)?

@nkolev92

This comment has been minimized.

Copy link
Member

@nkolev92 nkolev92 commented Dec 2, 2019

Thanks @cartermp and @Brondahl

Closing this as external.

@nkolev92 nkolev92 closed this Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.