Permalink
Fetching contributors…
Cannot retrieve contributors at this time
74 lines (59 sloc) 2.35 KB
title ms.date ms.prod ms.technology ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author translation.priority.ht
-warnaserror (C# Compiler Options)
2015-07-20
.net
devlang-csharp
article
/warnaserror
CSharp
/warnaserror compiler option [C#]
-warnaserror compiler option [C#]
warnaserror compiler option [C#]
04680ec3-08d6-4e2e-a274-38310e10e33c
15
BillWagner
wiwagn
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

/warnaserror (C# Compiler Options)

The /warnaserror+ option treats all warnings as errors

Syntax

/warnaserror[<U>+</U> | -][:warning-list]  

Remarks

Any messages that would ordinarily be reported as warnings are instead reported as errors, and the build process is halted (no output files are built).

By default, /warnaserror- is in effect, which causes warnings to not prevent the generation of an output file. /warnaserror, which is the same as /warnaserror+, causes warnings to be treated as errors.

Optionally, if you want only a few specific warnings to be treated as errors, you may specify a comma-separated list of warning numbers to treat as errors.

Use /warn to specify the level of warnings that you want the compiler to display. Use /nowarn to disable certain warnings.

To set this compiler option in the Visual Studio development environment

  1. Open the project's Properties page.

  2. Click the Build property page.

  3. Modify the Treat Warnings As Errors property.

    To set this compiler option programmatically, see xref:VSLangProj80.CSharpProjectConfigurationProperties3.TreatWarningsAsErrors%2A.

Example

Compile in.cs and have the compiler display no warnings:

csc /warnaserror in.cs  
csc /warnaserror:642,649,652 in.cs  

See Also

C# Compiler Options
Managing Project and Solution Properties