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.exe throws exception 'authors required' during pack of a csproj ignoring placeholders and assemblyinfo attributes if the assembly name is changed #4234

Closed
mawl opened this issue Jan 9, 2017 · 46 comments · Fixed by NuGet/NuGet.Client#3334
Assignees
Labels
Category:Quality Week Issues that should be considered for quality week Functionality:Pack Priority:2 Issues for the current backlog. Type:Bug

Comments

@mawl
Copy link

mawl commented Jan 9, 2017

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.

@mawl mawl changed the title nuget cli 3.5.0 throws exception during pack of a csproj (using placeholders) nuget cli 3.5.0 throws exception authors required during pack of a csproj ignoring placeholders and assemblyinfo attributes Jan 9, 2017
@mawl mawl changed the title nuget cli 3.5.0 throws exception authors required during pack of a csproj ignoring placeholders and assemblyinfo attributes nuget cli 3.5.0 throws exception 'authors required' during pack of a csproj ignoring placeholders and assemblyinfo attributes Jan 9, 2017
@rohit21agrawal rohit21agrawal self-assigned this Jan 20, 2017
@JohannesDrexler
Copy link

I have exact the same issue.

@JohannesDrexler
Copy link

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

@rohit21agrawal
Copy link
Contributor

@JohannesDrexler @mawl This is actually a different bug : #3146

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

@JohannesDrexler
Copy link

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

@rohit21agrawal
Copy link
Contributor

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

@rohit21agrawal
Copy link
Contributor

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
Copy link

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
Copy link

thoemmi commented Jan 31, 2017

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@04f9b91 ) says

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

@rohit21agrawal
Copy link
Contributor

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

@thoemmi
Copy link

thoemmi commented Feb 1, 2017

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

@thoemmi
Copy link

thoemmi commented Feb 1, 2017

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
Copy link

thoemmi commented Feb 3, 2017

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
Copy link

danielmclaugh commented Mar 23, 2017

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
Copy link

Livven commented Mar 29, 2017

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
Copy link

dweggemans commented Apr 20, 2017

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
Copy link

ghost commented Apr 24, 2017

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
Copy link

ghost commented Apr 25, 2017

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

@l6gslayer
Copy link

l6gslayer commented Jun 24, 2017

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
Copy link

The same issue!
When that will fixed?

@GeorgeTsaplin
Copy link

GeorgeTsaplin commented Sep 14, 2017

+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
Copy link

GeorgeTsaplin commented Sep 14, 2017

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.

@zhili1208 zhili1208 added the Priority:2 Issues for the current backlog. label Oct 17, 2017
@zhili1208 zhili1208 added this to the Backlog milestone Oct 17, 2017
@gatsbys
Copy link

gatsbys commented Nov 8, 2017

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")]

@Skoucail
Copy link

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
Copy link

Same issue

@brian-pickens
Copy link

brian-pickens commented Jun 11, 2019

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
Copy link

dmpe commented Sep 24, 2019

Run into this issue as well! Nuget version 5.2

@Code-ScottLe
Copy link

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

@aortiz-msft aortiz-msft added the Category:Quality Week Issues that should be considered for quality week label Mar 12, 2020
@nkolev92
Copy link
Member

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
Copy link
Member

nkolev92 commented Apr 8, 2020

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

@nkolev92 nkolev92 changed the title nuget cli 3.5.0 throws exception 'authors required' during pack of a csproj ignoring placeholders and assemblyinfo attributes nuget cli 3.5.0 throws exception 'authors required' during pack of a csproj ignoring placeholders and assemblyinfo attributes if the assembly name is changed Apr 8, 2020
@nkolev92 nkolev92 self-assigned this Apr 8, 2020
@nkolev92 nkolev92 changed the title nuget cli 3.5.0 throws exception 'authors required' during pack of a csproj ignoring placeholders and assemblyinfo attributes if the assembly name is changed nuget cli throws exception 'authors required' during pack of a csproj ignoring placeholders and assemblyinfo attributes if the assembly name is changed Aug 22, 2020
@nkolev92 nkolev92 changed the title nuget cli throws exception 'authors required' during pack of a csproj ignoring placeholders and assemblyinfo attributes if the assembly name is changed NuGet.exe throws exception 'authors required' during pack of a csproj ignoring placeholders and assemblyinfo attributes if the assembly name is changed Aug 22, 2020
@bladewolf55
Copy link

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
Copy link

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

@zivkan
Copy link
Member

zivkan commented Aug 28, 2020

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
Copy link
Member

@bladewolf55

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

@sintecnos-lucabiffi
Copy link

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

@bladewolf55
Copy link

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

#9954

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category:Quality Week Issues that should be considered for quality week Functionality:Pack Priority:2 Issues for the current backlog. Type:Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.