Our team uses the Code Analysis feature with a custom ruleset to cause our build to fail if we forget to do things like null checks on method arguments.
However, now
Normally, the only thing you need to do is install the Microsoft.CodeAnalysis.FxCopAnalyzers nuget on your project.
But as mentioned correctly, this does not work, especially for .Net Core (currently in vs2017).
In order to work for aspnet core projects, as well, and resolve the error:
"Could not identify platform for ..."
Manually modify the project's csproj file and make sure to not insert the RunCodeAnalysis
tag. Make the PropertyGroup like that:
netcoreapp2.2
..\MyStylecop.ruleset
Also, if you need to put a given ruleset file, make sure to place it to the correct path, as seen above ..\MyStylecop.ruleset
. MyStylecop.ruleset is the file with the rules (actually the ones suppresed I think - so it is inverse logic).
For example my ruleset file is: