2012-07-24 39 views
0

我有以下目標:MSBuild的消息輸出兩次

<Target Name="SetBinariesLocationForTeamBuild"> 
    <!--We add the following location paths because TFS Team Build first copies to \sources and \binaries folders 
    rather than simply having the binaries in a \bin folder of the source folder 
    at this point the build will be at: C:\Builds\3\x.Int.MIS\SupportBTDF\Sources\x.Int.MIS\Dev\V1.0\Src\Solutions\MIS\x.Int.MIS.Deployment 
    so we need to go up 4 levels before going back down to binaries--> 
    <Message Text="Value of TeamBuild=$(TeamBuild)"/> 

    <Message Text="MSBuildProjectName: $(MSBuildProjectName)"/> 
    <Message Text="MSBuildStartupDirectory: $(MSBuildStartupDirectory)"/> 
    <Message Text="MSBuildProjectDirectory: $(MSBuildProjectDirectory)"/> 
    <Message Text="MSBuildProjectFullPath: $(MSBuildProjectFullPath)"/> 
    <Message Text="MSBuildThisFileDirectory: $(MSBuildThisFileDirectory)"/> 

    <ItemGroup> 
     <Schemas Condition ="'$(TeamBuild)' == 'True'" Include="x.Int.MIS.Schemas.dll"> 
     <LocationPath>..\..\..\..\..\..\..\..\binaries\</LocationPath> 
     </Schemas> 
    </ItemGroup> 

    <ItemGroup> 
     <Pipelines Condition ="'$(TeamBuild)' == 'True'" Include="x.Int.Pipelines.dll"> 
     <LocationPath>..\..\..\..\..\..\..\..\binaries\</LocationPath> 
     </Pipelines> 
    </ItemGroup> 

    <ItemGroup> 
     <PipelineComponents Condition ="'$(TeamBuild)' == 'True'" Include="x.Int.PipelineComponents.dll"> 
     <LocationPath>..\..\..\..\..\..\..\..\binaries\</LocationPath> 
     </PipelineComponents> 
    </ItemGroup> 

    <ItemGroup> 
     <Orchestrations Condition ="'$(TeamBuild)' == 'True'" Include="x.Int.Orchestrations.dll"> 
     <LocationPath>..\..\..\..\..\..\..\..\binaries\</LocationPath> 
     </Orchestrations> 
    </ItemGroup> 

    <ItemGroup> 
     <Transforms Condition ="'$(TeamBuild)' == 'True'" Include="x.Int.Transforms.dll"> 
     <LocationPath>..\..\..\..\..\..\..\..\binaries\</LocationPath> 
     </Transforms> 
    </ItemGroup> 

    <Message Text="What is Schemas location path: %(Schemas.LocationPath)"/> 
    <Message Text="What is Pipelines location path: %(Pipelines.LocationPath)"/> 

    </Target> 

我從命令行傳入/ P運行項目:TeamBuild =真/噸:SetBinariesForTeamBuild。輸出讓我非常疑惑...

Microsoft(R)Build Engine版本4.0.30319.1 [Microsoft .NET Framework,版本4.0.30319.269] 版權(C)Microsoft Corporation 2007.保留所有權利。

Build started 24/07/2012 16:59:08. 
Project "C:\Builds\3\x.Int.MIS\SupportBTDF\Sources\x.Int.MIS\Dev\V1.0\Src\Solutions\MIS\x.Int.MIS.Deployment\x.Int.MIS.Deployment.btdfproj" on node 1 (SetBinariesLocationForTeamBuild target(s)). 
SetBinariesLocationForTeamBuild: 
    Value of TeamBuild=True 
    MSBuildProjectName: x.Int.MIS.Deployment 
    MSBuildStartupDirectory: C:\Builds\3\x.Int.MIS\SupportBTDF\Sources\x.Int.MIS\Dev\V1.0\Src\Solutions\MIS\x.Int.MIS.Deployment 
    MSBuildProjectDirectory: C:\Builds\3\x.Int.MIS\SupportBTDF\Sources\x.Int.MIS\Dev\V1.0\Src\Solutions\MIS\x.Int.MIS.Deployment 
    MSBuildProjectFullPath: C:\Builds\3\x.Int.MIS\SupportBTDF\Sources\x.Int.MIS\Dev\V1.0\Src\Solutions\MIS\x.Int.MIS.Deployment\x.Int.MIS.Deployment.btdfproj 
    MSBuildThisFileDirectory: C:\Builds\3\x.Int.MIS\SupportBTDF\Sources\x.Int.MIS\Dev\V1.0\Src\Solutions\MIS\x.Int.MIS.Deployment\ 
    What is Schemas location path: ..\x.Int.MIS.Schemas\bin\Debug 
    What is Schemas location path: ..\..\..\..\..\..\..\..\binaries\ 
    What is Pipelines location path: ..\x.Int.MIS.Pipelines\bin\Debug 
    What is Pipelines location path: ..\..\..\..\..\..\..\..\binaries\ 
Done Building Project "C:\Builds\3\x.Int.MIS\SupportBTDF\Sources\x.Int.MIS\Dev\V1.0\Src\Solutions\MIS\x.Int.MIS.Deployment\x.Int.MIS.Deployment.btdfproj" (SetBinariesLocationForTeamBuild target(s)). 

Build succeeded. 
    0 Warning(s) 
    0 Error(s) 

Time Elapsed 00:00:00.17 

我想要位置路徑是8 .. \但它不是 - 任何想法爲什麼以及爲什麼打印兩次!

回答

1

@(Schemas)和@(Pipelines)項目數組每個都獲得添加到其中的另一個項目元組,或者它們不能被打印出來。必須有另一個目標正在發生這種情況。如果您使用確切的命令行在項目上運行msbuild,那麼額外的目標必須是項目上的InitialTargets中的條目,否則使用BeforeTargets或AfterTargets引用指向上面目標中的目標。 。

+0

就是這樣!感謝Brian。還有另一個目標叫'部署'。這也有與我試圖重寫的名稱相同的項目組。我對這個問題的解決方案是將任務移到自定義目標外的LocationPath屬性中。他們現在坐在父項目中 - 而不是在一個特定的目標。我只需要自定義目標,以便我可以使用消息任務進行診斷 - 消息任務必須包含在目標中。 – 2012-07-25 09:09:52