I have multiple occurences of analyzers rulesets, which I run with CodeAnalysisRuleSet
. Some are automatically injected companywide (via a props-File in a referenced nuget package), but there are a few occasions where I want to override a few rules for my specific solution or project.
Using only the injected ruleset, works as expected. Using only the solution ruleset works. But when using both, only the injected works, the other is ignored. Even rules that are exclusive to the solution ruleset are ignored.
Can I somehow merge two rulesets, without referencing both in one parentfile? Because it is a nuget package, I can't use Include, as the nugetfiles are in some cached folder...
Edit 1:
I also tried to use Include in the nuget packagefile, but the path can't handle MSBuilds well known paths (like MSBuildProjectDirectory or so)
CodePudding user response:
I figured it out: I added the imported ruleset into Directory.build.props and overwritting ruleset in the Directory.build.targets.
It is important to add a full ruleset file, not only the delta, as it is not merged.
Also be sure to clean the solution and close/reopen visual studio. Changes do not take effect immediatly (at least with VS 2022)