Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 为整个团队设置Visual Studio格式选项_Visual Studio_Code Formatting - Fatal编程技术网

Visual studio 为整个团队设置Visual Studio格式选项

Visual studio 为整个团队设置Visual Studio格式选项,visual-studio,code-formatting,Visual Studio,Code Formatting,我们团队中不同的开发人员在这里有完全不同的复选框: 因此,VisualStudio不断地重新格式化代码,这确实污染了我们的提交 我想要的是在每个开发人员的计算机上运行一个单独的whatever(.reg文件或其他东西),以便这些设置保持一致 如何执行此操作?您可以使用“导入和导出设置”选项从“工具”菜单中的一个visual studio实例导出所需的设置。这将把设置保存到一个.vssettings文件(实际上是一个xml文件)中,其中包含如下内容 <PropertyValue name=

我们团队中不同的开发人员在这里有完全不同的复选框:

因此,VisualStudio不断地重新格式化代码,这确实污染了我们的提交

我想要的是在每个开发人员的计算机上运行一个单独的whatever(
.reg
文件或其他东西),以便这些设置保持一致


如何执行此操作?

您可以使用“导入和导出设置”选项从“工具”菜单中的一个visual studio实例导出所需的设置。这将把设置保存到一个.vssettings文件(实际上是一个xml文件)中,其中包含如下内容

<PropertyValue name="TabSize">4</PropertyValue>
4
然后,您可以通过用户界面(相同的菜单选项)在其他机器上导入这些设置,也可以使用从命令行加载这些设置

devenv.exe /Resetsettings <your settingsfile>
devenv.exe/Resetsettings
此命令行设置从VS2017开始记录,并允许覆盖本地首选项。将它放在项目解决方案的根目录下(甚至更高),置于源代码控制之下,以便将它与源代码一起分发给每个开发人员

您可以通过VS(从v15.3开始)特定的属性设置.Net编码约定,并记录在案

示例文件:

root = true

[*]
end_of_line = CRLF
insert_final_newline = true

[*.cs]
indent_style = tab
dotnet_sort_system_directives_first = true
csharp_space_after_cast = true

[*.xsd]
indent_style = tab

[*.json]
indent_style = space
indent_size = 2

[*.xml]
indent_style = space
indent_size = 2

[*.cshtml]
indent_style = space
indent_size = 4
对于VS2017,实验性扩展具有生成编辑器配置文件的功能,有关更多信息,请参阅此


从VS2019开始,VS可以从(右键单击项目>添加>新建editorconfig)或从(工具>选项>文本编辑器>[C#或基本]>代码样式>常规)创建editorconfig文件。

相关:在Visual Studio 2013中,这不会导出Anton在屏幕截图中显示的格式设置。在VS2102导出中“所有设置/选项/文本编辑器/C#编辑器“是否导出这些设置,例如1Same for VS2013您可以准确指定导出的内容和未导出的内容。是否有方法根据我当前的设置自动导出。editorconfig?”?手工操作,查找每一处房产都需要几个小时。问得好。我在这里加了一个建议,你可以投赞成票。我也认为,如果能够从当前选项中导出clang或editor.config文件,而不是试图手动重新创建整个配置文件,那就太好了。它似乎从7月份就可以使用了,请看我在回答中添加的最后一句话。