4

I have prepared my .editorconfig file which I want to use on multiple Git repositories. Each repository holds a Visual Studio solution (C#). My first thought was to put the .editorconfig file in its own repository and then include it in all "solution repositories" as submodule. The problem however: The submodule will be in a subfolder. The contained .editorconfig will thus not be applied to the whole project/solution (but only to the subfolder and its children). It seems to me that I cannot specify a path to my solution-wide .editorconfig in the solution configuration file (.sln), either.

What is the best approach to actually share a single .editorconfig file between multiple Git repositories? The .editorconfig file still needs to be version controlled (and thus shared between users), ie. no local editorconfig configuration.

4

1 回答 1

6

我自己找到了一个解决方案,使用共享存储库作为我想要的子模块:这是一个符号链接!

例如,如果您的子模块被调用Global,请进入解决方案的根目录并通过以下方式创建指向子文件夹中真实文件的符号链接Global

mklink .editorconfig .\Global\.editorconfig

可以像任何其他文件一样提交和推送此链接。Gitea(我用作服务器)甚至显示一个小箭头作为文件符号的叠加层。显然它知道它只是一个符号链接。当我在 Windows 机器上克隆此存储库时,符号链接按预期工作。也许它甚至适用于 *nix 系统;不过我没有尝试。

我撤回了这个解决方案:VS2017 (15.8.2) 不会立即接受更改。必须关闭并重新打开解决方案。如果您使用的是真实.editorconfig文件,则从 15.8 Preview 3 开始会立即检测到更改

编辑:我们决定不提交到 Git 的符号链接,因为它曾经被 Gitea 搞砸了(可能是一个错误)并且因为我们有非 Windows 开发系统。相反,我们的项目文件中有一个“后克隆脚本”和一个条件错误<Error Condition="!Exists('$(SolutionDir).editorconfig')" Text=".editorconfig is missing. Please run $(SolutionDir)_post_clone_script.bat first." />

于 2018-09-05T15:57:36.087 回答