0

I have the following Target:

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

I run the project from the command line passing in /p:TeamBuild=True /t:SetBinariesForTeamBuild. The output has me very puzzled...

Microsoft (R) Build Engine Version 4.0.30319.1 [Microsoft .NET Framework, Version 4.0.30319.269] Copyright (C) Microsoft Corporation 2007. All rights reserved.

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

I want the location path to be the one with 8 ..\ but it is not - any idea why and why it gets printed twice!?

1 Answer 1

1

The @(Schemas) and @(Pipelines) item arrays are each getting another item tuple added to them, or else they couldn't be printing out. There must be another target that is getting run in which this happens. If you are running msbuild on the project using the exact command line, then the additional target would have to be either an entry in an InitialTargets on a Project, or else a target wired into the target above with a BeforeTargets or AfterTargets reference to this one.

1
  • That's it! Thanks Brian. There was another target called 'Deploy'. This also had item groups with the same name that I was trying to override. My solution to this problem was to move the assignment to the LocationPath properties outside of my custom target. They now sit in the Parent project - not in a specific target. I only needed the custom target so that I could use the Message task for diagnostics - message tasks MUST be contained within a target.
    – Rob Bowman
    Jul 25, 2012 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.