我想編輯我的項目文件,使我有一個項目,一次構建多個構建配置。我已經使用批處理方法並使用MSBuild任務完成了這一任務(請參見下文)。使用MSBuild建立多個配置
如果我運行該腳本,我得到這個錯誤:
Error 103 The OutputPath property is not set for project "ThisMSBuildProjectFile.csproj". Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='AnyCPU'.
我得到這個,如果我地添加或刪除從MSBuild任務的OutputPath。如果使用VS2010調試器來逐步執行腳本並調用MSBuild任務 - 調試器再次進入文件,然後進入OutputPath,所以afaik,應該選擇該值,不是?
任何幫助,這將不勝感激 - 這是讓我瘋了。謝謝,保羅。
ThisMSBuildProjectFile.csproj(剩餘的東西取出來):
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<!-- Only Import normal targets if not building multiple projects -->
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" Condition="'$(Configuration)|$(Platform)' != 'AllBuild|AnyCPU' "/>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == '' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>C:\Folder\Etc\Output\$(Configuration)\</OutputPath>
<OutDir>C:\Folder\Etc\Output\$(Configuration)\</OutDir>
<BaseOutputPath>C:\Folder\Etc\Output\$(Configuration)\</BaseOutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<!-- Common -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Platform>AnyCPU</Platform>
<!-- Repeated properties from above here (including, of course, OutputPath) -->
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<!-- Repeated properties from above here (including, of course, OutputPath) -->
</PropertyGroup>
<ItemGroup>
<Projects Include="C:\Folder\Etc\ThisMSBuildProjectFile.csproj" />
</ItemGroup>
<!-- Call this project file again, but with a different configuration - if this was working, this would call multiple build configs -->
<Target Name="Build" Condition="'$(Configuration)|$(Platform)' == 'AllBuild|AnyCPU' ">
<Message Text="hm!"/>
<!-- Tried thiswith and without the OutputPath property - makes no difference. -->
<MSBuild Projects="@(Projects)" Properties="Configuration=Debug;OutputPath=C:\Folder\Etc\Output\" ToolsVersion="4.0" Condition="'$(Configuration)|$(Platform)' == 'AllBuild|AnyCPU' "/>
</Target>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AllBuild|AnyCPU' ">
<!-- Repeated properties from above here (including, of course, OutputPath) -->
</PropertyGroup>
<!-- Project files -->
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Blah\Blah.cs" />
</ItemGroup>
非常好,謝謝你 - 這不是我正在尋找的東西(因爲我正在尋求最小化對標準CSProj文件的更改),但它看起來像我是過度思考的東西。我現在要採用這種方法。謝謝 – 2011-04-01 15:39:52
Fyi,這種技術被稱爲「任務配料」。有很多方法可以進行批處理,Sayed Ibrahim Hashimi在他的書「Inside the Microsoft Build Engine:Using MSBuild and Team Foundation Build」一書中涵蓋了他們 – 2012-11-26 17:31:33
「重要的是要認識到,當您使用」MSBuild「任務時,一個新的孩子MSBuild進程將開始。「這不是真的。根據http://msdn.microsoft.com/en-us/library/z7f65y0d.aspx:「與使用Exec任務啓動MSBuild.exe不同,此任務使用相同的MSBuild進程來構建子項目。」 這也符合我自己的經驗。 – 2012-12-07 16:49:08