How to treat Warning as Error in Visual Studio during build


Visual Studio shows a build results in three groups in output window that usually appears in bottom of the IDE. They are Errors, Warnings, Messages. The build will fail if there any error appeared in the code during code building activity. Application will not build successfully unless you fix the error list which is appearing on your output window. But, in case if there are no errors and few warning messages, then compiler ignore warning messages and build the application successfully. Its observed that majority of the developers avoid  warning messages during their coding. These warning messages starts accumulating over the period as project grows which makes your code ugly.

Inorder to keep your code clean, you must consider warning messages to be clear by fixing them safely. Since, warning messages do not harm build activity they have been ignored most of the time. In this situation, we must have some mandatory mechanism to consider warning messages as errors.

Visual Studio provides configuration settings where you can set warning messages as error. In this case all warning messages treated as errors and this makes developer to fix warning messages to make build successful. In Visual Studio IDE follow the below steps in order to treat warning messages as error.

  • Right click on the project you want to enable this on.
  • Select the “Build” tab.
  • Change “Treat warnings as errors” to “All”.

After this configuration update, all warning messages treated as errors.

– Article ends here –

Related Tags:

Share this:

We will be happy to hear your thoughts

Leave a reply