是否可以使用MSBuild将配置定义移动到属性表中

是否可以使用MSBuild将配置定义移动到属性表中

本文介绍了是否可以使用MSBuild将配置定义移动到属性表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在维护大量具有20多个配置的项目,但仍会不时添加一些配置.现在,我们使用VCBuild将此类更改传播到所有项目中.我开始尝试使用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?

请注意,当我尝试执行此操作时,Visual Studio抱怨项目中没有配置.下面是我尝试实现此目标的示例.预先感谢.

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:

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>

项目:

<?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>

    ...

推荐答案

(据我报道)这是VS 2010 Beta期间的错误,但不幸的是,该更新未包含此修复程序.我将尝试探讨连接问题.您可能要考虑使用MSBuild Project对象模型生成某些代码,或者使用该模型来生成项目文件的构建时验证,但除此之外,我们必须等待修复.

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.

这篇关于是否可以使用MSBuild将配置定义移动到属性表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 00:28