Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 997
wbj Avatar asked Apr 01 '16 19:04

wbj


People also ask

How do I turn off warnings in Visual Studio?

Use a preprocessor directive Use a #pragma warning (C#) or Disable (Visual Basic) directive to suppress the warning for only a specific line of code.

How do I ignore errors in Visual Studio?

To ignore all errors in the current filePress Alt+Enter. From the pop-up menu, select Ignore All Errors in This File.

What does NuGet EXE do?

The NuGet Command Line Interface (CLI), nuget.exe , provides the full extent of NuGet functionality to install, create, publish, and manage packages without making any changes to project files.


1 Answers

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

like image 171
themilkyninja Avatar answered Feb 22 '23 22:02

themilkyninja