Build and Deploy a Web Application with TFS 2015 Build

Erik Funkenbusch picture Erik Funkenbusch · Feb 11, 2016 · Viewed 13.4k times · Source

We have just installed TFS 2015 (Update 1) on-premise and are trying to create a Continuous Integration/Build system using the new TFS Build system. The build works fine, and gives me a green light, but when I look at the default build it has only built the binaries from the bin directory, and there seems to be no easy way to deploy the app on-premise to a local server.

There are two deploy options for a filesystem copy, and a powershell script, and it would certainly be easy enough to use them to copy files to a new server, but since the build only built the binaries, I don't see a tool to gather up the Web artifacts (cshtml, images, scripts, css, etc..) for this.

After an exhaustive google search, I've only found one article which talks about this at:

http://www.deliveron.com/blog/building-websites-team-foundation-build-2015/

However, this uses WebDeploy and creates a rather messy deploy package.

How can I deploy the site (standard MVC web application, in fact my tests are using the default boilerplate site created by the create project wizard) complete with artifacts to a local server in the easiest possible way? I don't want to have to install WebDeploy on the servers, and would rather use PowerShell or something to deploy the final artifacts.

The build is just the standard Visual Studio build template, with 4 steps (Build, Test, Index & Publish, Publish Build Artifacts).

Answer

Sebastian Siemens picture Sebastian Siemens · Apr 12, 2016

We use "Visual Studio Build" step and as Arguments for MSBuild we use following line:

/p:DeployOnBuild=True /p:PublishProfile=$(DeploymentConfiguration)

On Variables tab page DeploymentConfiguration has to be configured. It must be the Name of the publish Profile (filename of the pubxml file). If the file Name is Build.pubxml the publish profile is Build.

for example:

/p:DeployOnBuild=True /p:PublishProfile=Build