2011-03-07 69 views
3

我保持相當多的有20+的配置,仍然有些配置添加不時項目。將這種改變傳播到所有項目是我們現在用VCBuild所做的。我開始嘗試的MSBuild並似乎有一些邏輯來提取這些成單獨的屬性表,允許一個在一個地方做的改變。我該如何做到這一點?是否可以使用MSBuild將配置定義移動到屬性表中?

注意,我當我試圖做到這一點,Visual Studio中抱怨說,有項目中沒有的配置。下面是我試圖實現它的一個例子。提前致謝。

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> 

    ... 

回答

2

這是報告(由我)作爲VS 2010公測期間的錯誤,但不幸的是修復並沒有使其進入發佈。我會嘗試挖掘連接問題。您可能需要使用MSBuild項目對象模型,或者使用相同的項目文件的一些編譯時間驗證,但除此之外,我們將不得不等待修復來考慮一些代碼生成。

+0

感謝您的信息,所以我會留在現在生成項目文件:( – Yakeen 2011-03-07 15:24:44

+0

upvote連接錯誤報告在這裏https://connect.microsoft.com/VisualStudio/feedback/details/514008/vcxproj-doesnt-檢查-進口找到的項目的配置-β-2 – 2011-03-07 20:58:09

+0

四處找不到網頁 – Yakeen 2011-03-08 10:40:19

0

這是可能在VS2012作爲我貼here,在VS2010未經測試。看不出爲什麼它不起作用。

+0

你應該包括你發佈什麼在這裏,並有一個鏈接,它的更好的做法。 – 2012-10-21 08:18:56

相關問題