What is the purpose of Binaries\_PublishedWebsites directory under TFS build

sam picture sam · Feb 1, 2012 · Viewed 9.9k times · Source

TFS generates a publish directory under the build agent working directory:

Z:\TFSBuilds\1\box\CT\Binaries\\_PublishedWebsites

I am supposing that this is where TFS is automatically publishing the site. How can I use it for auto publishing of sites... as Should we refer our IIS website to this directory. What is the purpose of it?

Answer

Frank Leigh picture Frank Leigh · Feb 2, 2012

Firstly, the working directory is as the name says, a "working" directory. That is where the build agent downloads the source, perform compiles etc. It also clears the working directory whenever you run the build again so you risk grabbing unfinished artifacts when you try to retrieve from the working directory.

TFS defines a "drop folder" that it will copy the final artifacts to, once the build completes. You can define the drop folder for a build by editing it's build definition:

  1. Right click on the build and choose 'edit build definition.
  2. Select the 'Build Defaults' section.
  3. Tick 'This build copies output files to a drop folder'
  4. Enter an UNC path for the build agent to copy artifacts to (make sure the Build Agent has access to that UNC path!)

Secondly, in regard to _PublishedWebsites. The build agent will create a _PublishedWebsites folder for each Web project it builds as part of its build artifacts (so if you tell it to build a solution with 2 web projects, it'll create [Project name A]\_PublishedWebsites and [Project Name B]\_PublishedWebsites). Inside each _PublishedWebsites folder are the contents to be dropped into an IIS application, same as what you would get by right clicking on a web project and selecting 'Publish'. I normally add a last step in the build workflow to copy the contents of this _PublishedWebsites folder to my desired IIS directory.

This link tells you how to add the copy workflow: TFS 2010: Copy _PublishedWebsites to test server

And here's more on drop folders: http://msdn.microsoft.com/en-us/library/bb778394.aspx