How to suppress specific MSBuild warning

Viewed 62811

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.

7 Answers

According to this thread in the MSDN Forum MSBuild warnings can't be suppressed.

Alternative: Add this to .csproj.

<PropertyGroup>
  <NoWarn>$(NoWarn);MSB3253</NoWarn>
</PropertyGroup>

At the time of this post (2021), Microsoft docs recommend DisabledWarnings, this worked for me:

<PropertyGroup>
    <DisabledWarnings>3568</DisabledWarnings>
</PropertyGroup>

Note that the "MS" prefix is omitted

Related