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. however, in case if there are no errors and few warning messages, then compiler ignore warning messages and build the application successfully. It is also 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.


How to treat Warning as Error in Visual Studio during build:

In order 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.

treat Warning as Error

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”.

treat Warning as Error

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


– Article ends here –

Recommended:   Visual Studio C# Code Snippets Overview
Share this:

Kiran is a Software engineer by profession and Enthusiastic blogger, love to write articles on computer technology and programming. Reach him at kiran.troubleshootyourself@gmail.com.

We will be happy to hear your thoughts

Leave a reply

Troubleshootyourself
Logo
Shopping cart