简体   繁体   English

比较Visual Studio中的配置?

[英]Compare Configurations within Visual Studio?

Actually i come around a problem i get more often into as i like to: 实际上我遇到了一个问题,我经常更喜欢进入:

Consider the following: You just made a new solution/project and start creating/adding all the stuff you need. 请考虑以下事项:您刚刚创建了一个新的解决方案/项目,并开始创建/添加您需要的所有内容。 While you're doing so, you're always on the way within the debug configuration. 当你这样做时,你总是在调试配置中继续前进。 You make changes to your configuration (in C++ projects especially compiler, linker settings) and at the end of the day you just want to swap to release mode to make a final build and what happens?? 您对配置进行了更改(在C ++项目中,特别是编译器,链接器设置),并且在一天结束时,您只想交换到发布模式以进行最终构建,会发生什么? You got plenty of error messages about missing defines, linked libraries, preprocessor definitions, precompiled headers, etc.) 您有大量关于缺少定义,链接库,预处理器定义,预编译头等的错误消息。)

And now? 现在? You open the Project Properties, select each item in the tree view and switch for and back with the combo box of the Configuration at the top left. 打开“项目属性”,在树视图中选择每个项目,然后使用左上角“配置”的组合框切换和返回。

Due to the fact, that both configurations are saved within one file you can't also use a simple Diff-Tool or you have to copy and paste both parts out of the project file into two different files, compare them and merge everything back into the project file. 由于这两个配置都保存在一个文件中,您不能使用简单的Diff-Tool,或者必须将项目文件中的两个部分复制并粘贴到两个不同的文件中,比较它们并将所有内容合并回来项目文件。

Isn't there a better solution to compare different configurations within one project?? 是否有更好的解决方案来比较一个项目中的不同配置?

For what it's worth now, here's how I handle the problem of changing one configuration and forgetting to change the other. 对于现在的价值,这里是我如何处理更改一个配置而忘记更改另一个配置的问题。 This process that I use, however, does have two caveats: 1) it works with VS2010 and above; 但是,我使用的这个过程确实有两个注意事项:1)它适用于VS2010及以上版本; and, 2) I've learned to avoid that problem altogether. 并且,2)我已经学会完全避免这个问题。

First off, I NEVER make changes to the project's property page itself! 首先,我永远不会对项目的属性页面进行更改! They tend to use build conditions that causes this problem in the first place. 他们倾向于使用最初导致此问题的构建条件。 Instead, I always have my "Property Manager" opened beside my "Solution Explorer". 相反,我总是在“解决方案资源管理器”旁边打开我的“物业经理”。

Second, I have several "pre-defined" property sheets in a sub-folder called common.properties that I include from, for instance: 其次,我在一个名为common.properties的子文件夹中有几个“预定义”属性表,例如:

  • my_macros.props - common macro definitions specific to my solution's (read: framework) directory structure. my_macros.props - 特定于我的解决方案(读取:框架)目录结构的常见宏定义。 For example, I have a definition called MY_COMMON_OUTPUT_DIRECTORY that equals $(SolutionDir)bin\\$(Configuration)\\$(ProjectName). 例如,我有一个名为MY_COMMON_OUTPUT_DIRECTORY的定义,它等于$(SolutionDir)bin \\ $(Configuration)\\ $(ProjectName)。

  • my_dox_settings.props - Settings specific to doxygen projects. my_dox_settings.props - 特定于doxygen项目的设置。 Yep, I create a seperate project using doxygen to create my documentation. 是的,我使用doxygen创建了一个单独的项目来创建我的文档。

  • my_test_settings.props - Settings specific for my unit-testing framework. my_test_settings.props - 特定于我的单元测试框架的设置。 Again, a seperate project for unit-tests. 同样,单独测试的单独项目。 Adds a post-build event that runs the compiled executable. 添加运行已编译可执行文件的生成后事件。

  • my_app_settings.props - Default settings for my application's framework. my_app_settings.props - 我的应用程序框架的默认设置。 For instance, it sets the "output directory" to the previously mentioned MY_COMMON_OUTPUT_DIRECTORY. 例如,它将“输出目录”设置为前面提到的MY_COMMON_OUTPUT_DIRECTORY。

  • my_app_settings_use_pch.props - Additional changes to my application's framework that uses precompiled-headers. my_app_settings_use_pch.props - 对使用预编译头的应用程序框架的其他更改。 It simply adds a /DI_WANT_MY_PCH compiler switch. 它只是添加了一个/ DI_WANT_MY_PCH编译器开关。

  • include_boost_files.props - Settings for adding the boost-libraries to my projects. include_boost_files.props - 将boost-libraries添加到我的项目的设置。

  • include_ogre_files.props - Settings for adding ogre-libraries to my projects. include_ogre_files.props - 将ogre-libraries添加到我的项目的设置。
  • include_sdl_file.props - Setting for adding sdl-libraries to my projects. include_sdl_file.props - 为我的项目添加sdl-libraries的设置。

  • You should be getting the idea... 你应该得到这个想法......

Next, I create a NEW blank property sheet and add it as well. 接下来,我创建一个新的空白属性表并添加它。 I typically call this $(ProjectName).props [NOTE: be sure to expand the macro yourself] and then add it via the property manager as the very last item. 我通常称之为$(ProjectName).props [注意:一定要自己扩展宏],然后通过属性管理器添加它作为最后一项。

Now, when I need to make a change to the project, I just simply flip over to the property-manager and change the appropriate property-sheet. 现在,当我需要对项目进行更改时,我只需转到属性管理器并更改相应的属性表。 Keep in mind that doing so affects all projects that use that property-sheet. 请记住,这样做会影响使用该属性表的所有项目。 If you only want to affect your current project, then modify the $(ProjectName) property-sheet. 如果您只想影响当前项目,请修改$(ProjectName)属性表。 Unless you build in conditions (which I won't get into), one change affects many configurations (and projects). 除非你构建条件(我不会进入),否则一个更改会影响许多配置(和项目)。

I even check my common.properties directory into source-control. 我甚至将common.properties目录检查为source-control。

I hope this helps, 我希望这有帮助,

I'm not sure when they introduced it, but in VS2015 at-least, you can select "Multiple Configurations..." in the configuration drop-down list on the Property Pages screen. 我不确定他们什么时候推出它,但至少在VS2015中,你可以在Property Pages屏幕的配置下拉列表中选择“Multiple Configurations ...”。 You can then select "All Options" from the various sections, and see which parameters differ (those that differ say ). 然后,您可以从各个部分中选择“所有选项”,并查看哪些参数不同(不同的参数)。 Doesn't show you the actual values - you still have to switch back and forth for that - but at least you can spot the differences quickly. 没有向您显示实际值 - 您仍然需要来回切换 - 但至少您可以快速发现差异。

I don't have a perfect solution to compare within a project file... but for what it's worth, you may find it helpful to compare the current project file to the copy in source control. 我没有在项目文件中进行比较的完美解决方案......但是对于它的价值,您可能会发现将当前项目文件与源代码管理中的副本进行比较会很有帮助。 And then where you see a changed value in one section, you can quickly see whether that value is also changed in the other section. 然后,您在一个部分中看到更改的值,您可以快速查看该值是否也在另一部分中更改。

But your question specified a new project... so I'll assume it isn't in source control yet. 但是你的问题指定了一个新项目...所以我认为它还没有源代码控制。

So here's another option: Copy the project file to another name and then compare the two copies. 所以这是另一个选项:将项目文件复制到另一个名称,然后比较两个副本。 Yes, they'll be the same... but if you use a good tool such as Beyond Compare 2 that allows you to manually align sections then you can right click on the first line of the debug section in the left window and select Align Manually and then right click on the first line of the release section in the right window and select Align Manually. 是的,它们将是相同的......但是如果你使用Beyond Compare 2之类的好工具允许你手动对齐部分,那么你可以右键单击左侧窗口中调试部分的第一行并选择Align手动然后右键单击右侧窗口中发布部分的第一行,然后选择“手动对齐”。 Voila... there are your changes. 瞧...有你的改变。 :) :)

There's a program called BeyondCompare3 that is very cheap. 有一个名为BeyondCompare3的程序非常便宜。 I rarely endorse products, but it should do the job for you here. 我很少赞同产品,但它应该在这里为你做好准备。 Use the "Compare selection to clipboard" option. 使用“比较选择到剪贴板”选项。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM