简体   繁体   中英

Suppress warning output from Nuget.exe

I'm wondering if I can suppress warning messages in the output from the nuget.exe pack command? 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. 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:

<?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. 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).

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. 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. 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.

TIA for any input.

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:

Display this amount of details in the output: normal, quiet, (v2.5) detailed.

Try packing your project file instead of .nuspec file if possible, use lowercase for quiet flag and use -NoPackageAnalysis :

nuget pack myproject.proj -Verbosity quiet -NoPackageAnalysis

The -nopackageanalysis flag will suppress the warning, even when using a .nuspec file.

You might also consider using Octopack , if it's an option. 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.

You can pass specific properties into the NuGet CLI, including "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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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