views:

81

answers:

3

I want to perform some copy actions on the build machine (but not on the developer machines)

  • after a build is performed and
  • before the integration tests run.

How do I do that?

Perhaps, I should split the question up into sub-questions and give some examples.

Question 1: What do I need to do so that the MSBuild script detects that it is being executed on the build machine and therefore does a copy operation? Do I adapt the *.csproj file? Do I do something within the Build Definition file? The build server is part of our TFS 2010 backend.

Question 2: What variable do I need to use to reference the build folder on the build machine? The absolute path is

C:\Builds\1\ProjectX\Continous Integration\

I need to copy some files which are under version control and end up in the Sources folder to the Binaries folder.

C:\Builds\1\ProjectX\Continous Integration\Binaries
C:\Builds\1\ProjectX\Continous Integration\Sources
C:\Builds\1\ProjectX\Continous Integration\TestResults
A: 

Whatever you are automating the build with ought to be able to pass a property through to MSBuild. On the command line you do something like:

msbuild my.proj /p:RunningOnBuildMachine=true

In your script you can then use a condition based on $(RunningOnBuildMachine) == 'true' to trigger the interim step. Alternatively there is already an inbuilt variable $(BuildingInsideVisualStudio) which tells MSBuild whether it's being called from within VS or not which may be sufficient for your needs.

As to where your output directory is, that's a bit trickier. What determines that location? Is it the CI server? If so you could try getting that to pass the output directory as a property to the script as well.

Paolo
I am not sure what the output directory location determines. We have a TFS 2010 instance and a build server. I suppose the output location is defined somewhere in the Team Explorer view > ProjectX > Builds > "Continuous Integration" > Edit Build Definition > Workspace > Build Agent Folder = $(SourceDir)... I assume I could use $(SourceDir) from the MSBuild script.
Lernkurve
A: 

If you are using the default build process template (DefaultTemplate.xaml) that is using Windows Workflow Foundation instead of the Upgrade Template that uses MSBuild then you can use a CopyDirectory workflow activity that is included out of the box and put it between the compilation section and the testing section of the workflow.

Which build process template are you using in TFS 2010?

Ed Blankenship
Great hint, thanks! Yes, we are using the default build process template DefaultTemplate.xaml. I'll try to add a CopyDirectory workflow acdtivity at the right place.
Lernkurve
Awesome - I'm really a big fan of Windows Workflow Foundation in Team Build 2010 now.
Ed Blankenship
A: 

Build folder:

Have you tried MSBuild reserved property MSBuildProjectDirectory?

You can acces it in the same manner as other properties, e.g. $(MSBuildProjectDirectory)\Binaries. Or did you mean something else?

zbynour