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

Nuget pack defaults to version 1.0.0 when AssemblyInformationalVersion metadata contains forward slash #4082

Closed
cortex93 opened this issue Dec 9, 2016 · 10 comments
Labels
Functionality:Pack Priority:1 High priority issues that must be resolved in the current sprint. Product:NuGet.exe NuGet.exe
Milestone

Comments

@cortex93
Copy link

cortex93 commented Dec 9, 2016

Details about Problem

When AssemblyInformationalVersion is a SemVer2 value where BuildMetadata segment contains a forward slash, nuget pack do not resolve version from AssemblyInformationalVersion attribute and use 1.0.0 as a default version number, also skipping other version attributes with valid version.

Same behavior when resolving version of dependent projects (IncludeReferencedProjects )

NuGet product used (NuGet.exe):

NuGet version (3.5.0-rtm-1996, 3.6.0-rc-2004):

OS version (i.e. win2016 build 14393):

Worked before? If so, with which NuGet version:
I think no

Detailed repro steps so we can see the same problem

  1. Create a project.
  2. Set AssemblyInformationVersion to something like 0.4.1-beta.1+3.Branch.hotfix/0.4.1.Sha.425411544773065ae3f26134ecc2f977953efe39
  3. Set AssemblyVersion to 0.4.1
  4. Build and pack project (packing csproj)
  5. package version is 1.0.0
@cortex93 cortex93 changed the title Nuget pack default to version 1.0.0 when AssemblyInformationalVersion metadata contains forward slash Nuget pack defaults to version 1.0.0 when AssemblyInformationalVersion metadata contains forward slash Dec 9, 2016
@rrelyea rrelyea added this to the Future-1 milestone Dec 10, 2016
@zhili1208 zhili1208 modified the milestones: Future-1, 4.5 Oct 17, 2017
@zhili1208 zhili1208 added the Product:NuGet.exe NuGet.exe label Oct 17, 2017
@zhili1208
Copy link
Contributor

Please try nuget.exe 4.3 from https://www.nuget.org/downloads, if it still repro, feel free to reopen it

@joffreynorsys
Copy link

I have the same problem with the last recommended version (4.6.2)

@cortex93
Copy link
Author

cortex93 commented May 29, 2018

It's also in VS 15.7.2
With a .NETSdk csproj :
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
and own [assembly: System.Reflection.AssemblyInformationalVersionAttribute("0.4.1-beta.1+3.Branch.hotfix/0.4.1.Sha.425411544773065ae3f26134ecc2f977953efe39")]
gives a 1.0.0 nuget package.

Note: Without GeneratePackageOnBuild, pack context menu command seems do nothing.

With
<Version>0.4.1-beta.1+3.Branch.hotfix/0.4.1.Sha.425411544773065ae3f26134ecc2f977953efe39</Version>
gives a build error
C:\Program Files\dotnet\sdk\2.1.201\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(114,5): error MSB4018: System.ArgumentException: '0.4.1-beta.1+3.Branch.hotfix/0.4.1.Sha.425411544773065ae3f26134ecc2f977953efe39' is not a valid version string.

@zhili1208 zhili1208 reopened this May 29, 2018
@zhili1208 zhili1208 modified the milestones: 4.5, Backlog May 29, 2018
@zhili1208 zhili1208 added the Priority:1 High priority issues that must be resolved in the current sprint. label May 29, 2018
@dasMulli
Copy link

@cortex93 this is likely the same as in #6972

@rohit21agrawal
Copy link
Contributor

rohit21agrawal commented May 30, 2018

can you try setting [assembly: System.Reflection.AssemblyInformationalVersionAttribute("0.4.1-beta.1+3.Branch.hotfix/0.4.1.Sha.425411544773065ae3f26134ecc2f977953efe39")] as you are currently doing in csproj, and also set PackageVersion in csproj to the same value (instead of setting version) ?

@cortex93
Copy link
Author

@dasMulli That would explain case 1.
At least, a warning message should appears because, in that case, the package tabs in project properties show the attribute value as Package versions.

@rohit21agrawal Same result as case 2

@rohit21agrawal
Copy link
Contributor

@cortex93 markdown swallowed my <PackageVersion> tag. This is what i meant:

set PackageVersion in csproj to the same value as AssemblyInformationVersionAttribute (instead of setting Version property)

@cortex93
Copy link
Author

cortex93 commented Jun 1, 2018

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
    <PackageVersion>0.4.1-beta.1+3.Branch.hotfix/0.4.1.Sha.425411544773065ae3f26134ecc2f977953efe39</PackageVersion>
  </PropertyGroup>
</Project>
using System;
using System.Reflection;
[assembly: AssemblyVersion("0.4.1")]
[assembly: AssemblyInformationalVersion("0.4.1-beta.1+3.Branch.hotfix/0.4.1.Sha.425411544773065ae3f26134ecc2f977953efe39")]

namespace ClassLibrary1
{
    public class Class1
    {
    }
}

1>C:\Program Files\dotnet\sdk\2.1.201\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(78,5): error MSB4018: The "GetPackOutputItemsTask" task failed unexpectedly.
1>C:\Program Files\dotnet\sdk\2.1.201\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(78,5): error MSB4018: System.ArgumentException: PackageVersion string specified '0.4.1-beta.1+3.Branch.hotfix/0.4.1.Sha.425411544773065ae3f26134ecc2f977953efe39' is invalid.
1>C:\Program Files\dotnet\sdk\2.1.201\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(78,5): error MSB4018:    at NuGet.Build.Tasks.Pack.GetPackOutputItemsTask.Execute()
1>C:\Program Files\dotnet\sdk\2.1.201\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(78,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Program Files\dotnet\sdk\2.1.201\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(78,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

@rohit21agrawal
Copy link
Contributor

@cortex93 this is because your version string is invalid as per semver2.0 requirements:

Build metadata MAY be denoted by appending a plus sign and a series of dot separated identifiers immediately following the patch or pre-release version. Identifiers MUST comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Build metadata SHOULD be ignored when determining version precedence. Thus two versions that differ only in the build metadata, have the same precedence. Examples: 1.0.0-alpha+001, 1.0.0+20130313144700, 1.0.0-beta+exp.sha.5114f85.

Source: https://semver.org/

You need to remove / from your version string.

@cortex93
Copy link
Author

cortex93 commented Jun 4, 2018

@rohit21agrawal. Ok. I close this issue. When fixed, the related one should lead to better consistency in error message when building without PackageVersion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:Pack Priority:1 High priority issues that must be resolved in the current sprint. Product:NuGet.exe NuGet.exe
Projects
None yet
Development

No branches or pull requests

6 participants