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:
- Open the TFS Admin Console, and navigate to the Build Configuration
- Stop the build service (use the Stop link on the Build Service in this window)
- Go to the properties of the Build Service (use the Properties link on the Build Service in this window)
- 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.
- The command window will pop up now
- 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
- 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
- Edit the build definition and go to the Process tab
- Open the Advanced group
- 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
- 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.
- 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.
- 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
- Check in your project, and run the build. The CodedUI tests will now run in the new environment, with Test Impact and IntelliTrace enabled.