简体   繁体   English

禁止 Nuget.exe 的警告输出

[英]Suppress warning output from Nuget.exe

I'm wondering if I can suppress warning messages in the output from the nuget.exe pack command?我想知道是否可以在 nuget.exe pack 命令的输出中抑制警告消息? Specific messages would be awesome, but I can live with suppressing all of them.特定的信息会很棒,但我可以忍受压制所有这些信息。

The nuget command line documentation mentions a Verbosity flag, but never really specifies what the valid values for that are. nuget命令行文档提到了 Verbosity 标志,但从未真正指定其有效值是什么。 I've tried the following:我尝试了以下方法:

nuget pack mypackage.nuspec -Verbosity Quiet

But doesn't seem to do anything.但是好像什么都做不了。

Here is an example of the nuspec I'm trying to pack:这是我要打包的 nuspec 示例:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
    <metadata>
        <id>MyPackage</id>
        <version>1.0.0</version>
        <authors>Administrator</authors>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>My package description.</description>
    </metadata>
    <files>
        <file src="mysourcepath\foo.dll" target="mytargetpath\foo.dll" />
    </files>
</package>

The warning message I get is this:我得到的警告信息是这样的:

WARNING: 1 issue(s) found with package 'MyPackage'.

Issue: Assembly outside lib folder.
Description: The assembly 'mytargetpath\foo.dll' is not inside the 'lib' folder and hence it won't be added as a reference when the package is installed into a project.
Solution: Move it into the 'lib' folder if it should be referenced.

I'm creating a nuget package that will be deployed as an application via an Octopus server.我正在创建一个 nuget 包,它将通过八达通服务器部署为应用程序。 The assemblies in this dll do NOT need to be referenced by anything - this package should never be referenced as part of a build (we have other more logical packages for that).这个 dll 中的程序集不需要被任何东西引用——这个包永远不应该作为构建的一部分被引用(我们有其他更合乎逻辑的包)。

I want to suppress this warning because the actual package I'm creating has thousands of files, none of which are in the lib folder.我想取消此警告,因为我创建的实际包有数千个文件,其中没有一个在 lib 文件夹中。 The output noise from this one warning is making it difficult to see any other legitimate warnings I might be interested in.这个警告的输出噪音使我很难看到我可能感兴趣的任何其他合法警告。

UPDATE: This package is packed from a custom nuspec file - it consists of the output of hundreds of projects, so specifying a project file is not a viable option for eliminating the warning.更新:这个包是从一个自定义的 nuspec 文件打包的——它包含数百个项目的输出,所以指定一个项目文件不是消除警告的可行选项。 FWIW, specifying a project file does eliminate the warning, because it ends up putting the project output into a lib folder - which is what I'm trying to avoid. FWIW,指定一个项目文件确实消除了警告,因为它最终将项目输出放入一个 lib 文件夹 - 这是我试图避免的。

TIA for any input.任何输入的 TIA。

First of all, nuget reference clearly specifies what the valid values are for Verbosity .In the link you have provided under the pack command section:首先,nuget 参考明确指定了Verbosity的有效值。在您在pack命令部分下提供的链接中:

Display this amount of details in the output: normal, quiet, (v2.5) detailed.在输出中显示此数量的详细信息:正常、安静、(v2.5) 详细信息。

Try packing your project file instead of .nuspec file if possible, use lowercase for quiet flag and use -NoPackageAnalysis :如果可能,尝试打包您的项目文件而不是.nuspec文件,使用小写字母作为quiet标志并使用-NoPackageAnalysis

nuget pack myproject.proj -Verbosity quiet -NoPackageAnalysis

The -nopackageanalysis flag will suppress the warning, even when using a .nuspec file. -nopackageanalysis标志将抑制警告,即使在使用.nuspec文件时也是.nuspec

You might also consider using Octopack , if it's an option.如果可以的,您也可以考虑使用Octopack Octopack was designed to create packages specifically for Octopus Deploy (ie, no lib folder, no spurious warning messages, etc.) It uses NuGet under the hood so you can still use it with a .nuspec file as well. Octopack 旨在为 Octopus Deploy 创建包(即,没有 lib 文件夹,没有虚假的警告消息等)。它在.nuspec使用 NuGet,因此您仍然可以将它与.nuspec文件一起使用。

You can pass specific properties into the NuGet CLI, including "NoWarn":您可以将特定属性传递到 NuGet CLI,包括“NoWarn”:

nuget.exe pack package.nuspec -Properties NoWarn=NU5104

https://docs.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-pack#suppressing-pack-warnings https://docs.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-pack#suppressing-pack-warnings

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

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