'Nuget.exe pack WARNING: Description was not specified. Using 'Description'

I'm trying to create a NuGet Package via command line and I can't seem to figure out how to set Description, Author, Title, Summary, releaseNotes, and Owner. The package creates successfully it just gives me this warning:

WARNING: Description was not specified. Using 'Description'.
WARNING: Author was not specified. Using 'User'.

Here's my command:

NuGet.exe pack "<MyProjectPath>.csproj" -OutputDirectory "<MyOutputDirectory>" -Properties Configuration=release;Description="MyDescription";Authors="MeMeMe...MeToo";Title="MyTitle";Summary="MySummary";releaseNotes="MyChanges;"Owners="MyCompany"

I'm not sure if this matters but I'm using the NuGet.exe that came from the "CredentialProviderBundle.zip" file downloaded from Visual Studio Team Services.



Solution 1:[1]

There's actually almost nothing wrong with the command.

It is not possible to do what the question asks without some prerequisites.

  1. There must be a *.nuspec file in the same directory as the *.csproj with the same exact name.
  2. The *.nuspec file must contain all the elements you are trying to set via command line
  3. All elements that will be populated via command line must contain a token in the form "$tokenName$"
  4. In the command line you must not specify the *.nuspec element name but rather the value contained between the dollar signs (AKA the token name)
  5. The token name may be the same as the element name for all the properties listed in the question with the exception of the Description element. The Description element's token must NOT be named "Description". "Desc" works perfectly fine here. (This is why I said ALMOST nothing wrong with the command listed in the question)

Here's an example of a *.nuspec file for this specific example:

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
    <metadata>
        <id>$Id$</id>
        <version>$Version$</version>
        <title>$Title$</title>
        <authors>$Authors$</authors>
        <owners>$Owners$</owners>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>$Desc$</description>
        <summary>$Summary$</summary>
        <releaseNotes>$ReleaseNotes$</releaseNotes>
        <copyright>Copyright ©  2016</copyright>
        <dependencies />
    </metadata>
</package>

The Id and Version don't need to have tokens because they will automatically be overwritten either way, but it doesn't hurt.

Here's the command line you should use with the *.nuspec file as specified above:

NuGet.exe pack "<MyProjectPath>.csproj" -OutputDirectory "<MyOutputDirectory>" -Properties Configuration=release;Desc="MyDescription";Authors="MeMeMe...MeToo";Title="MyTitle";Summary="MySummary";ReleaseNotes="MyChanges;"Owners="MyCompany"

Solution 2:[2]

In case this helps someone else, a stupid reason for getting a "Description is required" error: I had not rebuilt my project since I added a description to my AssemblyInfo.

I'd defined a nuspec file in my project directory with a <description>$description$</description> token. When I ran

nuget pack MyProject.csproj

I saw a "Description is required" error, even though my AssemblyInfo contained [assembly: AssemblyDescription("A DESCRIPTION.")]...

... because although you pack the .csproj, it is your most recent build that is actually packaged by Nuget. d'oh.

Solution 3:[3]

For me unblocking nuget.exe did the trick. As of NuGet 5.7 this seems to be necessary.

Unblock nuget.exe

Solution 4:[4]

I know this is fairly old, but I've been struggling with this issue today for a while. I was running

nuget pack SomeRandom.csproj -Properties Configuration=Release

and I was getting 'Description is required' error.

I ended up then deleting the nuspec file and getting nuget to create a new one by running

nuget spec SomeRandom.csproj

Then when I ran nuget pack it worked fine. Weird, but could help someone.

Solution 5:[5]

Just to add to this post, since neither of these fully helped me, run the command

nuget pack

This will create a Package.nuspec file for you at the base of your solution. Once this is done, you must rename the file to NameOfProject.nuspec. So if my project is called GameEngine.csproj then I will rename my nuspec file to GameEnginer.csproj. Then, move this file into the same folder that the .csproj is located (NOT the debug/release folder, just the basic folder containing all your handwritten code files). Then go ahead and run

nuget pack RelativePathOfNameOfProject.csproj

So if I wanted to hit my GameEngine.csproj the command would look something like

nuget pack .\GameEngine\GameEngine.csproj

Since my folder structure looks something like:

root/
??? Folder1/
??? Folder2/
??? GameEngine/
?   ??? bin/
?   ??? obj/
?   ??? Properties/
?   ??? Class1.cs
?   ??? Class2.cs
?   ??? GameEngine.nuspec
?   ??? GameEngine.csproj
??? packages/
??? GameEngine.sln/

Hopefully between these answers, you can figure it out :)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 LorneCash
Solution 2 tessafyi
Solution 3 Matthias Schuchardt
Solution 4 matt_lethargic
Solution 5 Manny Villa