Hi
There seems to be an issue with the nuget pack option when the AssemblyInformationalVersion contains an invalid value. I had presumed "beta" was an acceptable value and then I see "author/description is required" which is the error from issuing the "nuget pack" command. This is misleading.
To recreate
At the very least the error message here is misleading.
NuGet Version: 4.1.0.2450
Solution built with VS 14.0.25123.00 Update 2
Solution targetting .Net framework v4.5.2
Written in C# not VB (although I'm not sure this matters)
Using the nuspec file
<?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>Initial Release of Project.Name</releaseNotes>
<copyright>Copyright 2017</copyright>
<tags>Project Project.Name</tags>
</metadata>
</package>
An invalid AssemblyInfo.cs file would be...
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("A.Title.Here")]
[assembly: AssemblyDescription("Any description.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Company.Name")]
[assembly: AssemblyProduct("Project.Name")]
[assembly: AssemblyCopyright("Copyright")]
[assembly: AssemblyInformationalVersion("beta")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("e37b2b24-6b0a-4ad9-a2d8-a33c1f22b829")]
[assembly: AssemblyVersion("1.0.5.0")]
[assembly: AssemblyFileVersion("1.0.5.0")]
Issuing the following commands yields the following results...
nuget pack Project.csproj -Build -Verbosity detailed
Using '{something}.nuspec' for metadata.
System.Exception: Authors is required.
Description is required.
at NuGet.Packaging.Manifest.Validate(Manifest manifest)
at NuGet.Packaging.Manifest.ReadFrom(Stream stream, Func`2 propertyProvider, Boolean validateSchema)
at NuGet.CommandLine.ProjectFactory.ProcessNuspec(PackageBuilder builder, String basePath)
at NuGet.CommandLine.ProjectFactory.CreateBuilder(String basePath, NuGetVersion version, String suffix, Boolean buildIfNeeded, PackageBuilder build
er)
at NuGet.Commands.PackCommandRunner.BuildFromProjectFile(String path)
at NuGet.CommandLine.PackCommand.ExecuteCommand()
at NuGet.CommandLine.Command.ExecuteCommandAsync()
at NuGet.CommandLine.Command.Execute()
at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)
Note the error above is misleading, as the problem is an invalid attribute, but the description is A-OK. Adjusting the AssemblyInformationalVersion attribute as below resolves the issue.
[assembly: AssemblyInformationalVersion("1.0-beta")]
nuget pack Project.csproj -Build -Verbosity detailed
Successfully created package
Update to this:
We just started having these issues with v4.8.1. Here's what our AssemblyInformationalVersion looked like in both failure cases so far. This was working with much older versions. We use GitVersion to generate the version #'s placed into AssemblyInfo. So, I don't believe either of these should have caused any issues.
Build from a tag - 2.1.1.Sha.51ca7ae4572a95ecc0c3ac570780922ccbe5a694
Build from a pull request - 2.1.1-PBI-105043-FET-RemovePostAndContriveKeyFromScrubber.1+3.Branch.features/PBI-105043-FET-RemovePostAndContriveKeyFromScrubber.Sha.12be4d23a8434b0745b8291d0040c00e9c1bc1a5
Same here with 4.9.2.5706 and GitVersion:
[assembly: AssemblyInformationalVersion("1.1.0-version.1+881.Branch.feature/version.Sha.8358cb26832a14f95ae54567e14454f646dab44b")]
The problem here is the slash after feature. If I replace the slash with a hyphen everything is fine.
Had the same problem today with NuGet version: 5.4.0.6315 and the following in AssemblyInfo.cs
[assembly: AssemblyInformationalVersion("1.0 (April 2020)")]
The error message Description is required. is completely misleading.
@JereckNET
I'm trying to reproduce the bug so that I may come up with a fix, and I'm not successful: I've tried to reproduce with a simple project. But nuget (versions 5.4, 5.5 or 5.6-preview2) do not seem to exhibit the problem any more.
Could you elaborate on the circumstances you encounter the issue? Do you use nuget in command line? Do you have a nuspec? The best would be a repro project!
Thanks!
I used the exact same steps as described in the first post of this thread.
S:\Projets\TestNuGet\TestNuGet>nuget update -self
Checking for updates from https://www.nuget.org/api/v2/.
Currently running NuGet.exe 5.4.0.
NuGet.exe is up to date.S:\Projets\TestNuGet\TestNuGet>nuget spec TestNuGet.csproj
Created 'TestNuGet.nuspec' successfully.S:\Projets\TestNuGet\TestNuGet>nuget pack TestNuGet.csproj -Build
Attempting to build package from 'TestNuGet.csproj'.
MSBuild auto-detection: using msbuild version '16.5.0.12403' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\bin'.
Building project 'S:\Projets\TestNuGet\TestNuGet\TestNuGet.csproj' for target framework '.NETFramework,Version=v4.5.2'.
Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.Build started 10/04/2020 10:15:06.
Project "S:\Projets\TestNuGet\TestNuGet\TestNuGet.csproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "bin\Debug\".
Creating directory "obj\Debug\".
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the i
nput files.
CoreCompile:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\bin\Roslyn\csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\Microsoft.CSharp.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.Data.DataSetExtensions.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.Net.Http.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\System.Xml.Linq.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\TestNuGet.dll /ruleset:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Static Analysis Tools\Rule Sets\MinimumRecommendedRules.ruleset" /subsystemversion:6.00 /target:library /utf8output /deterministic+ /langversion:7.3 Class1.cs PropertiesAssemblyInfo.cs "C:\Users\Jereck\AppData\Local\Temp.NETFramework,Version=v4.5.2.AssemblyAttributes.cs"
Using shared compilation with compiler from directory: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\bin\Roslyn
CopyFilesToOutputDirectory:
Copying file from "S:\Projets\TestNuGet\TestNuGet\obj\Debug\TestNuGet.dll" to "S:\Projets\TestNuGet\TestNuGet\bin\Debug\TestNuGet.dll".
TestNuGet -> S:\Projets\TestNuGet\TestNuGet\bin\Debug\TestNuGet.dll
Copying file from "S:\Projets\TestNuGet\TestNuGet\obj\Debug\TestNuGet.pdb" to "S:\Projets\TestNuGet\TestNuGet\bin\Debug\TestNuGet.pdb".
Done Building Project "S:\Projets\TestNuGet\TestNuGet\TestNuGet.csproj" (default targets).Build succeeded.
0 Warning(s)
0 Error(s)Time Elapsed 00:00:00.39
Packing files from 'S:\Projets\TestNuGet\TestNuGet\bin\Debug'.
Using 'TestNuGet.nuspec' for metadata.
Authors is required.
Description is required.
The (very light) test project : TestNuGet.zip
Check AssemblyInfo.cs and (un)comment the last lines to test.
AssemblyInformationalVersion | Pack ? | Package name
----------------------------------|--------|------------------
_No attribute tag_ | Yes | TestNuGet.1.0.0.nupkg
"beta" | No |
"1.0-beta" | Yes | TestNuGet.1.0.0-beta.nupkg
"1.0 (April 2020)" | No |
To summarize :
Although you can specify any text, a warning message appears on compilation if the string is not in the format used by the assembly version number, or if it is in that format but contains wildcard characters. This warning is harmless.
Thanks for the details. I'll have a look into it
Concerning your last assertion:
The AssemblyInformationalVersion should not be required to follow said rule
I'm not sure this is applicable here. The documentation you refer to indicates what an AssemblyInformationalVersionAttribute can be with respect to the C# compiler or the .NET framework: neither expects anything special from this attribute.
However, nuget requires Semver versions for the packages: See https://docs.microsoft.com/en-us/nuget/concepts/package-versioning. Therefore, the fact that, with nuspec generation, the package version comes from AssemblyInformationalVersionAttribute via the $version$ placeholder imposes additional constraints to it.
This explains why beta alone, or 1.0 (April 2020) do not work; they are not correct Semver versions. Nuget documentation should be a bit more clear about this...
So what I'll try to do is:
AssemblyVersionAttribute if AssemblyInformationalVersionAttribute cannot be parsed. Looking at nuget's code it seems this is already something that is done in other places.Thank you for the "SemVer" explanation
I re-downloaded my sample project, and ran some more tests.
If I run the "pack" command _without_ creating the .nuspec file, I receive the following warning, but no error :
WARNING: NU5115: Description was not specified. Using 'Description'.
WARNING: NU5115: Author was not specified. Using 'jereck'.
Then, I created the .nuspec file, and I removed the '$' in the Author and Description fields :
<package >
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>Jereck</authors>
<owners>$author$</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<projectUrl>http://project_url_here_or_delete_this_line/</projectUrl>
<iconUrl>http://icon_url_here_or_delete_this_line/</iconUrl>
<description>Description</description>
<releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
<copyright>Copyright 2020</copyright>
<tags>Tag1 Tag2</tags>
</metadata>
</package>
Then, the pack command works, but and generates the TestNuGet.1.0.0.nupkg package.
Notice the version number : "1.0.0" event though it should be '1.0.5' based on the AssemblyInfo.cs file.
I believe that, if the AssemblyInformationalVersionAttribute is not a valid SemVer value, the entire file is discarded. Which explains why $author$ and $description$ are replaced by empty values, and then, the incorrect error message.
I'll look into this as well, but that may be the subject for another issue :,-)
@JereckNET
I just submitted a PR. It appears that the second problem you describe (choosing 1.0.0 over the assembly version) was directly related to the wrong error messages - well at least, the way I fixed the issue has the consequence that now the assembly version is chosen in case of a missing or invalid informational version. So given the PR is accepted it should fix both issues.
@odalet Sorry I was not more explicit : that "second problem" was meant as a hint for you (I guessed there was that deeper problem) and not as a second grievance.
Thank you for the fix.
Oh you were explicit enough: you were perfectly right in supposing that an invalid informational version had the whole file (in fact the whole metadata extracted from the assembly to package).