Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to suppress specific MSBuild warning

Is there any way to disable specific MSBuild warning (e.g. MSB3253) when running MSBuild from command line? My build script calls msbuild.exe much the following way:

msbuild.exe MySolution.sln /t:Rebuild /p:Configuration=Release 

I've found out that I can suppress C# warnings (e.g. CS0618) using another parameter for msbuild.exe:

msbuild.exe MySolution.sln /t:Rebuild /p:Configuration=Release /p:NoWarn=0618 

However, this approach doesn't work for MSBuild warnings. Maybe there is another magic property to set?

I'm using .NET 3.5 and VS2008.

like image 650
Andrew Avatar asked Jun 21 '09 13:06

Andrew


People also ask

How do I use specific version of MSBuild?

Use 'where msbuild' to determine where it is loading msbuild from. Use the Visual Studio Command Prompt (2010) shortcut to initialize the path and other environment variables for VS 2010 and MSBuild 4.0. Don't forget, older MSBuild versions are also updated when newer .

How do I ignore warnings in C#?

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

What is MSBuild and do I need it?

MSBuild is a build tool that helps automate the process of creating a software product, including compiling the source code, packaging, testing, deployment and creating documentations. With MSBuild, it is possible to build Visual Studio projects and solutions without the Visual Studio IDE installed.


1 Answers

I've managed to supress the warning level with /p:WarningLevel=X

msbuild.exe MySolution.sln /t:Rebuild /p:WarningLevel=0 /p:Configuration=Release                                       ^^^^^^^^^^^^^^^^^ Warning   Level    Meaning -------- -------------------------------------------       0  Turns off emission of all warning messages.        1  Displays severe warning messages        2  Displays level 1 warnings plus certain, less-severe warnings, such          as warnings about hiding class members        3  Displays level 2 warnings plus certain, less-severe warnings, such           as warnings about expressions that always evaluate to true or false        4  (the default) Displays all level 3 warnings plus informational warnings 
like image 139
Yag Avatar answered Oct 04 '22 23:10

Yag