Azure DevOps, Scrum, & .NET Software Leadership and Consulting Services

Free course! Predicting the Future, Estimating, and Running Your Projects with Flow Metrics

An ASP.NET MVC Site That’s Easy to Deploy from a TFS Build

By this point, you’ve probably heard that Team Foundation Server 2015 has a completely new build system.  As part of it, it organizese and compiles the code slightly differently than the old XAML-based TFS Build system.  First off, when you run a vNext build on a build server, you got four folders: a, b, s, and TestResults.  TestResults contains (surprise!) the results of any unit tests that you ran.  The “s” directory contains the source code that went into the build.  The “a” directory contains the artifacts (also known as the “drop”) that are uploaded at the end of the build.  The “b” directory is probably empty.

The disk layout for a TFS vNext build

If you’re in a DevOps mindset and you’re trying to deploy an ASP.NET Web Application (WebForms, MVC, WebAPI), you’re probably going to panic when you open up the artifacts directory (“a”) and find everything EXCEPT your web application.  If you’re used to doing “right-click deploys” or you’re used to building with the old XAML-based TFS build system, you’re probably wondering where your nice _PublishedWebsites directory is.  Life used to be so easy.  You used to be able to do a simple copy/xcopy from _PublishedWebsites and you were done.  Now that directory’s gone and — well — that’s kind of annoying, isn’t it?

There’s a reasonably straightforward fix.

Go to your build definition.  Click on the Visual Studio Build task.  By default, that’s the second task in the list.

Next you’ll need to specify some additional parameters for the MSBuild Arguments value for the task.  These parameters cause the web project to do a file system deploy that’s pretty much the same thing that it would have done to create that _PublishedWebsites directory.  To make your life easier as you get into more and more build and deployment customization, I’d recommend creating a ‘for-deploy’ directory inside of your artifacts directory and putting the published code in that.

Here’s the value to paste into MSBuild Arguments.  This will publish the website into a directory called “for-deploy\website” in the artifacts directory.

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

Edit the MSBuild Arguments for the Visual Studio Build step

After you’ve plugged that value in, save the build definition, and then run a new build.

When the build completes, click on the Artifacts tab to view the build’s drop.  Remember: this drop directory is the same as the contents of the artifacts directory at the end of the build.  Click the Explore link to take a look at the artifacts from your build.  

The Build Artifacts Tab

You should now see the Artifacts Explorer dialog and if you expand the folders, you’ll see the for-deploy\website directory.  Inside of that directory is the published website that’s ready for you to deploy to your web server. 

Artifacts Explorer & the Build Drop

I hope that this saves you some pain and frustration.



— Looking for help getting going with Team Foundation Server Build vNext?  Want to get better at DevOps?  Not sure where to start?  We can help.  Drop us a line at


12 responses to “An ASP.NET MVC Site That’s Easy to Deploy from a TFS Build”

  1. […] Ben Day solves a problem with An ASP.NET MVC Site That’s Easy to Deploy from a TFS Build: […]

  2. […] my last post, I talked about how to create an ASP.NET Web Application that’s easy to deploy from your Team […]

  3. Aleks Avatar

    Thank you! You saved my day!

  4. Ethan Avatar

    Thanks for sharing, how to handle if i have more than one web application projects in my solution?

    1. Ben Day Avatar

      Hey Mickey —

      Have you tried it with >1 web project and found that it causes problems somehow? My first thought is that it should work just fine with multiple projects provided that you’ve set the publish options on each web project.


  5. B Avatar

    how can I do it with .csproj ?

  6. ishahrier Avatar

    I have two web project in one solutions. and only one is being copied. how can I do it for both of them in two separate folders inside the for-deployment folder.
    NOTE: I am also taking your course on plural sight. absolutely love the way you explain things.

  7. Edgar Flores Palma Avatar

    I have the same doubt… i have two web project… how can i separate in folders that.

  8. Kurt Huebner Avatar
    Kurt Huebner

    Excellent article, I wish Microsoft would document their stuff like this. Being relatively new the deploying web sites via TFS, it would have been nice to add the final release step on how to use the “Windows Machine Copy” task to copy the the code to the web site.

  9. Olamide James Avatar
    Olamide James

    Hello Benday,

    Thanks for this awesome article, i have a solution which contains 3 projects ( 2 class libraries and 1 MVC project). I created a build as defined in your pluralsight video and your blog, but i noticed that only the 2 class libraries produces release package but this $(build.artifactstagingdirectory)\for-deploy\website directory was never created neither was it available in the drop artifact.

    Kindly assist.


    1. Ben Day Avatar

      Hi —

      Are you seeing any errors in your log files? I wonder if you’re accidentally doing the deploy out of order. Or maybe you accidentally put the “dotnet publish -o” stuff in the wrong box.


  10. Matthew Avatar

    Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.