views:

69

answers:

3

Hi All,

I'm working on a application where multiple dev will check-in everyday. I want to copy latest files only after check-in and successful TFS build to a share location. Currently I'm using post build script something like

Attrib -r "$(ProjectDir)Data*." /S & xcopy /S /Y /I "$(ProjectDir)Data*." "ShareLocation"

But the biggest problem is, even someone locally made some changes and then do local build, all files get copied to the shared location. But I only want to copy files which are checked-in and after successful TFS build.

Could someone please help what will be the best solution for this. I'm not a build engineer and know very less about MSBuild, so if your answer is MSBuild then please share some good sample rather than giving MSDN link. Thnks in advance.

Pritam

A: 

If you have a dedicated server for TFS build then you can call a separate .bat file as post build event.

Inside the post build event you can specify the servername i.e. make a check whether build is done on that remote server. If build is on remote server you can have the copy command here.

Example : IF /i "%COMPUTERNAME%" == "servername" (command)

Sunil Agarwal
Hii. Did you tried? Is it working?
Sunil Agarwal
I update my default TFSBuild.Proj file with a target. So this way whenever someone checked-in something, then only it get copied to my server. but thanks everyone for your help.
Pritam Karmakar
A: 

You can add a condition that only release builds will execute the command:

if "$(ConfigurationName)" == "Release" (command)

Ewald Hofman
A: 

Thanks everyone for your help. Here is what I used in my TFSBuild.proj file and solve my problem

<Target Name="AfterCompile">
<Exec Command="Attrib -r &quot;$(SolutionRoot)\<SolutionFolder>\*.*&quot; /S"></Exec>
<Exec Command="xcopy /S /Y /I &quot;$(SolutionRoot)\<SolutionFolder>\*.*&quot; &quot;<server location>;" />     

Pritam Karmakar