2013-07-01 9 views
5

私のチームは大きなソリューション(〜500 csproj's)を持っています。 VS2012を使用し、MSBuild 4を使用するTFS Buildを使用してビルドします。現在、シリアルに構築していますが、(msbuild /maxcpucount:4を使用して)並列にビルドしたいと考えています。しかし、私は私の4-procのマシン上でそれをしようとしたとき、私は奇妙な失敗を取得:ログを見てMSBuild/m:4は同じプロジェクトを2回構築するため失敗しました

11:2>CSC : fatal error CS0042: Unexpected error creating debug information file 'C:\Common\obj\Debug\Common.PDB' -- 'C:\Common\obj\Debug\Common.pdb: The process cannot access the file because it is being used by another process. [C:\Common\Common.csproj]

を、2つのMSBuildのノードは、同じcsprojを構築しようとしていたので、いくつかを書くことに衝突します出力:

10>Project "C:\Utils\Utils.csproj" (10) is building "C:\Common\Common.csproj" (11) on node 4 (default targets).
46:2>Project "C:\Objects\Objects.csproj" (46:2) is building "C:\Common\Common.csproj" (11:2) on node 1 (default targets).

なぜMSBuildのは二度同じプロジェクトをビルドしようとするのでしょうか?

答えて

3

原因:誰かが<MSBuild Projects="Common.csproj" Properties="..." />を呼び出していました。次に、MSBuildは、Common.csprojを別のプロパティで再度ビルドする必要があると考え、Common.csprojの通常のコンパイルと同時に発生します。

修正:<MSBuild ... />を不要なプロパティなしで呼び出します。

試験:

Common.targets

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 
    <Target Name="Build"> 
    <Message Importance="high" Text="Build in $(MSBuildThisFile)" /> 
    </Target> 
    <Target Name="After" DependsOnTargets="Build"> 
    <Message Importance="high" Text="After in $(MSBuildThisFile)" /> 
    </Target> 
</Project> 

Other.targets

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 
    <Target Name="Build"> 
    <Message Importance="high" Text="Build in $(MSBuildThisFile)" /> 
    <MSBuild Projects="common.targets" Targets="Build" /> <!-- regular builds --> 
    <MSBuild Projects="common.targets"      <!-- custom invocation with properties --> 
      Targets="After" 
      Properties="myprop=myvalue" 
      /> 
    </Target> 
</Project> 

実行:

> msbuild other.targets /clp:verbosity=minimal 
    Build in other.targets 
    Build in common.targets 
    Build in common.targets <<<< Common.targets Build is invoked again 
    After in common.targets 

実際には、Properties="myprop=myvalue"を削除すると問題が解決します。