13

I have two projects in my solution. I am currently using the default configuration mode which is 'Debug'. When I want to do a 'Release' build, I switch to Release-mode and then I see all my previous projects properties are set to default, meaning I have to add all properties again manually to this mode.

Is there a convenient way to solve this in VS2010, for example to copy all properties like include paths, preprocessor macros, build macros, etc from 'Debug' to 'Release' mode?

KaiserJohaan
  • 9,028
  • 20
  • 112
  • 199

4 Answers4

13

Configuration settings are stored in .vcproj / .vcxproj file. You could open it in some text editor and copy some settings manually, but it wouldn't be convenient. For now you could just open projects properties and copy these settings while switching Debug / Release configuration in the upper left corner of that window.

Next time when you are setting properties that are intended to be the same for all configurations, choose Configuration: All Configurations to avoid troubles.

LihO
  • 41,190
  • 11
  • 99
  • 167
5

Property sheets can solve this and a few other property-related issues with ease.

In short, all the properties in a project are just nodes in an XML document, and the property group nodes can have a condition attribute. They're easy to change in any text editor, but a lesser-known feature is the ability to import other XML documents, which can provide settings (for all but a few project-specific ones).

This blog post has a good tutorial on using project sheets, and some more info in this question. You can create them in Visual Studio, edit them (including copying your existing project settings over), then attach them to your project with the property manager (not the property window).

The groups in your property sheet use the same syntax as regular settings, and can be set for all configurations or filtered to only apply on some. They can also be filtered by project name and a few other things, using VS' variable and condition system. For example, I use:

<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
  <ClCompile>
    <WarningLevel>Level4</WarningLevel>
    <TreatWarningAsError>true</TreatWarningAsError>
    <Optimization>Disabled</Optimization>
    <EnablePREfast>true</EnablePREfast>
    <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
  </ClCompile>
</ItemDefinitionGroup> 

for some of my builds, to apply the same settings to all project (full file here).

One of the most convenient uses is giving the build directory in the file, so all your projects build uniformly into the same directory (make sure to use the project name for the output).

Community
  • 1
  • 1
ssube
  • 47,010
  • 7
  • 103
  • 140
1

Managing almost all the properties across multiple different builds (debug, release, win32, x64 etc.) can be accomplished with a single collection of settings by using Macros.

Thus, before editing a project settings, make sure you've set Configurations to All Configurations and, Platform: to All Platforms. Now almost all settings can be done in this way, across all the different configurations. Say, you want different configurations and platforms to use different versions of various libraries. Assuming you are using a naming convention that's consistent across all projects, you can then use:

Additional Library Directories: ..\..\foo\bar\lib\$(Platform)_$(Configuration)

You can see what macros will expand to, by hitting the edit button, and then clicking on the Macros>> button.

John
  • 5,735
  • 3
  • 46
  • 62
0

You could also recreate the new mode you want using the configuration manager and then you can choose from which configuration you want to copy all the settings.

Ashwani Mehlem
  • 125
  • 1
  • 7