I found this Gem, which would be exactly what I need:
To build one project for multiple configurations when building just a single sln configuration without duplicating the project files:
Importing project is such manner works for me in Visual Studio 2010:
TestProject64.vcxproj <== the wrapper project
<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="TestProject.vcxproj" /> *<== the wrapped project* <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Release|x64"> *<== just needed by VS* <Configuration>Release</Configuration> <Platform>x64</Platform> </ProjectConfiguration> </ItemGroup> <PropertyGroup Label="Globals"> <ProjectGuid>{B7D61F1C-B413-4768-8BDB-31FD464AD053}</ProjectGuid> </PropertyGroup> </Project>
TestProject64.vcxproj.filters
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="TestProject.vcxproj.filters" /> </Project>
TestProject.vcxproj has two configurations defined inside: Release|x86 and Release|x64. As you can see TestProject64.vcxproj has only Release|x64 configuration. Defining of at least one configuration in TestProject64.vcxproj is necessary, otherwise Visual Studio will not be able to add TestProject64.vcxproj to a solution.
Now it's possible to include both TestProject.vcxproj and TestProject64.vcxproj to the same solution and build Release|x86 and Release|x64 at the same time.
The question now is whether all Visual Studio Versions 2010 - 2015+ will handle this well:
- Will VS try to edit/normalize the wrapper project somehow?
- Will there be any weird behaviour when opening the project properties?
- Will there be unexpected behaviour when building from the IDE vs. MSBUILD on the command line?
Bottom line: Is this something that can be deployed in a production team without major headaches down the road?
Use case (just anyone is interested):
- X.sln
- proj_cpp_dll ... C++ DLL can be built in 64 and 32 bit
- proj_exe1_x64 ... needs the DLL in the 64bit version
- proj_exe2_Win32 ... needs the DLL in the 32 bit version
One build pass via Release|Any CPU
(or Release|Mixed Platforms
) must (should) be enough to build this.