Auto deployment of my web application with Team Build 2010 to add Interactive Testing

by Ewald Hofman 12. April 2010 04:03

Since the beginning of Team Foundation Server, Team Build was part of the environment. In TFS 2010 the ability to perform CodedUI tests is introduced, as well as the Data Collectors Intellitrace and Test Impact. These data collectors don’t work for an ASP.NET application when the web application is hosted by the ASP Development Server. So in order to use the CodedUI tests including with these collectors you first need to deploy the application in IIS.

You can use Lab Management for this purpose, but if you don’t have this you can also use the Interactive Build mode of Team Build. Normally the Build is a windows service, but a windows service cannot interact with the desktop. When you run in interactive mode, the build runs in a command window. You can set an interactive build with the following steps:

  1. Open the TFS Admin Console, and navigate to the Build Configuration

     image

  2. Stop the build service (use the Stop link on the Build Service in this window)
  3. Go to the properties of the Build Service (use the Properties link on the Build Service in this window)
  4. Change the option “Run the Build Service as” to Interactive Process and provide the account it is running under. Close the window by clicking Start.

    image 

  5. The command window will pop up now

    image

  6. You can now queue your builds and perform CodedUI tests in your build.

But you are not ready yet. The requirement was that the CodedUI test had to run in IIS, and team build won’t deploy the compiled application automatically to IIS. Microsoft has added MSDeploy to Visual Studio 2010 which we are going to use to setup the auto deployment. Follow the following steps to setup the auto deployment

  1. First you have to setup the deployment in your project. See the blog of Vishal Joshi for more information on this topic. He is the Program Manager at Microsoft for these technologies. You can start with http://vishaljoshi.blogspot.com/2009/05/web-1-click-publish-with-vs-2010.html
  2. Edit the build definition and go to the Process tab
  3. Open the Advanced group
  4. Add the value “/p:DeployOnBuild=True” to the MSBuild Arguments. Providing this property will ensure that the deployment package is created during the build. It will not automatically deploy the application, but it will create a zip file with all files and a command file to actually execute the deployment

    image

  5. We now have to make sure that the actual deployment is also executed. To do this, we go to the Build Events of the Web Application. You can find these by opening the properties of the Web Application and go to the Build Events tab.

    image

  6. Note that the events you put in here are executed always. To ensure that it is only executed during your build and not when you build locally, you must use the Debug configuration when building locally and the Release configuration for the automated build.
  7. You can now add the following lines to the Post-build event command line (rename the <application> with your own application name)

    if "$(ConfigurationName)" == "Release" "$(TargetDir)_PublishedWebsites\<application>.Web_Package\<application>.Web.deploy.cmd" /Y

    UPDATE 11 October 2010
    If you want to deploy your website to a remote server, then you can add the /M:<Server> to the command line. The Post-build event will then look like
    if "$(ConfigurationName)" == "Release" "$(TargetDir)_PublishedWebsites\<application>.Web_Package\<application>.Web.deploy.cmd" /Y /M:MyQAServer
  8. Check in your project, and run the build. The CodedUI tests will now run in the new environment, with Test Impact and IntelliTrace enabled.

Happy building….

Tags:

Comments

5/14/2010 11:44:05 AM #

JimSimmons

I'm having trouble with something very similar to this. I'm using a robocopy script to copy the _PublishedWebsites to their proper place. But when I use $(TargetDir) it shows up in the log as using a local path instead of the UNC path for the Drop Folder. Is there any way to get this Drop Folder path dynamically into my post build event command line?

Thanx. -Jim

JimSimmons United States |

5/14/2010 12:08:37 PM #

Ewald Hofman

The drop location is a variable that is known by team build and not in the post build event.

You should override the AfterCompile target in your build script.

Ewald Hofman Netherlands |

5/16/2010 8:21:06 AM #

JimSimmons

Awesome! Thanks for the info!

One other quick question on build. I'm setting up a new Team 2010 environment for my Devs, and I'm trying to use build services to build to our QA environment which is on a separate, untrusted domain. I'm using credential manager in 2008 R2 to connect to my QA web servers, but I am getting the error:

The system detected a possible attempt to compromise security. Please ensure that you can contact the server that authenticated you.

When I reboot or restart the build service, it works again for a while, and then errors out again with the above error. Any idea what I can do?

Thanx again! -Jim

JimSimmons United States |

5/16/2010 11:42:08 PM #

Ewald Hofman

That is an area I have no experience in. You can try to post your question on the MSDN forum: social.msdn.microsoft.com/.../threads

Ewald Hofman Netherlands |

5/17/2010 9:35:24 AM #

JimSimmons

Cool. I really appreciate your help.

Thanks. -Jim

JimSimmons United States |

6/2/2010 2:59:49 AM #

Rajshekar

Dear Jim,
I have started to work on automated deployment solution using TFS 2008. Can you guide me with correct script to deploy the application after the successful build. I got a peice of code from internet, I used it but, once the same is built, the application is not getting deployed. Can u guide me please??

best regards
Rajshekar

Rajshekar India |

6/2/2010 3:12:16 AM #

Rajshekar

I want to deploy my web application once the same is successfully built using TFS build 2008. Can you help me what & where to write in .proj file.

Rajshekar India |

6/2/2010 3:48:22 AM #

Ewald Hofman

This post is for Visual Studio 2010. If you want to deploy your website in VS 2008, you could make use of copy tasks in your build script. An example you can find at blogs.msdn.com/.../490068.aspx

Ewald Hofman Netherlands |

6/9/2010 12:47:28 AM #

Gregory

Hello Ewald,

This a very interesting post.
I'am actually having trouble dealing with de DeployOnBuld property. Build Log show that "MsBuild.exe" instruction is well formatted, but the "zip package" is not generated in the Publish folder. I actually tried many tips, documentation is missing...
Is that "/pLaughingeployOnBuild=true" enough to generate the package ?

Thanks,
Grégory

Gregory France |

6/9/2010 12:53:56 AM #

Ewald Hofman

Did you configure the deployment? see the blog of vishal joshi for more details on that topic.

Ewald Hofman Netherlands |

8/6/2010 6:27:15 AM #

trackback

Running MSDeploy to a remote box from inside a TFS 2010 Build

A fellow MVP Ewald Hofman wrote a great post on getting an Web Application to deploy as part of a TFS

But it works on my PC! |

8/6/2010 6:38:41 AM #

trackback

Running MSDeploy to a remote box from inside a TFS 2010 Build

A fellow MVP Ewald Hofman wrote a great post on getting an Web Application to deploy as part of a TFS

Richard Fennell |

9/1/2010 10:05:28 AM #

pingback

Pingback from blog.sanc.idv.tw

TFS 2010 Team Build 後自動發佈 | 天空的垃圾場

blog.sanc.idv.tw |

10/9/2010 3:12:48 PM #

M.Radwan

WoW, it's great article man you did exactly what I am looking for, nice to see such articles , I have a question if you don't mind it's out of the deployment but it's related to Team build 2010 I used Microsoft Ajax Minifier and it only work local but not on the server could you give a hand? I will relay appreciate that and I will understand if you couldn't, you can see my post to it for stackoverfollw and ASP.NET

stackoverflow.com/.../why-microsoft-ajax-minifier-doesnt-generate-mini-file-with-team-build-2010

http://forums.asp.net/t/1611349.aspx

Thanks

M.Radwan Egypt |

10/9/2010 4:27:13 PM #

M.Radwan

I have a question if TFS on PC A and the drop folder on PC B and I want to deploy in the PC B for example if the PC A is a Dev server and PC B is QA server and I just want to deploy my project to the QA but the build occur in the Dev Server?

M.Radwan Egypt |

10/10/2010 10:46:58 PM #

Ewald Hofman

You can add the /M:<RemoteServer> to the post build event to run the package on the remote server. Your post build event will then be

if "$(ConfigurationName)" == "Release" "$(TargetDir)_PublishedWebsites\<application>.Web_Package\<application>.Web.deploy.cmd" /Y /M:MyQAServer

Ewald Hofman Netherlands |

10/12/2010 11:26:20 PM #

M.Radwan

Yes that's right it works thanks

M.Radwan Egypt |

10/18/2010 7:07:00 AM #

Graham Abell

I've followed this procedure and the steps on Vishals blog but my project won't publish the deployment package.

I don't see any errors in the log files relating to it. I can publish the package if I manually select it from the context menu or by using Web Deploy in the Publish dialog.

I'm completely stumped as to why it won't generate the .zip file and the ancillary bits...

Any help would be muchly appreciated! Smile

Graham Abell Ireland |

10/23/2010 2:12:22 AM #

pingback

Pingback from mohamedradwan.wordpress.com

Auto Deploy your Website for QA with Team Build « Mohamed Radwan's Blog

mohamedradwan.wordpress.com |

5/4/2011 7:48:31 AM #

pingback

Pingback from learntfs.com

May 4, 2011 – Visual Studio and TFS Daily | Learn TFS

learntfs.com |

12/14/2012 11:45:47 PM #

pingback

Pingback from siteduct.com

Trackback Submitter Software

siteduct.com |

7/31/2013 11:38:46 AM #

pingback

Pingback from followliker.com

twitter follower bot

followliker.com |

10/6/2013 8:34:36 AM #

pingback

Pingback from alexatrafficracer.org

Wine Lovers Guide

alexatrafficracer.org |

Comments are closed

Powered by BlogEngine.NET 1.6.1.0
Theme by Mads Kristensen


ClusterMap

Statistics

Statistics created at 09 Sep 2009

121 posts
493 comments
328 raters
1945781 visit (1042 per day)
26 users online

Recent comments

Comment RSS