0

我有以下目标:

<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=True /t: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 ..\ 的位置路径,但它不是 - 知道为什么以及为什么它会被打印两次!?

4

1 回答 1

1

@(Schemas) 和 @(Pipelines) 项目数组都在添加另一个项目元组,否则它们无法打印出来。必须有另一个正在运行的目标会发生这种情况。如果您使用确切的命令行在项目上运行 msbuild,则附加目标必须是项目的 InitialTargets 中的一个条目,或者是连接到上述目标的目标,其中包含对该目标的 BeforeTargets 或 AfterTargets 引用.

于 2012-07-25T05:17:05.533 回答