2013-07-01 6 views
5

Mein Team hat eine große Lösung (~ 500 csproj). Wir verwenden VS2012 und bauen mit TFS Build, das MSBuild 4 verwendet. Derzeit bauen wir seriell, aber wir wollen parallel bauen (mit msbuild /maxcpucount:4). Allerdings, wenn ich es auf meiner 4-proc Maschine versuchen, ich eine seltsame Scheitern:MSBuild/m: 4 schlägt fehl, weil es das gleiche Projekt zweimal erstellt

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]

im Protokoll der Suche, 2 msbuild Knoten versuchen die gleiche csproj zu bauen und damit zu kollidieren auf einig schreiben Ausgang:

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).

Warum sollte MSBuild versuchen zweimal das gleiche Projekt zu bauen?

Antwort

3

Ursache: Jemand rief <MSBuild Projects="Common.csproj" Properties="..." /> an. Dann denkt MSBuild, dass Common.csproj erneut mit diesen verschiedenen Eigenschaften erstellt werden sollte, und es trat bei der regulären Kompilierung von Common.csproj zur gleichen Zeit auf.

Fix: Rufen Sie <MSBuild ... /> ohne diese nicht benötigten Eigenschaften.

Test:

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> 

Run:

> 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 

Und in der Tat löst das Entfernen Properties="myprop=myvalue" das Problem.