Geeks With Blogs

@jakobehn

News

Microsoft Community Contributor Award 2011


Jakob Ehn Visual Studio ALM MVP

By default, TFS Team Build creates a new folder in the drop location for every build. I have seen request from people that wonder how to always have team build put the output in the same folder every time, effectively overwriting the results from the last build. This is easy to accomplish by adding an activity that copies the drop folder to a fixed location.

To copy the result of the build to a fixed location, you need to modify the build process template:

  1. Open the build process template XAML file in the workflow designer.
  2. Click on the Collapse All link in the upper right corner so that only the top level activities are shown
  3. Open the Toolbox window and locate the CopyDirectory activity (it is located in the Team Foundation Build Activities tab)
  4. Drag the CopyDirectory activity onto the design surface and drop it between the Run On Agent and the Check In Gated Changes for CheckInShelveset Builds activity:

    image  
  5. Right click on the CopyDirectory activity and select Properties. Fill out the properties, you will of course need to modify the path for the destination accordingly:

    image
  6. Save the build definition and check it in. NB: Remember to check in the build process template file after modifying it, a lot of times people forget this step!
  7. Queue a new build and, after the build has succeeded, verify that the build output has been copied to the corresponding output path

To make this build process template more generic, you proabably want to create a process parameter that lets you define the path either when you create a new build definition, or when you queue the build (or both). This will let you you reuse the build process template for builds with different output paths

Posted on Wednesday, September 1, 2010 8:47 AM TFS , Team Build , Visual Studio 2010 | Back to top


Comments on this post: TFS Team Build 2010: How to place the build output to a fixed location

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
I am getting "Access Denied" errors using this CopyDirectory task. Essentially the task is unable to write to the other server in my case. Is this a result of the TFSBuildServiceHost running under 'Network Service' account? What security settings are required on the \\ServerPath\SomeShare folder?
Left by Tim on Nov 11, 2010 11:05 AM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
You must give the build service account permission to write to the share. Normal Write/Modify ACL permissions is enough
Left by Jakob Ehn on Nov 14, 2010 2:42 AM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
Thanks. Exactly what I was looking for. :)
Left by tikra on Feb 08, 2011 9:08 AM

# re: TFS Team Build 2010: How to place the build output (All dll's and some files) to a DROP LOCATION
Requesting Gravatar...
We are using WIX which creats an MSI cabinate that contains all dll's and files that copies to DROP Location. Now my need is to copy the same content of the MSI file to the drop location (Not as a cabinate) when the build get succeded.

Any help wolud be appriciated..
Thanks in Advance. :)
Left by shamsheer on Mar 25, 2011 9:10 AM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
It was very well laid out and helpful. Thanks Jakob!
Left by gout symptoms on May 02, 2011 5:57 PM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
I tried this, but did not work, only log file was available at the drop location I specified, the buildversionlabel.xml file was in C:\Builds\5\product\product_Nightly\Sources\A3\Common\Components\RemoteServer\Source\A3.Common.Components.RemoteServer
Left by Ananya on Sep 06, 2011 2:59 PM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
You are the man! Was looking for some guidance on this, where can I get better build guidance than here :)
Worked for us!!!
Left by Naveen Sharma on Mar 20, 2012 10:07 PM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
Why can't i set a normal physical path (e.g. D:\Web\Sites\MyWebSite) for the build output? I have TFS and web sites on the same machine and i need to copy my build output files just to another directory on the same machine. But i can't make it because i can set my drop directory only in the Visual Studio project properties that accepts only UNC paths...Do i need to use some custom publishing actions to copy my build output from default build folder to the www root of my IIS web sites?
Left by Andrey on Sep 14, 2012 6:27 AM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
@Andrey: You must enter a share as the output path, Team Build won't accept anything else. I suggest that you just create a share on the server that points to the web site folder in IIS

/Jakob
Left by Jakob Ehn on Sep 14, 2012 8:53 AM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
@Jakob - ok, i've shared a website root and set it as a drop folder for the TFS build configuration. Is it enough to "publish" a build output on my web site (ASP.NET MVC project)
Left by Andrey on Sep 14, 2012 11:09 AM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
@Andrey: No, team build will create a new drop folder beneath the drop location on every build. This post describe how you can take the output from the drop folder and copy it to a fixed location, which basically is what you need.

Another option for you, since you are developing web apps, is to use web deploy to publish your web application. If you are using VS2012, create a publish profile and check it in, then add this to the MSBuild Arguments parameter in your build definition:

/p:DeployOnBuild=true;PublishProfile="MyPublishProfileName"

Hope that helps
Left by Jakob Ehn on Sep 14, 2012 11:26 AM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
@Jakob - thanks a lot, it works.

Although i can't guess why TFS doesnt support a simple copying of the build output to the any folder on the local file system...

Thanks again, you really helper me!
Left by Andrey on Sep 14, 2012 5:05 PM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
Jakob,
I am trying to deloy WCF service of .net in TFS2012 using build defination and useed below args in msbuild in the arguments

/p:DeployOnBuild=True /p:DeployTarget=MsDeployPublish /p:MSDeployPublishMethod=InProc /p:MSDeployServiceUrl=win-gs9gmujits8 /p:DeployIISAppPath="Sites/Website name"

but thi is not deplying the published folder on iis virtual shared directoy although there is no error reported . so i used your copydietcory approach to manually copy it to shared IIS virtual directory after build , but is there more smart way to do it rathet tahn creating new template for this for diffrent build ?

also i dont want all files under _PublishedWebsites folder as thet are web.config and other xml files also which are created and i want to exlude them and coply only bin and servrice folder to IIS , so do i need as many diffrent copydirectot task in defination to give source as _PublishedWebsites\bin, _PublishedWebsites\XXXX and ,_PublishedWebsites\YYYY folder separtely or is there much easier and better way to achive this ?

Any help is well appreciated .
Left by Ancc on Oct 18, 2012 10:17 AM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
Appreciate your post, it's exactly what I've been looking for.
I've made a slight modification though. As we use multiple build definitions, I use
BuildDetail.DropLocationRoot + "\latest"
as the Destination to keep the latest source with appropriate build definition outputs.
Left by Jan Sokoly on Oct 25, 2012 1:03 PM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
I can't even express how graceful I am! I spent several days to overcome this problem and at last got your solution. Thank's a lot!
Left by Shota Giorgobiani on Nov 26, 2012 10:11 AM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
Amazing,... Thanks a lot for this.. :)
Left by Abraham Dhanyaraj on Mar 01, 2013 2:06 PM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
How about simply modifying the BuildNumberFormat vallue From: $(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.r)
To: $(BuildDefinitionName) or any other fixed name. So, every time the build runs it will dump the final output to the same folder under the UNC drop location path
Left by Vikas Gupta on Jul 26, 2013 3:07 PM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
Sorry, the above solution will not work as the build engine needs a unique name for every build.
Left by Vikas Gupta on Jul 26, 2013 3:15 PM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
As mentioned in a previous post (for which I didn't see a reply), I need to exclude the web.config from CopyDirectory. "Exclude" was supported in the TFSBuild.proj AfterDropBuild script. Why doesn't CopyDirectory support exclusion?
Left by Steve on Sep 13, 2013 5:10 PM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
Very nice and Helped a lot
Left by Ganesh on Feb 05, 2014 8:58 AM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
I am looking for the same and this post helped, Thanks.
In addition to this, I am looking to create 4 sub-folders at the destination for my 8 projects in the solution. What is the recommended way to do this. Based on it, I have two question:
1. Should I use CreateDirectory and CopyDirectory activities. OR use arguments in MSBuild.
2. In the example source of Copy is the DropLocation. As per my understanding build server makes a copy of source and build files. So isn't it a good idea to copy files directly from Build Server (something like $\build folder\bin) to \\ServerPath\SomeShare. Currently, I don't know how to do this, but if kindly provide info if you know how to do it.

Thanks
Hardy
Left by Hardy on Jun 27, 2014 10:14 PM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
Hi Everyone,

I am trying an TFS autobuild continous integration. When a developer checks in the code, the build definition executes the code and Drops the publish files to a Location with build numbers incrementally. once the Code is checked in, i would like the build defination to delete the old publish files and deploy the new publish file to the same location of the drop location, Am doing this because my drop location is mapped to iis virtual directory, does any one have a better solution.

Left by Jonathan Siqueira on Jul 12, 2014 5:42 PM

# re: TFS Team Build 2010: How to place the build output to a fixed location
Requesting Gravatar...
Hi,

After I do a new build using the build definition, I get the _PublishWebsite folder created. i want to get rid of the _Publishwebsite folder and directly copy all the dll and cshtml files to the Root folder.
Please suggest
Left by Jonathan Siqueira on Jul 14, 2014 10:44 PM

Your comment:
 (will show your gravatar)


Copyright © Jakob Ehn | Powered by: GeeksWithBlogs.net | Join free