user69453
user69453

Reputation: 1405

MSBuild Shorten Configuration Managment In vcxproj-Files

In the *.vcxproj files of this project there is a lot of code in like this

<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
  [do some stuff]
</ImportGroup>

for all configurations, 'Debug|Win32', 'Release|Win32', 'Debug|x64', 'Release|x64'. But I will have the same configuration for all combinations, therefore I do not want to write it 4 times making my project file 3 times longer and less readable .

Is there a shortcut like Condition="'$(Configuration)|$(Platform)'=='Any Configuration|Any Architecture'?

Upvotes: 0

Views: 57

Answers (2)

stijn
stijn

Reputation: 35901

The standard way of doing this would be using 'property sheets'; more concrete: one property sheet with the common options which gets imported by all platform/configuration combinations. Some reasons to choose this approach:

  • it exactly addresses your "I will have the same configuration for all combinations, therefore I do not want to write it 4 times making my project file 3 times longer and less readable" requirement, and more: it keeps the common options in one single file, which can also be resued by other projects (which is really the number 1 selling point if you have multiple projects and want the same options for them)
  • it has user interface support for editing (though it's no problem if you'd want to manually edit the vcxproj to add it)
  • it keeps the standard project structure intact, so still allows for per-configuration and per-platform modifications should you need those
  • property sheets are just msbuild files like any other and as such can Import other files so you can create hierarchies with them, do things like having one master file which based on application type (exe/dll) sets different output paths and so on

Upvotes: 1

Emiel Koning
Emiel Koning

Reputation: 4225

You can remove the Condition attribute and have the ImportGroup being applied for every configuration.

Upvotes: 1

Related Questions