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

时间:2022-09-25 11:50:16

We have a variety of Visual Studio 2008 and Visual Studio 2012 solutions in our team. VS08 is being used for legacy reasons, mainly because Smart Device projects are unsupported beyond that version of VS.

我们团队中有各种Visual Studio 2008和Visual Studio 2012解决方案。 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. This works wonders at the moment, though we would like to also use the "same" settings on our VS08 solutions.

我们目前正在使用单个Resharper .DotSettings文件,并通过每个解决方案的团队共享解决方案设置中的一个层在每个VS2012解决方案*享它。虽然我们想在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. For instance, there is a custom rule in it that suggests converting argument validation code with exceptions to Contract.Requires<TException> calls.

这里的问题是,在这个常见的.DotSettings文件中专门为.Net4项目创建了一小部分规则,而且这些规则不应该对.Net2 VS08项目可见。例如,其中有一个自定义规则建议将参数验证代码转换为Contract.Requires 调用的异常。

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. Updating the base file should also make every solution using the inherited file to update that setting.

理想情况下,应该有一种方法可以创建一个“基础”设置文件,该文件将用于每个VS08解决方案,以及一个“继承”设置,包含基本文件中的每个设置以及特定于VS12解决方案的其他规则。更新基本文件还应使每个使用继承文件的解决方案更新该设置。

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. In that case, both files would be included as layers on every VS12 solution, but only the former on the VS08 solutions. 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.

我认为创建两个文件(一个具有常规设置,另一个仅添加.Net4)可以正常工作。在这种情况下,两个文件都将作为层包含在每个VS12解决方案中,但只包括VS08解决方案中的前者。我不确定这是这种情况下最好的方法,并且希望听到其他可能的选项,因为我们希望在每个解决方案上只保留一层,因为这似乎更容易维护。

We're using the latest version of Resharper, currently v7.1.1000.900.

我们使用的是最新版本的Resharper,目前为v7.1.1000.900。

1 个解决方案

#1


0  

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. 确保所有主要设置都在自定义设置文件中,并且其上方的所有设置图层都为空。

  3. Create an empty file for additional settings and put it above the main settings file.
  4. 为其他设置创建一个空文件,并将其放在主设置文件上方。

  5. Now both settings files should be under the team-shared layer, one above the other, in the Setting Layers dialog box.
  6. 现在,两个设置文件应位于团队共享层下,一个在另一个上面,在“设置图层”对话框中。

  7. Open a solution and make sure that the settings from the main settings file apply.
  8. 打开解决方案并确保应用主设置文件中的设置。

  9. Make necessary modifications to the settings and save them to the additional settings file using Save To.
  10. 使用“保存到”对设置进行必要的修改并将其保存到其他设置文件中。

To better understand how settings layers work, check out this post.

要更好地了解设置图层的工作方式,请查看此文章。

#1


0  

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. 确保所有主要设置都在自定义设置文件中,并且其上方的所有设置图层都为空。

  3. Create an empty file for additional settings and put it above the main settings file.
  4. 为其他设置创建一个空文件,并将其放在主设置文件上方。

  5. Now both settings files should be under the team-shared layer, one above the other, in the Setting Layers dialog box.
  6. 现在,两个设置文件应位于团队共享层下,一个在另一个上面,在“设置图层”对话框中。

  7. Open a solution and make sure that the settings from the main settings file apply.
  8. 打开解决方案并确保应用主设置文件中的设置。

  9. Make necessary modifications to the settings and save them to the additional settings file using Save To.
  10. 使用“保存到”对设置进行必要的修改并将其保存到其他设置文件中。

To better understand how settings layers work, check out this post.

要更好地了解设置图层的工作方式,请查看此文章。