NuGet / Home

Repo for NuGet Client issues
Other
1.49k stars 252 forks source link

NuGet.exe throws exception 'authors required' during pack of a csproj ignoring placeholders and assemblyinfo attributes if the assembly name is changed #4234

Closed mawl closed 4 years ago

mawl commented 7 years ago

Details about Problem

NuGet Version: 3.5.0.1938 On Windows 10

Ignores Placeholder during pack: nuget.exe pack "NugetBug.csproj" -Properties Configuration=Release -Verbosity detailed -Symbols -Version "2.0.0"

Worked before? If so, with which NuGet version 2.8 (and 3.4.x)

Detailed repro steps so we can see the same problem

  1. Use https://github.com/mawl/NugetBug
  2. msbuild /p:Configuration=Release
With 2.8:
C:\projects\csharp\NugetBug\NugetBug>nuget.exe pack "NugetBug.csproj" -Properties Configuration=Release -Verbosity detailed -Symbols -Version "2.0.0"
Es wird versucht, das Paket aus "NugetBug.csproj" zu erstellen.
Paketerstellung der Dateien aus "C:\projects\csharp\NugetBug\NugetBug\bin\Release".
"NugetBug.nuspec" wird für Metadaten verwendet.
Datei "C:\projects\csharp\NugetBug\NugetBug\bin\Release\NugetBug.dll" dem Paket als "lib\net452\NugetBug.dll" hinzufügen

Id: NugetBug
Version: 2.0.0
Authors: Company
Description: Description
Dependencies: None

Die Datei "lib\net452\NugetBug.dll" wurde hinzugefügt.

Das Paket "C:\projects\csharp\NugetBug\NugetBug\NugetBug.2.0.0.nupkg" wurde erfolgreich erstellt.

Es wird versucht, das Symbolpaket für "NugetBug.csproj" zu erstellen.
Paketerstellung der Dateien aus "C:\projects\csharp\NugetBug\NugetBug\bin\Release".
"NugetBug.nuspec" wird für Metadaten verwendet.
Datei "C:\projects\csharp\NugetBug\NugetBug\bin\Release\NugetBug.dll" dem Paket als "lib\net452\NugetBug.dll" hinzufügen
Datei "C:\projects\csharp\NugetBug\NugetBug\bin\Release\NugetBug.pdb" dem Paket als "lib\net452\NugetBug.pdb" hinzufügen
Datei "C:\projects\csharp\NugetBug\NugetBug\Class1.cs" dem Paket als "src\Class1.cs" hinzufügen
Datei "C:\projects\csharp\NugetBug\NugetBug\Properties\AssemblyInfo.cs" dem Paket als "src\Properties\AssemblyInfo.cs" hinzufügen

Id: NugetBug
Version: 2.0.0
Authors: Company
Description: Description
Dependencies: None

Die Datei "lib\net452\NugetBug.dll" wurde hinzugefügt.
Die Datei "lib\net452\NugetBug.pdb" wurde hinzugefügt.
Die Datei "src\Class1.cs" wurde hinzugefügt.
Die Datei "src\Properties\AssemblyInfo.cs" wurde hinzugefügt.

Das Paket "C:\projects\csharp\NugetBug\NugetBug\NugetBug.2.0.0.symbols.nupkg" wurde erfolgreich erstellt.

With 3.5.x
C:\projects\csharp\NugetBug\NugetBug>c:\tmp\nuget-3.5.exe pack "NugetBug.csproj" -Properties Configuration=Release -Verbosity detailed -Symbols -Version "2.0.0"
NuGet Version: 3.5.0.1938
Es wird versucht, das Paket aus "NugetBug.csproj" zu erstellen.
MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
Paketerstellung der Dateien aus "C:\projects\csharp\NugetBug\NugetBug\bin\Release".
"NugetBug.nuspec" wird für Metadaten verwendet.
System.Exception: Authors is required.
Description is required.
   bei NuGet.Packaging.Manifest.Validate(Manifest manifest)
   bei NuGet.Packaging.Manifest.ReadFrom(Stream stream, Func`2 propertyProvider, Boolean validateSchema)
   bei NuGet.CommandLine.ProjectFactory.ProcessNuspec(PackageBuilder builder, String basePath)
   bei NuGet.CommandLine.ProjectFactory.CreateBuilder(String basePath, NuGetVersion version, String suffix, Boolean buildIfNeeded)
   bei NuGet.Commands.PackCommandRunner.BuildFromProjectFile(String path)
   bei NuGet.Commands.PackCommandRunner.BuildPackage(String path)
   bei NuGet.Commands.PackCommandRunner.BuildPackage()
   bei NuGet.CommandLine.PackCommand.ExecuteCommand()
   bei NuGet.CommandLine.Command.ExecuteCommandAsync()
   bei NuGet.CommandLine.Command.Execute()
   bei NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)

...

Other suggested things

Placeholder were ignored.

JohannesDrexler commented 7 years ago

I have exact the same issue.

JohannesDrexler commented 7 years ago

I downloaded nuget.exe 3.4.4 and it worked again so it seems the bug was introduced in 3.5

rohit21agrawal commented 7 years ago

@JohannesDrexler @mawl This is actually a different bug : https://github.com/NuGet/Home/issues/3146

If you change the name of your nuget-3.5.exe to nuget.exe, it should work for you.

JohannesDrexler commented 7 years ago

@rohit21agrawal the nuget.exe in my project is named nuget.exe and it doesn't work. Im creating a repro project now

rohit21agrawal commented 7 years ago

please include the nuget.exe in your repro project as well.

rohit21agrawal commented 7 years ago

the repro project provided by @mawl actually works well with nuget.exe 3.5.0 RTM (build 1938). Attaching the project with its build result and the nuget.exe used.

NugetBug.zip

JohannesDrexler commented 7 years ago

I am having problems recreating this issue but i don't want to attach the original project where it occures. In the project where it occured the "Author" and "Description" were included as a shared AssemblyInfo.cs that was included as "LinkedFile" in the project

thoemmi commented 7 years ago

I'm facing the same issue in my project: in the nuspec file I'm using $author$ and $description$, which -- according to the documentation -- should be replaced with the content of the assembly attributes AssemblyCompany and AssemblyDescription respectively.

However, NuGet v3.5 (and even the current NuGet/NuGet.Client@04f9b91fbb78b2adc2f81fd78badcee02f62212b ) says

Attempting to build package from 'TinyLittleMvvm.nuspec'. Authors is required. Description is required. Press any key to continue . . .

rohit21agrawal commented 7 years ago

@thoemmi i would be more than happy to take a look if you could tell me the repro steps for your project..

thoemmi commented 7 years ago

I'm out of office currently, but will provide you with repro steps in a couple of days.

thoemmi commented 7 years ago

It took me a while, but then I was able to reproduce it. It happens, when GitVersion writes a long AssemblyInformationalVersion including SHA, e.g.

[assembly: AssemblyInformationalVersion("0.5.1-wizard.1+7.Branch.feature/wizard.Sha.eb2021104d20c964ed7374c6c5e02c3b123f8e36")]

I have attached a small demo for reproduction, you just have to call build.bat. NuGetIssue4234.zip

thoemmi commented 7 years ago

I tried to investigate the issue. My assumption was right, AssemblyMetadataExtractor.GetMetadata throws an InvalidDataException if the AssemblyInformationalVersion is not a valid NuGet version.

However, this information never arrives at the user. Because the method throws an exception, it does not return a AssemblyMetadata object and thus author and description is not retrieved from the assembly.

Some more information for the user would be appreciated.

danielmclaugh commented 7 years ago

This related to this http://nuget.codeplex.com/discussions/262324 A work around documented here is to set the default project to release in the csproj instead of debug and then set author="Frank Dux" property.

Livven commented 7 years ago

I'm getting the same issue, even with new projects straight from the Class Library (.NET Framework) template. The value of the AssemblyInformationalVersion attribute (or whether it even exists) doesn't seem to matter (@thoemmi).

Repro (using nuget 3.5):

  1. Create new project from Class Library (.NET Framework) template.
  2. Run nuget spec in the project folder.
  3. Run nuget pack <ProjectName>.csproj.

Result:

Attempting to build package from '<ProjectName>.csproj'.
MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
Packing files from '<PathToBinFolder>'.
Using '<ProjectName>.nuspec' for metadata.
Authors is required.
Description is required.

Just for reference here's a Stackoverflow question regarding this issue.

dweggemans commented 7 years ago

I just ran into this issue as well. I can confirm it has to do with the AssemblyInformationalVersion produced by GitVersion.

On my local machine packaging works. The version generated locally is [assembly: AssemblyInformationalVersion("0.1.0-unstable.6+Branch.develop.Sha.5e3df28141ab83c853b26f35d1732d491cc266c2")]

On the buildserver a different version is produced: [assembly: AssemblyInformationalVersion("0.1.0-origin-develop.1+6.Branch.origin/develop.Sha.5e3df28141ab83c853b26f35d1732d491cc266c2")]

The latter does not work due to the branch name "origin/develop". A checkout to develop resolved my issue because the forward slash is no longer present.

ghost commented 7 years ago

I'm running Win 7 enterprise SP1 with VS2015 and VS2017 installed side by side. Targetting .Net 4.6.2

I cannot reproduce all of the above - this is happening to me with nuget versions v4.1 - NOT v3.5

I do notice that :

  1. Running v3.5.0.1938 of nuget it reports auto detection of MSBuild v14
  2. Running v4.1.0.2450 of nuget ir reports auto detection of MSBuild v15

Attribute value is: [assembly: AssemblyInformationalVersion("6.0.1-LOCAL-0000")]

Nuspec tag is: <authors>$author$</authors> This value is shared through a linked file common to all solution projects

Any ideas?

ghost commented 7 years ago

OK I've narrowed this down: V.3.5.0.1938 - works correctly V.3.5.0.1996 - gives the "authors required" bug

l6gslayer commented 7 years ago

I ran into this same problem and was able to fix it by making sure that the <authors></authors> section was defined in my .csproj file. Afterwards I had to update the token in the .nuspec file to $authors. It looks like the generated file uses $author without the "s" which caused the problem in my case.

renattomachado commented 7 years ago

The same issue! When that will fixed?

GeorgeTsaplin commented 7 years ago

+1 pack failed with "Authors is required" if assembly has: [assembly: AssemblyInformationalVersion("1.0.1-beta Branch:master Commit(SHA1):0917d95390880b1be64dd26fddc5be4dcc19605e")]

For example if change to [assembly: AssemblyInformationalVersion("1.0.1-beta.0917d95390880b1be64dd26fddc5be4dcc19605e")] then pack works fine.

According to this https://blog.nuget.org/20140924/supporting-semver-2.0.0.html NuGet supported Build Metadata, but even with such format got same "Authors is required" exception: [assembly: AssemblyInformationalVersion("1.0.1-beta+Branch:master Commit(SHA1):0917d95390880b1be64dd26fddc5be4dcc19605e")]

GeorgeTsaplin commented 7 years ago

Futher investigation shows that NuGet pack works fine according SemVer 2.0.0 specification. Error cause found by @thoemmi known as Build metadata and must has such format.

gatsbys commented 6 years ago

Same issue here!

Create lib project in Csharp. nuget spec on the folder nuget pack {mynugetspecfile} : Value cannot be null or an empty string. Nombre del parámetro: value

I change version manually to 1.0.0 then nuget spec -Force and pack :

Id is required. Authors is required. Description is required.

My AssemblyInfo is :

using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("WebCacheHelper")] [assembly: AssemblyDescription("Cache Helper for web applications. Aside strategy.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("MyCompany")] [assembly: AssemblyProduct("WebCacheHelper")] [assembly: AssemblyCopyright("Copyright © 2017")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("dcef87c2-1c69-4e59-be44-e9d2ee63194a")]

// Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")]

SH2015 commented 6 years ago

Same issue here, please fix the bug ASAP @zhili1208

qidydl commented 6 years ago

Problem still exists in NuGet 4.6.2.5055, although after 18 months, I assume this is WONTFIX?

cbries commented 5 years ago

Problem still exists in NuGet 4.9.2.5706. I ran into this issue right now.

zodiac403 commented 5 years ago

Can confirm. This still seems to be an issue with NuGet Version: 4.9.2.5706.

crashbdx commented 5 years ago

Same here :(

bickycheese commented 5 years ago

lol!

szczepix commented 5 years ago

Same here 😢

rogersillito commented 5 years ago

Likewise for me - I specifically need to do a debug build of my package. NuGet Version: 4.9.3.5777

adun commented 5 years ago

I ran into this issue today with NuGet Version: 4.9.3.5777.

sbacquet commented 5 years ago

Same issue with 4.9.3.5777. Had to replace $author$ with $authors$ manually.

Rahkola commented 5 years ago

I'm having the same issue when building in Azure DevOps and using GitVersion task in my build pipeline. I would assume that it's related and points out to the issue with the AssemblyInformationalVersion generated by GitVersion.

NuGet Version: 4.1.0.2450 Assembly Informational Version 12.2.2-beta.1+1.Branch.hotfix/12.2.2.Sha.15e4cc6e6d3b9da9d03449b6d62f282a502bcb73

Edit Confirmed that the issue went away by replacing the Assembly Informational Version with only major.minor.patch 12.2.2 This further verifies that the issue is indeed with parsing the data in AssemblyMetadataExtractor.GetMetadata function, as pointed out by @thoemmi

Skoucail commented 5 years ago

I just ran into this issue and in my opinion its a problem in GitVersion. I just posted a comment on GitVersion's github too Bug: Branch contains / is not replaced by - in build metadata

As i posted: GitVersion is not following the Semantic Versioning 2.0.0 specs. '/' or ':' aren't allowed metadata characters. They should replace these characters with '.' or '-'.

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.

emmanuelmathot commented 5 years ago

Same issue

brian-pickens commented 5 years ago

My Solution

Ensure the the following AssemblyInfo properties are not empty strings.

[assembly: AssemblyDescription("")]
[assembly: AssemblyCompany("")]

This resolved the 'Authors is required' and 'Description is required' error. I guess these can be non empty.

Update This seems to have resolved my issue locally, but still trying to figure out why my devops build is still throwing the same error after this fix.

dmpe commented 4 years ago

Run into this issue as well! Nuget version 5.2

Code-ScottLe commented 4 years ago

is this bug gaining any traction? 2-year delay doesn't seem great to me.

nkolev92 commented 4 years ago

Is anyone able to repro this issue with nuget.exe as the tool name? Specifically trying to figure if #3146 is the root cause for these problems.

nkolev92 commented 4 years ago

At this point I'm treating this as a dup of #3146 but keeping this open as it has more engagement.

bladewolf55 commented 4 years ago

Using the exact same project and build:

Nuget Version 5.6.0.6591 does not display the Authors/Description error. However, version 5.7.0.6726 does.

I'm surprised this important issue doesn't seem to be regression tested.

5.6 output

nuget pack -verbosity detailed
NuGet Version: 5.6.0.6591
Attempting to build package from 'ClassLibrary1.csproj'.
MSBuild auto-detection: using msbuild version '16.7.0.37604' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
Packing files from 'C:\Users\charl\Google Drive\Development\NuGet Testing\NuGet Dependency Resolution\Framework Major-Numbered\ClassLibrary1\ClassLibrary1\bin\Debug'.
Using 'ClassLibrary1.nuspec' for metadata.
Add file 'C:\Users\charl\Google Drive\Development\NuGet Testing\NuGet Dependency Resolution\Framework Major-Numbered\ClassLibrary1\ClassLibrary1\bin\Debug\ClassLibrary1.dll' to package as 'lib\net472\ClassLibrary1.dll'

Id: ClassLibrary1
Version: 1.0.0
Authors: C
Description: D
Dependencies:

Added file '[Content_Types].xml'.
Added file '_rels/.rels'.
Added file 'ClassLibrary1.nuspec'.
Added file 'lib/net472/ClassLibrary1.dll'.
Added file 'package/services/metadata/core-properties/0a9c65c5d99145c6af36a7c3d0d48724.psmdcp'.

Successfully created package 'C:\Users\charl\Google Drive\Development\NuGet Testing\NuGet Dependency Resolution\Framework Major-Numbered\ClassLibrary1\ClassLibrary1\ClassLibrary1.1.0.0.nupkg'.

5.7 output

nuget pack -verbosity detailed
NuGet Version: 5.7.0.6726
Attempting to build package from 'ClassLibrary1.csproj'.
MSBuild auto-detection: using msbuild version '16.7.0.37604' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
Packing files from 'C:\Users\charl\Google Drive\Development\NuGet Testing\NuGet Dependency Resolution\Framework Major-Numbered\ClassLibrary1\ClassLibrary1\bin\Debug'.
Could not load file or assembly 'file:///C:\Program Files (x86)\NuGet CLI\nuget.exe' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
Using 'ClassLibrary1.nuspec' for metadata.
Authors is required.
Description is required.
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 builder)
   at NuGet.Commands.PackCommandRunner.BuildFromProjectFile(String path)
   at NuGet.Commands.PackCommandRunner.RunPackageBuild()
   at NuGet.CommandLine.PackCommand.ExecuteCommand()
   at NuGet.CommandLine.Command.ExecuteCommandAsync()
   at NuGet.CommandLine.Command.Execute()
   at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)
bladewolf55 commented 4 years ago

I see the original thread is closed. Should I start a new one, or can this be reopened?

zivkan commented 4 years ago

I think it's better to start a new thread. This thread was closed when a PR was merged, meaning this issue is linked to our release notes.

nkolev92 commented 4 years ago

@bladewolf55

The change for this particular issue is in 5.7, not 5.6.

sintecnos-lucabiffi commented 3 years ago

I'm using NuGet 5.7.0.6726 and this still has to be fixed

bladewolf55 commented 3 years ago

@sintecnos-lucabiffi You might add your comment to the new thread so it's clear the issue exists in the latest build.

https://github.com/NuGet/Home/issues/9954