5
votes

I'm using TFS 2012 to automate a build of a solution which contains multiple windows services and two web applicaitons.

I've used the guide I found here to customize the build process template so that the windows services are put in a folder structure that I like. Specifically:

  1. \dropserver\droproot\MyApp\BuildNumber\
    • \Service1
    • \Service2
    • \Service3
    • \Service4

This works great, but unfortunately it doesn't work for web applicaitons. If I used the same strategy for those, I just get the contents of /bin for each web app, rather than the full site contents.

MSBuild typically uses the web application targets to handle this, but for some reason, this doesn't work when you customize the build as I have. I no longer get the _PublishedWebSites folder in the build output. (I'm guessing that's because I cleared our the OutDir property of the MSBuild task.)

Has anybody done something like this and gotten it to work with web applications as well?

5
Can you open your website projects in notepad and check that the following is in there: <DeployOnBuild>True</DeployOnBuild> - Matt Whetton

5 Answers

1
votes

I think I can help with this, it looks like in the build targets that the published websites folder isn't created if the OutDir is the same as the OutputPath.

So this isn't perfect, but if you add the following into the csproj file in the first property group, you'll get everything deployed into "\bin\deploy\" including the _PublishedWebsites folder

<DeployOnBuild>True</DeployOnBuild>
<OutDir>bin\deploy\</OutDir>
1
votes

With a bit of customization, this solution ended up working for me:

http://www.edsquared.com/2011/01/31/Customizable+Output+Directories+For+TFS+2010+Build.aspx

Basically, did what that link recommended, but also leveraged a new solution configuration (which I called TeamBuild) rather than conditional property definitions.

I believe the key to making this all work was the passing of the outputDirectory as the TeamBuildOutDir argument to MSBuild. Embedding this variable reference in the OutDir or OutputPath variable was allowed Team Build to build to the correct staging location and then automatically copy files from that location to the drop folder.

I'm going to take this a little futher and get rid of the whole _PublishedWebSites thing, but that will be done entirely in the build workflow.

EDIT: TFS 2013 supports this natively with a simply build configuration option:

enter image description here

0
votes

Take a look at this thread as this post as well. Team Build: Publish locally using MSDeploy Since you need all the files for your web projects, you need to trigger the publishing process, and by tweaking the destination of that process, you can have all of your files copied where you need them. I think option (2) from his answer will work for you. I hope that helps.

0
votes

As I can see in your reference link, it will just compile and package the binaries. It does not deploy the website by the steps mentioned in that.

If you want to get the .html, .css, .js etc. under the _PublishedWebSites folder, you need to do a Web Deployment. This manually we can do by clicking the publish option from right click menu of your VS project and by selecting Publish Method as File System.

But, since you need to automate this in your build and drop it in custom drop folder, you may need to manipulate your MSBuild script by calling a AspNetCompiler task. You can get more information on this at the MSDN link. By specifying the TargetPath while you call this target you can get your Web files deployed at the appropriate custom drop folder.

Happy Scripting.

0
votes

Have you check this blog, this solved my problem where I wanted customized TeamBuild Ouput Directory. Customizable O/P with TFS 2013

Customizaable O/P with TFS 2012 and .NET Framework 4.5