简体   繁体   English

是否可以从另一个设置文件中“继承”Resharper设置文件?

[英]Is it possible to have a Resharper settings file 'inherit' from another settings file?

We have a variety of Visual Studio 2008 and Visual Studio 2012 solutions in our team. 我们团队中有各种Visual Studio 2008和Visual Studio 2012解决方案。 VS08 is being used for legacy reasons, mainly because Smart Device projects are unsupported beyond that version of VS. VS08由于遗留原因而被使用,主要是因为除了该版本的VS之外不支持智能设备项目。

We are currently using a single Resharper .DotSettings file and sharing it across every VS2012 solution via a layer in the Team Shared Solution Settings for each solution. 我们目前正在使用单个Resharper .DotSettings文件,并通过每个解决方案的团队共享解决方案设置中的一个层在每个VS2012解决方案中共享它。 This works wonders at the moment, though we would like to also use the "same" settings on our VS08 solutions. 虽然我们想在VS08解决方案上使用“相同”的设置,但这在目前仍然有效。

The catch here is that there is a very small subset of rules that were created specifically for .Net4 projects in this common .DotSettings file, and those should not be visible to the .Net2 VS08 projects. 这里的问题是,在这个常见的.DotSettings文件中专门为.Net4项目创建了一小部分规则,而这些规则不应该对.Net2 VS08项目可见。 For instance, there is a custom rule in it that suggests converting argument validation code with exceptions to Contract.Requires<TException> calls. 例如,其中有一个自定义规则建议将参数验证代码转换为Contract.Requires<TException>调用的异常。

Ideally there should be a way to make a 'base' settings file, which would be used across every VS08 solution, and an 'inherited' settings, containing every setting in the base file plus the additional rules specific to the VS12 solutions. 理想情况下,应该有一种方法可以创建一个“基础”设置文件,该文件将用于每个VS08解决方案,以及一个“继承”设置,包含基本文件中的每个设置以及特定于VS12解决方案的其他规则。 Updating the base file should also make every solution using the inherited file to update that setting. 更新基本文件还应使每个使用继承文件的解决方案更新该设置。

Is there a way to properly handle this while avoiding multiple clones of the same file and at the same time keeping the capability of autoupdating every solution's settings upon editing one of the settings files? 有没有办法正确处理这个,同时避免同一文件的多个克隆,同时保持在编辑其中一个设置文件时自动更新每个解决方案的设置的能力?

I think that creating two files (one with the general settings and another with only the .Net4 additions) could work. 我认为创建两个文件(一个具有常规设置,另一个仅添加.Net4)可以正常工作。 In that case, both files would be included as layers on every VS12 solution, but only the former on the VS08 solutions. 在这种情况下,两个文件都将作为层包含在每个VS12解决方案中,但只包括VS08解决方案中的前者。 I'm not sure this is the best approach in this case though, and would like to hear other possible options, as we would prefer to keep only one layer set on every solution, since this seems more easily maintainable. 我不确定这是这种情况下的最佳方法,并且希望听到其他可能的选项,因为我们希望在每个解决方案上只保留一个层,因为这似乎更容易维护。

We're using the latest version of Resharper, currently v7.1.1000.900. 我们使用的是最新版本的Resharper,目前为v7.1.1000.900。

You can create a settings file that overrides some of the settings from the main settings file. 您可以创建一个设置文件,覆盖主设置文件中的某些设置。 Here is how to do it: 这是怎么做的:

  1. Make sure that all your main settings are in a custom settings file and all settings layers above it are empty. 确保所有主要设置都在自定义设置文件中,并且其上方的所有设置图层都为空。
  2. Create an empty file for additional settings and put it above the main settings file. 为其他设置创建一个空文件,并将其放在主设置文件上方。
  3. Now both settings files should be under the team-shared layer, one above the other, in the Setting Layers dialog box . 现在,两个设置文件应位于团队共享层下,一个在另一个之上,在“ 设置图层”对话框中
  4. Open a solution and make sure that the settings from the main settings file apply. 打开解决方案并确保应用主设置文件中的设置。
  5. Make necessary modifications to the settings and save them to the additional settings file using Save To . 对设置进行必要的修改,并使用“ 保存到”将其保存到其他设置文件中。

To better understand how settings layers work, check out this post . 要更好地了解设置图层的工作方式,请查看此文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有什么方法可以从子程序集继承.config文件中的设置? - Is there any way to inherit settings in the .config file from a subassembly? <appSettings />是否可以包含设置并引用另一个文件中的另一个<appSettings />部分? - Is it possible for <appSettings /> to contain settings AND refer to another <appSettings /> section in a different file? 如何让.NET库从请求的应用程序继承其配置文件设置? - How do I get my .NET library to inherit its configuration file settings from the requested app? 如何在C#中的另一个文件中备份/还原用户设置 - Howto backup / restore user Settings to / from another file in c# 是否可能有一个文件exe.settings,其值将适合于msi的安装文件夹? - Is it possible to have a file exe.settings whose values will adapt to the installation folder of the msi? 某些 ReSharper 设置不可见 - Some of ReSharper settings not visible C#:从文件导入/导出设置 - C#: Import/Export Settings into/from a File WCF channelfactory与配置文件中的设置? - WCF channelfactory with settings from the config file? 如何从配置文件加载统一设置? - How to load unity settings from config file? 更改设置文件的位置 - changing the location of the settings file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM