简体   繁体   English

Nuget.exe 包警告:未指定说明。 使用“描述”

[英]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.我正在尝试通过命令行创建 NuGet Package,但我似乎无法弄清楚如何设置描述、作者、标题、摘要、发布说明和所有者。 The package creates successfully it just gives me this warning: package 成功创建它只是给了我这个警告:

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.我不确定这是否重要,但我使用的是 NuGet.exe,它来自从 Visual Studio Team Services 下载的“CredentialProviderBundle.zip”文件。

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.在与 *.csproj 相同的目录中必须有一个具有相同名称的 *.nuspec 文件。
  2. The *.nuspec file must contain all the elements you are trying to set via command line *.nuspec 文件必须包含您尝试通过命令行设置的所有元素
  3. All elements that will be populated via command line must contain a token in the form "$tokenName$"将通过命令行填充的所有元素都必须包含“$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)在命令行中,您不能指定 *.nuspec 元素名称,而是指定包含在美元符号之间的值(也称为令牌名称)
  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". Description 元素的标记不得命名为“Description”。 "Desc" works perfectly fine here. “Desc”在这里工作得很好。 (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:以下是此特定示例的 *.nuspec 文件示例:

<?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. Id 和 Version 不需要有令牌,因为无论哪种方式它们都会自动被覆盖,但这不会造成伤害。

Here's the command line you should use with the *.nuspec file as specified above:这是您应该与上面指定的 *.nuspec 文件一起使用的命令行:

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

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.万一这对其他人有帮助,这是导致“需要描述”错误的愚蠢原因:自从我向我的 AssemblyInfo 添加描述以来,我没有重建我的项目。

I'd defined a nuspec file in my project directory with a <description>$description$</description> token.我在我的项目目录中定义了一个带有<description>$description$</description>标记的 nuspec 文件。 When I ran当我跑

nuget pack MyProject.csproj

I saw a "Description is required" error, even though my AssemblyInfo contained [assembly: AssemblyDescription("A DESCRIPTION.")] ...我看到了“需要描述”错误,即使我的 AssemblyInfo 包含[assembly: AssemblyDescription("A DESCRIPTION.")] ...

... because although you pack the .csproj , it is your most recent build that is actually packaged by Nuget. ...因为尽管您打包了.csproj ,但实际上是 Nuget 打包的是您的最新版本。 d'oh.哦。

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我最终删除了 nuspec 文件并让 nuget 通过运行来创建一个新文件

nuget spec SomeRandom.csproj

Then when I ran nuget pack it worked fine.然后当我运行 nuget pack 时它运行良好。 Weird, but could help someone.奇怪,但可以帮助某人。

For me unblocking nuget.exe did the trick.对我来说,解除阻止 nuget.exe 成功了。 As of NuGet 5.7 this seems to be necessary .从 NuGet 5.7 开始,这似乎是必要的

取消阻止 nuget.exe

For a similar, but related issue:对于类似但相关的问题:

When setting these properties through the.csproj file of a .NET Core project, the warnings can be avoided by using:通过 .NET Core 项目的 .csproj 文件设置这些属性时,可以使用以下方法避免警告:

dotnet pack

instead of代替

nuget pack

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.这将在您的解决方案的基础上为您创建一个Package.nuspec文件。 Once this is done, you must rename the file to NameOfProject.nuspec .完成此操作后,您必须将文件重命名为NameOfProject.nuspec So if my project is called GameEngine.csproj then I will rename my nuspec file to GameEnginer.csproj .因此,如果我的项目名为GameEngine.csproj那么我会将我的nuspec文件重命名为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).然后,将此文件移动到 .csproj 所在的同一文件夹中(不是调试/发布文件夹,只是包含所有手写代码文件的基本文件夹)。 Then go ahead and run然后继续运行

nuget pack RelativePathOfNameOfProject.csproj

So if I wanted to hit my GameEngine.csproj the command would look something like所以如果我想点击我的GameEngine.csproj命令看起来像

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 :)希望在这些答案之间,您可以弄清楚:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM