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. The application will not build successfully unless you fix the error list appearing on your output window. However, if there are no errors and few warning messages, the compiler ignores warning messages and successfully builds the application. It is also observed that the majority of the developers avoid warning messages during their coding. These warning messages start accumulating over the period as the project grows, which makes your code ugly.


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

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, the developer ignores them 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 are treated as errors.


– Article ends here –

If you have any questions, please feel free to share your questions or comments on the comment box below.

Share this:
We will be happy to hear your thoughts

      Leave a reply

      www.troubleshootyourself.com
      Logo