Reputation: 127
I just joined a company with legacy code. The build has over 10000 warnings. 90% of the warnings are "obsolete" warnings. My coworkers don't want me to disable those warnings, because it is useful for them in IntelliSense.
My question is: is there a practical way, where I can still see the warning in the editor in Visual Studio, but it does not show up in the build.log?
Upvotes: 1
Views: 2765
Reputation: 76760
Is there a practical way, where i can still see the warning in the editor in visual studio, but it does not show up in the build.log?
Since you can not disable those warnings and using #pragma warning disable
is not your option, I would like provide your a workaround to resolve this question.
You can managed to supress the warning level with /p:WarningLevel=X
with MSBuild command line.
For example, when I build the sample project from Visual Studio, there is a warining in the error list window:
Then I build it with MSBuild command line with property /p:WarningLevel=0
in the command line:
msbuild "YourProjectName" /fl /flp:logfile=D:\MyProjectOutput.log;verbosity=diagnostic /p:WarningLevel=0
The meaning of the level:
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
There is no warining in the build log, then open the log file, there is also no warning here:
Hope this helps.
Upvotes: 1
Reputation: 1729
Some basic SWDev logic here:
If a warning is useful, then it should be fixed as a bug (perhaps a minor one) would be. If a warning isn't useful, then it should be suppressed to keep the build clean, so that useful warnings show up.
Ultimately, with project schedules and management pressure, there may be no way to get technical debt like that reduced to the point where it is manageable. But disabling a correct and useful warning is a very bad idea (especially suppressing an obsolete warning - the next upgrade of the associated component will cause the product to stop working, with an unexpected amount of work to fix it).
What we typically used to do with these sorts of things, where I worked, was get them prioritised as a task on the development schedule - we'd have a meeting, decide on which issues were significant (which warnings to go after, which to suppress etc...), and batch them into a number of tasks, with an appropriate prioritisation.
Upvotes: 0
Reputation: 710
I think you will need to switch between the build configurations "Debug" and "Release". So you will be able to have a "clean" build.log when compiling the "Release" but still have the warnings when working with a "Debug" build:
And when working yourself you just need to uncheck the warnings in the error list panel:
Upvotes: 0