Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodeAnalysisRuleSetDirectories not respected #52915

Open
6bee opened this issue Apr 22, 2021 · 2 comments
Open

CodeAnalysisRuleSetDirectories not respected #52915

6bee opened this issue Apr 22, 2021 · 2 comments

Comments

@6bee
Copy link

6bee commented Apr 22, 2021

Background

We're using a nuget package to distribute code analysis rule set (.ruleset) file as a default within our enterprise. In order to replace
or extend this default rule set, CodeAnalysisRuleSet property may be set on .csproj level to point to a custom .ruleset file.
One rule set file may include a number of other rule set files using Include element. However, included rule set files would not get resolved unless specified with their full path.

Issue

Specifying the directory of a .ruleset file via CodeAnalysisRuleSetDirectories property should allow setting the file name only in //RuleSet/Include/@path rather than full path. However, neither setting CodeAnalysisRuleSetDirectories in a nuget package props file nor in the csproj directly seems to work as expected, i.e. corresponding .ruleset files would not be resolved by VS/msbuild.

MyProject.csproj

<PropertyGroup>  
  <CodeAnalysisRuleSetDirectories>$(CodeAnalysisRuleSetDirectories);C:\nuget-package-location\rulesets\</CodeAnalysisRuleSetDirectories>
  <CodeAnalysisRuleSet>Style.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

Style.ruleset

<RuleSet Name="local project rules" Description=" " ToolsVersion="16.0">
  <Include Path="enterprise.ruleset" Action="Default" />
  ...
</RuleSet>

Expected Behavior

File C:\nuget-package-location\rulesets\enterprise.ruleset gets resolved by setting CodeAnalysisRuleSetDirectories property to C:\nuget-package-location\rulesets\ in MyProject.csproj and setting //RuleSet/Include/@path="enterprise.ruleset" in Style.ruleset.

Environment

Visual Studio Professional 2019 16.9.4
Windows 10 Pro 20H2

@rainersigwald
Copy link
Member

I believe this is a feature request for Roslyn's implementation of rulesets; AFAIK code in the MSBuild repo only finds the entry-point ruleset.

@rainersigwald rainersigwald transferred this issue from dotnet/msbuild Apr 26, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 26, 2021
@jinujoseph jinujoseph added Feature Request and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 28, 2021
@jinujoseph jinujoseph added this to the Backlog milestone Apr 28, 2021
@jinujoseph
Copy link
Contributor

cc @mavasani

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants