Reputation: 3311
I've set various C# Code Style rules to generate errors, and while violations show up as errors in the IDE (both in the error list and the text editor), actual builds still succeed.
Can anyone confirm this? I've tested on VisualStudio/15.0.0+26228.9 under both the Community (at home) and Enterprise (at work) editions. And I can't get any build to break due to a code style violation.
I've even tried to use .editorconfig, and builds still go through...
Upvotes: 21
Views: 4227
Reputation: 2151
Update:
This has not been implemented yet. This is now tracked as a project on GitHub at: https://github.com/dotnet/roslyn/projects/18 - check there for updates.
Original response:
I've opened a VS question on this at: https://developercommunity.visualstudio.com/content/problem/48804/editorconfig-with-rules-set-to-error-produces-erro.html that will hopefully provide some answers on why errors coming from the new .editorconfig support in VS2017 do not fail builds.
Upvotes: 14
Reputation: 53610
You're looking for the Treat warnings as errors option. You can find it by right-clicking on the project and choosing Properties -> Build:
Switch it from None to All to make all code style warnings (and any other warnings) break the build.
If you're working on a .NET Core project, you can edit the csproj file directly and add the TreatWarningsAsErrors
property:
<PropertyGroup>
<!-- ... other stuff -->
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
Upvotes: -3