I'm trying to use custom ruleset file from nuget package. I added given .props to the build folder of the package:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CodeAnalysisRuleSet>MyProject.CodeAnalysis.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
</Project>
After installing nuget package to project I see that rule set file is in the package root folder, the paths are correct:
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\MyProject.CodeAnalysis.3.0.0\build\MyProject.CodeAnalysis.props" Condition="Exists('..\packages\MyProject.CodeAnalysis.3.0.0\build\MyProject.CodeAnalysis.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
But Visual Studio is not seeing correct rule set. When I open active rule set from References -> Analyzers, it's pointing to different file: MinimumRecommendedRules.ruleset. So it's using rules from this file not from my one.
My .nuspec file incldes this code:
<files>
<file src="MyProject.CodeAnalysis.ruleset" target="content/StyleCop" />
<file src="build\**\*.*" target="build" />
</files>
Structure of nuget package in Nuget Package Explorer looks like this:
- build
- MyProject.CodeAnalysis.props
- content
- StyleCop
- MyProject.CodeAnalysis.ruleset
- StyleCop
My configuration is:
- Visual Studio 2019, ver. 16.6.0
- Project Target: .NET Framework v4.7.2
What I do wrong?
P.S. I see this posts, but they didn't help me: