16
votes

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).

3
How did this go for you? I'm trying to ensure the deployment does not occur if the following Test step fails. Were you able to do that?one.beat.consumer
@one.beat.consumer - You should split out your compile/test from deployment as two separate stages, then you can deploy the same code to your test/qa/prod environments.Erik Funkenbusch
Thanks. The "Release" feature is deploying the packages as you mentioned. What I was having trouble with was separating the execution of tests from the build step, as the only examples I found for XUnit were customizations to the build. I've since found the xunit.runner.visualstudio NuGet package that allows me to customize an Test step appropriately. However, it takes two builds now - the first to build prepping for test, and the second to create a deploy package if the tests pass.one.beat.consumer

3 Answers

15
votes

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
8
votes

I wanted to add that Ben Day has an excellent write-up that helped us package quickly and then release to multiple environments through Release Manager.

His msbuild arguments look like this:

/p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl=$(build.artifactstagingdirectory)\for-deploy\website

The difference between this and the accepted answer is that this parameter set stages everything in an artifacts folder, and then saves it as part of the build. We can then deploy exactly the same code repeatedly.

We capture the web.env.config files alongside the for-deploy folder and then use xdt transforms in the release process to ensure everything gets updated for whichever environment we're deploying to. It works well for all our web projects.

-5
votes

We use WebDeploy/MSDeploy for 40+ applications and love it. We do install WebDeploy on all our servers so we can deploy more easily but you could also use the Web Deploy On Demand feature which doesn't require WebDeploy be pre-installed.