VS 2005 Web Application Projects, MSBuild, and Continuous Integrations

One thing that I thought would be worth spending a few minutes writing about is the built-in MSBuild support provided with the VS 2005 Web Application Project Model option.

The project file used with VS 2005 Web Application Projects is a standard XML-based MSBuild file (just like a class library or any other project type within VS 2005), and allows you to add any custom MSBuild action with it.  Here is a pointer to an old blog post I wrote that listed a number of free MSBuild actions you can download and incorporate (including ones to create IIS application pools, FTP content, and provision databases).  When you do a build within the Visual Studio IDE, it will use the MSBuild Project file and launch the appropriate actions as part of the build.

The .NET Framework Redist actually includes and installs the core MSBuild utility system, as well as the VB and C# command-line compilers.  This means that you can copy a MSBuild based solution or project file to any machine that has the .NET Framework installed and build it from the command-line (you can just type: "msbuild mysolution.sln" to build every project within the solution from the command-line).  This does not require that Visual Studio is installed on the machine.  Two common scenarios where this is very useful are for centralized build servers, and for continuous integration scenarios. 

If you aren't familiar with the concept of continuous integrations, I'd definitely recommend spending time reading up on it (especially if you are in a team development environment where I think it is critical).  In a continuous integration environment you setup a machine that monitors your source code repository and automatically syncs and builds the full code-base, and runs all unit tests against the produced build, whenever a checkin is made.  It then sends an email report to the developer (or entire team) on the results.  The benefit with this is that it helps ensure the source tree is kept in an always clean/buildable state, and avoids issues where developers forget to checkin some files, or have other changes on their machines that impact the stability or success of the build.  We use this model heavily within Microsoft. No checkin is allowed to reach the ASP.NET feature team branch until it has been synched, built and tested on a centralized machine (which we affectionately call our "buddy machine") first.

The new Team Foundation Server that ships as part of the Visual Studio Team System family can be configured to enable continuous integration support.   Alternatively, you can also use the very popular CruiseControl.NET to achieve this, which is a free open-source product that is hosted here.  You can use both in conjunction with MSBuild files to launch and automate the build process from the command-line without needing Visual Studio installed on the machine.

One thing to be aware of with VS 2005 Web Application Projects is that the MSBuild project files created have an import reference to a VS 2005 Web Application Project .targets file.  You'll want to make sure you copy this .targets file to any build servers that don' t have VS 2005 and the Web Application Project option installed to ensure that command-line builds of these project types work fine. 

Scott Allen talks about the specifics of copying this VS 2005 Web Application Project .targets file (including the disk location where it is stored) in more detail on his excellent blog here.

Hope this helps,

Scott

 

12 Comments

  • > This does not require that Visual Studio is installed on the machine... ... unless the solution contains a Setup project, which I was amazed to find is not supported by MSBuild, so that devenv.exe is needed on the build server. It would be great to see this rectified in a future version, i.e. a Setup project that uses an XML project file format like other VS2005 projects and can be built without devenv.exe.

  • Hi Scott, will we see the Web Application Project for VS Web Developer Express edition some day?

  • Don't forget Draco. In some ways, it's always been more mature than cruisecontrol

  • Any idea when will this be available for Visual Basic 2005 Express?

  • Hi Joe,

    That is a good point. I'll follow up with that team to see what the plan is for setup going forward.

    Thanks,

    Scott

  • Hi Impu,

    When you say "ready for VB Express" are you referring to the VS 2005 Web Application Project option or MSBuild support in general? Note that MSBuild support is there now -- the VS 2005 Web Application Project option only supports VS Standard and higher currently, although we are looking at possibly adding it to the express SKUs in the next release too (along with the web site option).

    Thanks,

    Scott

  • Hi Val,

    We are looking at possibly adding the web application project option to Visual Web Developer Express for the next release. There are some technical reasons why it doesn't work today (the VWD express product doesn't support class library projects, which the web application project option depends on).

    Hope this helps,

    Scott

  • Good point! My team is also using the VS2005 Web Application Project to be able do continuous integration with CCNet.

    CCNet basically calls a NAnt scripts, which calls MSBuild to build the solution files. Works great!

  • > I'll follow up with that team to see what the plan is for setup going forward.



    Thanks.  If there are any plans in this area it would be nice to see a post describing them.

  • I too would love to use MSBuild but unfortunately have to build solutions containing setup (deployment) projects. Currently we run devenv from the cmd line but I would like to invoke it from an ASP.NET webservice. Even in cmd line mode devenv seems to want to interact with the desktop and I havent been able to figure out a way to get it to work from ASP.NET. It doesnt seem to work with NT AUTHORITY\NETWORK SERVICE and changing the user/password of the ProcessStartInfo causes some incompatibility with the winstation/desktop. Im open to (and tried)pinvoke'ing win32 apis (createprocesswithlogon,etc) to get access to desktop settings but still havent figured out the magic juju. CC.NET et al seem to sidestep this issue by running their own webservers which I dont want to do.
    Anyone had any luck launching devenv or any other desktop interacting app from asp.net?
    thanks
    -john

  • I love the fact that Web Application Projects are back, however it has caused somewhat of a problem for me.



    With Web Site Projects I've been using CruiseControl.Net to continuously build to a dev server. This was working superbly as all the files I wanted to deploy were put into a folder under a PreCompiledWeb folder, however with Web Application Projects I have to Publish in order to get the same result.



    The problem is when I try to Publish from the command line, I get an error:
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(3150,9): error : A signing key is required in order to publish this project. Publishing from Visual Studio 2005 will automatically configure a signing key for this project.



    I tried creating an snk for the project but it didn't help. Any ideas?



    Regards,

    Andrew.

  • Hi Andrew,

    Can you send me an email with more details about this issue? I can then loop you in with someone on my team to help.

    Thx!

    Scott

Comments have been disabled for this content.