gpt4 book ai didi

c# - "CS8700: Multiple analyzer config files cannot be in the same directory"但只有一个 StyleCop 文件

转载 作者:行者123 更新时间:2023-12-04 01:23:22 28 4
gpt4 key购买 nike

我正在尝试学习在个人项目中使用 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 中的错误什么也没做。单独搜索错误时,我也找不到任何有用的文档。

最佳答案

原来问题是试图引用 .editorconfig来自项目的文件。我删除了引用,并将文件作为解决方案根目录中的解决方案项保留。我从那里开始工作的大多数设置都很好,但是我有一些 StyleCop 严重性设置没有被分析器正确选择。

为了解决这个问题,我改为使用 GlobalSuppressions.cs每个项目的单独文件。我可能可以将这些捆绑在一起并引用它们,就像我对 stylecop.json 所做的那样文件,但决定限制抑制范围可能更合适。

关于c# - "CS8700: Multiple analyzer config files cannot be in the same directory"但只有一个 StyleCop 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62274932/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com