Is it possible to suppress the build warnings which are output when dotnet run
causes a build to occur, e.g. after a code change?
$ dotnet run --verbosity quiet
/../MyProgram.cs(6,21): warning CS8618: Non-nullable property
'MyProperty' must contain a non-null value when exiting
constructor. Consider declaring the property as nullable.
<My Program Output>
This is painful, as during development I will pipe my program output into another tool, and the build warning output breaks the parsing of that tool. I don't want to disable any particular warnings; I want to simply omit them from the output of dotnet run
.
CodePudding user response:
$ dotnet run --property WarningLevel=0
--property:<NAME>=<VALUE>
to pass properties to MSBuild (https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-run)WarningLevel=[0,1,2,3,4]
to configure the level of warnings to be output where4
is the default and0
disables all warnings (https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/errors-warnings)