简体   繁体   中英

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?? 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.

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; and, 2) I've learned to avoid that problem altogether.

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:

  • my_macros.props - common macro definitions specific to my solution's (read: framework) directory structure. For example, I have a definition called MY_COMMON_OUTPUT_DIRECTORY that equals $(SolutionDir)bin\\$(Configuration)\\$(ProjectName).

  • my_dox_settings.props - Settings specific to doxygen projects. Yep, I create a seperate project using doxygen to create my documentation.

  • my_test_settings.props - Settings specific for my unit-testing framework. 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. For instance, it sets the "output directory" to the previously mentioned MY_COMMON_OUTPUT_DIRECTORY.

  • my_app_settings_use_pch.props - Additional changes to my application's framework that uses precompiled-headers. It simply adds a /DI_WANT_MY_PCH compiler switch.

  • include_boost_files.props - Settings for adding the boost-libraries to my projects.

  • include_ogre_files.props - Settings for adding ogre-libraries to my projects.
  • include_sdl_file.props - Setting for adding sdl-libraries to my projects.

  • 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.

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. 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.

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. 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. Voila... there are your changes. :)

There's a program called BeyondCompare3 that is very cheap. I rarely endorse products, but it should do the job for you here. Use the "Compare selection to clipboard" option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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