“ CS8700:多个分析器配置文件不能位于同一目录中,而只能包含一个StyleCop文件

问题描述 投票:0回答:1

我正在尝试学习在个人项目上使用StyleCop。它不是很大,解决方案的结构如下:

- MySolution (2 of 2 projects)
   - Solution Items
      - .editorconfig
      - .gitignore
      - CODEOWNERS
      - my-pipeline-workflow.yml
      - README.md
      - stylecop.json
   - MyMainProject
      - Dependencies
      - .editorconfig (pointer Solution Items copy)
      - OneOfManyCsFiles.cs
      - stylecop.json (pointer Solution Items copy)
   - MyTestProject
      - Dependencies
      - .editorconfig (pointer Solution Items copy)
      - OneOfManyTestCsFiles.cs
      - stylecop.json (pointer Solution Items copy)

这是文件夹本身的结构:

- RepoFolder
   - .github
      - workflows
         - my-pipeline-workflow.yml
   - src
      - MyMainProject.csproj
      - OneOfManyCsFiles.cs
   - test
      - MyTestProject.csproj
      - OneOfManyTestCsFiles.cs
   - .editorconfig
   - .gitignore
   - CODEOWNERS
   - MySolution.sln
   - README.md
   - stylecop.json

在为StyleCop添加文件之前,一切正常。我可以在Visual Studio中进行构建和测试。出于某种原因,为StyleCop添加文件(可能还有.editorconfig文件)似乎在构建时导致了此错误:

CSC: error CS8700: Multiple analyzer config files cannot be in the same directory ('/home/runner/work/MySolution/MySolution').
[/home/runner/work/MySolution/MySolution/src/MyMainProject.csproj]

据我了解,StyleCop文件是唯一的分析器文件,并且在多个地方引用了它。 .editorconfig是否以某种方式算作另一个分析器文件?如果是这样,我该如何让他们表现出色?

抑制.editorconfig中的错误没有任何作用。仅搜索错误时,我也找不到任何有用的文档。

c# build configuration stylecop analyzer
1个回答
0
投票

原来问题是试图从项目中引用.editorconfig文件。我删除了引用,只是将该文件作为解决方案项保留在解决方案的根目录中。我从那里所做的大多数设置都可以正常工作,但是我有一些StyleCop严重性设置无法正确地用于分析仪。

[要解决此问题,我改为为每个项目分别使用GlobalSuppressions.cs文件。我可能可以将它们捆绑在一起,并像使用stylecop.json文件一样引用它们,但决定限制抑制范围可能更合适。

© www.soinside.com 2019 - 2024. All rights reserved.