开发者

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

I'm maintaining quite a large number of projects that have 20+ configurations and still some configurations are added from time to time. Propagating such change into all projects is what we do right now with VCBuild. I started experimenting with MSBuild and there seems to be some logic to extract these into separate property sheet, allowing one to do changes in one place. How do I do that exactly?

Note that I when I tried to do it, Visual Studio complained that there were no configurations in the project. An example of how I tried to achieve it is 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>

proj:

<?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" />
    <Prope开发者_Go百科rtyGroup Label="Configuration">
        <ConfigurationType>StaticLibrary</ConfigurationType>
    </PropertyGroup>

    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

    <ImportGroup Label="PropertySheets">
        <Import Project="other.props" /> </ImportGroup>

    ...


This was reported (by me) as a bug in the VS 2010 beta period, but unfortunately a fix did not make it into the release. I'll try to dig up the connect issue. You might want to consider some code generation using the MSBuild Project object model, or some build time verification of your project files using the same, but other than that we'll have to wait for a fix.


This is possible in VS2012 as I posted here , not tested in VS2010. Can't see why it wouldn't work however.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜