Is it possible to move configuration definitions to a property sheet using MSBuild?

I support a fairly large number of projects with 20+ configurations, and some configurations are added from time to time. Spreading such changes across all projects is what we are doing right now with VCBuild. I started experimenting with MSBuild, and there seems to be some kind of logic to extract them into a separate property sheet, allowing you to make changes in one place. How can I do it?

Please note that when I tried to do this, Visual Studio complained that there were no configurations in the project. An example of how I tried to achieve it is given below. Thanks in advance.

configurations.props:

<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug_Unicode|Win32"> <Configuration>Debug_Unicode</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> ... </ItemGroup> 

projected:

 <?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup Label="Globals"> <ProjectName>projname</ProjectName> <ProjectGuid>{XXX...XXX}</ProjectGuid> <RootNamespace>proj</RootNamespace> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="configurations.props" /> <PropertyGroup Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="PropertySheets"> <Import Project="other.props" /> </ImportGroup> ... 
+3
source share
2 answers

This was reported (by me) as an error in the beta testing period of VS 2010, but, unfortunately, the fix did not get into the release. I will try to dig a connection problem. You might want to consider some code generation using the MSBuild Project object model or some checking the runtime of your project files using the same one, but apart from that we will have to wait for a fix.

+2
source

This is possible in VS2012, since I published here , it was not tested in VS2010. I canโ€™t understand why this will not work.

0
source

Source: https://habr.com/ru/post/1347263/


All Articles