warnaserror not failing the build with exit 1 if only errors present were warnings
See original GitHub issueWhen there are no errors in a build, but only warnings that have been promoted to error with WarnAsError then the build will not fail with an exit of 1.
$ dotnet build --no-incremental /WarnAsError
...
Build FAILED.
....cs(28,1): error SA1507: Code must not contain multiple blank lines in a row [....csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:01.55
Exit code => 0
Given that there are errors in the build, would expect an exit code of 1
Note that if there are genuine errors in the build, the build will fail correctly with the correct exit code
OS: Linux Ubuntu 18.04 dotnet version: 2.2.3-preview
Issue Analytics
- State:
- Created 4 years ago
- Reactions:13
- Comments:29 (3 by maintainers)
Top Results From Across the Web
How to fetch warnings from the dotnet build command
1 Answer 1 ... What you can do is simply add /WarnAsError to your dotnet build. ... EDIT: OP requested to not fail...
Read more >C# Compiler Options to report errors and warnings
C# Compiler Options for errors and warnings. These options suppress or enable warnings, and control warnings as errors.
Read more >Version History
•When the build process of a project was failing due to missing resources or other resource related problems, then the error list was...
Read more >Nuget restore - system cannot find file - Microsoft.Build. ...
Everytime I try to run Nuget restore I get this error. I get on another server that I am trying to put a...
Read more >Troubleshooting F# | F# for fun and profit
A number of errors can be caused by this, such as “FS0072: Lookup on object of indeterminate type” and “FS0041: A unique overload...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just got it today with .net 6 😦
I thought of a good workaround that I am now using in my application at work.
The behavior I want is to allow warnings on developer machines but treat warnings as errors on our build server. The configuration on a developer machine is
Debug
and the configuration on the build server isRelease
. Therefore, doing this in each project files achieves the behavior that I want.I haven’t noticed this approach exhibiting the bug described in this issue.