views:

481

answers:

1

I am trying to get my build to checkout some files (using Microsoft.Sdc.Common.tasks) and then to check them in after the build has finished. But I can't seem to get this working at all, let alone before and after the build.

Whaereabouts should this sort of code live?

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="DesktopBuild;MyProjectDbUpdate" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
   <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets" />
  <PropertyGroup>
    <TasksPath>C:\Program Files\MSBuild\sdc\</TasksPath>
  </PropertyGroup>
  <Import Project="$(TasksPath)\Microsoft.Sdc.Common.tasks" />

  <Target Name="MyProjectDbUpdate">
    <Message Text="MyProjectDbUpdate checkin start"/>
    <SourceTfs.Checkout  Path="$/MyProject/Code/MyProjectDbUpdate" TfsVersion="2008" workingDirectory="C:\buildagent\MyProject\ContinuousIntegration\Sources\Code" />
    <SourceTfs.Checkin Path="$/MyProject/Code/MyProjectDbUpdate" workingDirectory="C:\buildagent\MyProject\ContinuousIntegration\Sources\Code" Comments="Build checkout/checkin." TfsVersion="2008" Override="Build overrides checkin policy" />
    <Message Text="MyProjectDbUpdate checkin complete"/>
  </Target>


  <ProjectExtensions>

    <ProjectFileVersion>2</ProjectFileVersion>
    <Description>Build</Description>
    <BuildMachine>MYSERVER</BuildMachine>

  </ProjectExtensions>

  <PropertyGroup>
    <TeamProject>MyProject</TeamProject>
    <BuildDirectoryPath>c:\buildagent\MyProject\ContinuousIntegration</BuildDirectoryPath>
    <DropLocation>\\UNKNOWN\drops</DropLocation>
    <RunTest>false</RunTest>
    <RunCodeAnalysis>Never</RunCodeAnalysis>
    <WorkItemType>Bug</WorkItemType>
    <WorkItemFieldValues>System.Reason=Build Failure;System.Description=Start the build using Team Build</WorkItemFieldValues>
    <WorkItemTitle>Build failure in build:</WorkItemTitle>
    <DescriptionText>This work item was created by Team Build on a build failure.</DescriptionText>
    <BuildlogText>The build log file is at:</BuildlogText>
    <ErrorWarningLogText>The errors/warnings log file is at:</ErrorWarningLogText>
    <UpdateAssociatedWorkItems>true</UpdateAssociatedWorkItems>
    <AdditionalVCOverrides></AdditionalVCOverrides>
    <CustomPropertiesForClean></CustomPropertiesForClean>
    <CustomPropertiesForBuild></CustomPropertiesForBuild>

  </PropertyGroup>

  <ItemGroup>
    <SolutionToBuild Include="$(BuildProjectFolderPath)/../../Code/MyProject.sln">
        <Targets></Targets>
        <Properties></Properties>
    </SolutionToBuild>

  </ItemGroup>

  <ItemGroup>
    <ConfigurationToBuild Include="Release|Any CPU">
        <FlavorToBuild>Release</FlavorToBuild>
        <PlatformToBuild>Any CPU</PlatformToBuild>
    </ConfigurationToBuild>

  </ItemGroup>

  <ItemGroup>
  </ItemGroup>

  <PropertyGroup>
  </PropertyGroup>

  <ItemGroup>
  </ItemGroup>
</Project>
+2  A: 

Specifying your target as a default target is not going to call it as Team build explicity sets the target it is going to call.

Try renaming the Target to AfterGet or overriding the the GetDependsOn property to include your target

<GetDependsOn>
  $(GetDependsOn)
  MyProjectDbUpdate;
</GetDependsOn>
John Hunter
So simple, yet I completely missed the point of how targets work...Thanks
simon831