Skip to content

Commit a4389a1

Browse files
committed
Add documentation on treating warnings as errors in MSBuild
1 parent 7c85d63 commit a4389a1

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

docs/content/getting-started/MSBuild.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,15 @@ However, the `FSharpAnalyzerAfterBuild` target might be skipped if the `CoreComp
221221
</PropertyGroup>
222222
```
223223

224+
### Treating Warnings as Errors
225+
226+
You can use the standard [WarningsAsErrors](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/errors-warnings#warningsaserrors-and-warningsnotaserrors) MSBuild property to treat specific warnings as errors. For example, to treat all warnings from the `OptionAnalyzer` (OV001) as errors, you can add the following to your project file:
227+
228+
```xml
229+
<PropertyGroup>
230+
<WarningsAsErrors>OV001</WarningsAsErrors>
231+
</PropertyGroup>
232+
```
233+
234+
224235
[Next]({{fsdocs-next-page-link}})

samples/MsBuildExample/MsBuildExample.fsproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
<FSharpAnalyzersExe>../../artifacts/bin/FSharp.Analyzers.Cli/debug/FSharp.Analyzers.Cli.dll</FSharpAnalyzersExe>
1111
<!-- Uncomment to always run the analyzer after a build, even if CoreCompile did not run -->
1212
<!-- <FSharpAnalyzersAlwaysRunAfterBuild>true</FSharpAnalyzersAlwaysRunAfterBuild> -->
13+
<!-- Uncomment to Treat OV001 (OptionAnalyzer) warnings as errors -->
14+
<!-- <WarningsAsErrors>OV001</WarningsAsErrors> -->
1315
</PropertyGroup>
1416

1517
<PropertyGroup>

0 commit comments

Comments
 (0)