VS 2010 Web Deployment

This is the twenty-fifth in a series of blog posts I’m doing on the VS 2010 and .NET 4 release.

Today’s blog post is the first of several posts I’ll be doing that cover some of the improvements we’ve made around web deployment.  I’ll provide a high-level overview of some of the key improvements.  Subsequent posts will then go into more details about each feature and how best to take advantage of them.

Making Web Deployment Easier

Deploying your web application to a server is something that all (successful) projects need to do.  Without good tools to help you, deployment can be a cumbersome task – especially if you need to do it manually.

VS 2010 includes a bunch of improvements that make it much easier to deploy your ASP.NET web applications – and which enable you to build automated deployment procedures that make deployment easily reproducible.  The deployment features support not just deploying your web content – but also support customizing your web.config file settings, deploying/updating your databases, and managing your other dependencies.  You can kick-off deployments manually – or via automated scripts or as part of an automated build or continuous integration process.

Below is a high-level overview of some of the key new web deployment features in VS 2010.  I’ll do subsequent posts that provide more details on how to use/customize each of them.

New “Publish Web” Dialog

Visual Studio 2010 includes a new “Publish Web” dialog that you can use to quickly deploy a web application to a remote server.

You can activate the dialog by right-clicking on an ASP.NET Web Project node within the solution explorer, and then select the “Publish” context menu item:

image

Selecting this will bring up a “Publish Web” dialog which allows you to configure publish location settings. 

Configuring and Saving a Publish Profile

You only need to define your publish settings once – you can then save them as a named “Publish Profile” to enable you to quickly re-use them again later.

image

Above I’ve created a “ScottGu Site” profile, and configured it to deploy via FTPS (a version of FTP that uses SSL) to a remote server.  To deploy over FTPS select the “FTP” node in the drop-down, and then prefix the server location you want to publish to with the “ftps://” prefix. 

Note that you can either re-enter your password each time you deploy – or save the password for future uses in a secure location (just click the “Save Password” checkbox to do this.

Web Deploy

In addition to supporting FTP/FTPS, VS 2010 also supports a more powerful publish mechanism called “Web Deploy”.  Web Deploy (earlier known as MSDeploy) provides a much more comprehensive publishing and deployment mechanism than FTP. It not only allows you to publish files, but also allows you to publish IIS Web Server Settings, Database Schema/Data, Database Change Scripts, Security ACLs, and much more.

Web Deploy can be used to deploy applications both to a single server, as well as to multiple servers within a web farm.  Web Deploy is also now supported by many inexpensive Windows hosting providers (some as cheap as $3.50/month for an ASP.NET + SQL account).  You can find great ASP.NET hosters that support Web Deploy by visiting this page: http://asp.net/find-a-hoster.

One Click Publish Toolbar

Clicking the “Publish” button within the “Publish Web” dialog will publish a web application (and optionally associated database schema/content) to a remote web server. 

VS 2010 also supports a “one click” publish toolbar that you can add to your IDE to quickly publish/re-publish your project without having to load the  “Publish Web” dialog:

image

Just select your publish profile from the toolbar drop-down and then click the publish icon to the right of it to begin deploying your application. 

Web.Config Transformations

In most real-world deployment scenarios, the web.config file you use for development is different than the one you use for production deployment.  Typically you want to change environment settings like database connection-strings, making sure debug is turned off, and enabling custom errors so that end-users (and hackers) don’t see the internals of your application.

VS 2010 now makes it easy to customize/tweak/modify your web.config files as part of your publish/deployment process.  Specifically, you can now easily have build-configuration specific transformation files that can customize your web.config file prior to the application being deployed:

image

You can maintain a separate transform file per Visual Studio build-environment.  For example, you could configure your project/solution to have a “Debug”, “Staging” and “Release” build configuration – in which case VS will maintain three separate transform files for you.  VS will automatically apply the appropriate one at deployment time depending on what your VS environment is set to.

I will dive deeper into how to perform web.config file transformations in a future blog post.

Database Deployment

VS 2010 allows you to optionally deploy a database, along with your web application files, when are using the “Web Deploy” option as your deployment mechanism. Databases deployed this way can include both schema and data, and can optionally also include change scripts to update existing databases.

ASP.NET Web Projects in VS 2010 have a special page within their the “project properties” settings to configure database deployments:

image

I will dive deeper into how to perform database deployments in future blog posts.

Web Deployment Packages

VS 2010 also supports a packaging option that enables you to package up your ASP.NET Web Application (together with its dependencies like web.config, databases, ACLs, etc) into a .zip based deployment package file that you can optionally hand-off to an IT administrator who can then easily install it either via the IIS Admin Tool or via a command-line/powershell script. 

The deployment package you create can optionally expose application configuration settings that can be overridden (like directory locations, database connection-strings, etc).  When using the IIS7 Admin Tool, the install wizard can prompt the administrator for each setting to be customized – enabling you to provide a clean customization experience without having to write any custom code to-do so.  The settings can also obviously be passed as arguments on the command-line when using a command-line or Powershell script to deploy the application.

To create a web package within Visual Studio 2010, just right click on your ASP.NET Web Project node in the solution explorer and select the “Build Deployment Package” menu item:

image

This will compile your application, perform appropriate web.config transforms on it, optionally create .sql scripts for your database schema and data files, and then package them all up into a .zip deployment package file.  Adjacent to the .zip file you’ll file a deployment script file that you can use to automate deployment of the package to a remote server.

I will dive deeper into how to create web deployment packages in future blog posts.

Continuous Integration with Team Build

Most of the VS 2010 web deployment features that I described above are built on top of MSBuild tasks & targets. The “Team Build” feature of TFS also uses MSBuild, and supports running nightly builds, rolling builds, and enabling continuous integration. This means that you can create deployment packages, or automatically publish your web applications from a Team Build environment.

I will dive deeper into how to enable this in future blog posts.

Summary

Today’s blog post covered some of the new VS 2010 web deployment features at a high-level.  All of the above features Iwork with both VS 2010 as well as the free Visual Web Developer 2010 Express Edition.

Hopefully today’s post provided a broad outline of all the new deployment capabilities, and helped set context as to how they are useful. In future posts I’ll go deeper and walkthrough the specifics of how to really take full advantage of them.

Hope this helps,

Scott

P.S. In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: twitter.com/scottgu

49 Comments

  • I use these features in my web site and they really do make deployment almost a joy. Rather than having to psych myself up to do a release over a stiff drink, now I just click a button.

  • Multi web.config is great feature ...

    Thanks Scott.

    P.S. When "IIS Express" will be released...

  • @ScottGu: "... This means that you can create deployment packages, or automatically publish your web applications from a Team Build environment ..."

    Can't wait to hear more we are currently in the process making the second scenario where we publish the CI build to an internal test server if it suceeded.

  • Are you going to be doing a post on the database schema deployment/update tools at some point? There is little information about how to utilize these in real world scenarios right now on the web and in print.

  • I've got a product in the pipeline called ClickDeploy. I've prototyped it to about 50% complete -- it deploys web applications over http using a web service on the target server. It looks like there's a lot of overlap with Web Deploy, so I might can the project. Guess I need to go and take a really good look at Web Deploy.

  • Thanks Scott. Multi web.config files are very useful

  • It took me a while to figure out how to properly set up IIS and all required security settings on our own Windows Server 2008 R2, so I would be able to use one click publish right from my desktop (It's an intranet application withing our company). But after that was done, this Web Deploy really rocks, specially since I'm constantly modifying and building new features in the application, having to publish it often.

  • I am currently looking into MSDeploy and I'm really looking forward to your post about continuous integration and automated publishing. To my knowledge there is really a lack of information concerning this topic.

    Thanks!

  • Great, thanks for your time!

  • Thanks Scott. Are there any special requirements (or can you point me to a resource) on shared hosting environments? In particular, I'm thinking of SQL, and roles and membership services.

  • Hi there Scott,
    so FTPS is working, just tested. But one of my providers supports SFTP:// only, which VS rejects. What can we do?

  • Thanks, for this quick review.

    Is there a way in Database Deployment part of Web Deploy to support VS for database professional
    the support Database Projects Deployment through dbschema files (currently done through vsdbcmd)

    I hope the part Continuous Integration with Team Build will be expanded soon :)


    great work keep it that way.

  • Hi Scott,

    These features are awesome. I'm really interested in the Web Deploy will you do a follow up on that in the future, or provide some links. Like Marcio Gabe have an intranet but we also host our websites ourselves and this feature would be a real time saver. I'd like to know how to configure IIS to do that.

    Simon

  • What is the idea of this, you still have to build at new package for each environment?
    I like the way that BizTalk do. You build only one package with every config file included, so that the IT-Admin can choose the right configuration when installing the application on different environments

  • Hi Scott,

    Could you possible write a post about integrating this web deployment functionality with Team Build / Team Foundation Server 2010? Our team want to do this, but we've found the documentation on this topic to be extremely sparse.

  • i hope than when you write on MSBuild and tfs you explain how is possible to deploy the webapplication on a cluster environment

  • Good stuff!

    I guess this spells out the end of .MSI Windows Installer setup projects for the web future. While it's still available it seems to require IIS 6 Compatibility to be able to install on IIS7/IIS7.5 and certainly doesn't support web.config transformation or database deployement.

    We wrote a custom installer to detect the appropriate version of IIS and set write access to the relevant account upon installation. E.g. in IIS 7.5 you *should* be using the application pool identity (using ICACLS) to grant the permission. Would I be able to do the same with these new technologies? Is it easy?

    Thanks,
    Jaans

  • This is great feature. I am software developer in one company. We often have to upload change on live server. some time we forget the which version are going to upload from this feature we can synchronize our development with live server.

    want to hear more from you.

  • Can I use web deployment packages with Web Site projects instead of Web Application projects?

  • Scott,

    We were wondering if the Web.Config Transformations also applies to other config files (such as a ConnectString.Config file) so that we can target these other configuration files to the destination environment as well.

  • I understand how it automatically updates the database schema, but what about rows in tables? We frequently need to add new tables or columns to existing tables and then populate data in those rows or columns. The only way I can see to do this is to add a SQL script under the web project deploy, but then I assume it'll get run every time a deployment is made from that point on (which is undesirable; when you're updating a million rows, that can take a while). Is there a better approach?

  • NaibStilgar: Not as far as I could find.

    I still don't understand why the Web Site projects are constantly treated as second-class citizens in such cases. I have read that Microsoft maintains that the Web Site projects are not dead, and will still be supported, but the support when it comes to such (extremely useful!) features really seems to be limited, if it exists at all.

    Being able to make simple updates to the code of a running site in an unfortunate reality, which the Web Application project doesn't take into account.

    I would be interested to know - does Microsoft actually have any metrics on how many productive web sites use one form over the other?

  • Great posting, as always. Re: the web deployment packages could you at some point demonstrate how to best use those from the command line? For instance we want to publish from the build box, not from developers' machines. Hopefully there's an MSBuild target buried in there for this?

  • Thanks Scott. In a Team Build environment, do you need to have a separate CI build for each environment, or can that be specified at deployment time? Can the CI server simply build the package and drop it somewhere for the network team to deploy at a later date?

  • Looking forward to your future posts on automating this with team build. Possibly cover farm deployments? I've never used the GUI based features for deploying things like click once or web deployments beyond the first couple weeks of a green project.

  • I agree with previous posts about why wasn't web site projects handled with this new deployment feature of VS2010. Web site projects were the new way to create Web projects when VS2005 came out.....then they became the orphan child. We currently use Web Deployment projects with Team Build to push website files to Development and Test Web Servers. Scott, is there any plan to update the new Deployment feature with Web Site projects?

    Thanks for all of the posts you do....they are of great use and reference.

  • like Torben said in his comment, it would be great to be able to make ONE package with every configurations and compilations (debug, staging, release). That way, we only have to handle one package that is good for all environment.

    The problem with "one package per type of compilation" is that we can't know for sure that each package (debug, staging, release) will come from the same version of code.

    or maybe i missed something with WebDeploy? can we do that?

    skoub

  • What about precompiling application and merging into 1 DLL... I actually like to keep only DLL on the server without source code..
    That helps to fight temptation fix small bugs on production server :)
    I do not see aspnet_merge.exe in .NET 4.0 folder.

  • Scott, this is much improved from prior versions, but I am still disappointed that pre-compilation and merging is still missing from the VS after 5 years.

  • Good post! It would be very helpful to get a similar blog post on how to configure IIS on the server side to enable this.

  • It would be nice if you can post how to deploy to Microsoft Azure.

  • I'm using Team City to pull changes from SVN

    I'd like to use MSBuild/MSDeploy to run after latest and copy the files to the web directory on that machine

    This is asp.net mvc (net 4.0)

  • Nice features. Is this applicable only for web application project or for website project as well?

  • Good Stuff!!
    It would be nice, if we get some such feature for Sharepoint deployment as well :)

  • I gave up using Visual Studio to deploy anything a long time ago, besides, with an established build process in place it's much more reliable, and doesn't encourage desktop-builds like this.

  • The fact that none of this works with Azure is very frustrating.

    Even the web.config transformations don't work. I hope that you are able to address this in a hotfix for the Azure VS tools.

  • Scott:

    These tools look great for IT shops, and for ISVs that "own" their web site, but we have had some problems with mass distribution.

    I work for an ISV, and some of our products are intranet applications -- the customer installs them on their web server. Since we are a vendor, we want to distribute our web apps with MSI -- and they are kind of sophisticated MSI's -- we have custom actions to create Event Log application sources, we create an app pool for our product, we modify the web.config based upon user input to the setup wizard, etc. All so that someone who probably is an IT person, but who doesn't have detailed information about our product can install it and get it right just by running setup. (just as you would with a client-side app). My point is that we do stuff that you can't do with just a .zip deployment.

    Here's what we did in the past (VS 05 and 08), it was a little clunky, but it worked: We installed the WebDeploy Visual Studio add-in. We used the WebDeploy add-in to precompile our aspx pages, and then we built an MSI from WebDeploy's output. With 2010, I haven't seen an option to precompile, so we will probably have to to write some build scripts. Not the end of the world, but a little more support for ISVs would be welcome.

  • If I have Web Deploy installed on my dedicated IIS Server, what do I need to do to get this working with VS2010 one-click publish?

  • Great post Scott! I have just started building my own website and the web deployment feature is so good.

    Can't wait for your post on database deployment, the one click publish for databases is a big plus, the VS family is getting better and better everyday. Great work :)

  • Are you going to be doing a post on the database schema deployment/update tools at some point? There is little information about how to utilize these in real world scenarios right now on the web and in print.

  • i'm using crystal reports in my asp.net web application when i'm use this method my rpt files are missing in publish folder...so i have to add those files manually..

  • HI, As always I am grateful for the great job you do and the clear way in which you present things. However I am really confused about the situation with regards to Express.
    In your final paragraph you say "as well as the free Visual Web Developer 2010 Express Edition.".
    I have a complicated data site under development that was started using my full 2008 version and, when 2010 was released I downloaded the Express version to try it out. I converted my site to 2010 Express and now want to deploy to a staging site but it would seem that the only options open to me are to "Copy Website" , to convert to a web application (tried this and it's more trouble than it's worth) or to upgrade to a full version of 2010.

    The options and methods shared in your article do NOT seem to be available to the Express edition.

    Can you cast any light on this"?

    Thanks.

    Ken Hull

  • @KenHull,

    >>>>>>>> I have a complicated data site under development that was started using my full 2008 version and, when 2010 was released I downloaded the Express version to try it out. I converted my site to 2010 Express and now want to deploy to a staging site but it would seem that the only options open to me are to "Copy Website" , to convert to a web application (tried this and it's more trouble than it's worth) or to upgrade to a full version of 2010.

    The Web Deployment feature in VS 2010 is supported in Express - but unfortunately only for Web Application Projects (and not the Web Site project model). This is also true with Visual Studio Pro (where the advanced deployment features only work with web application projects - both Web Forms and MVC ones). Unfortunately we didn't have time in the schedule to add support for them with Web Site projects - so that isn't supported just yet.

    Sorry about the confusion and missing feature!

    Scott

  • Thanks Scott, good stuff as always. Looking forward to your digging into the new web.config specifics

  • HI Scott,
    Is it possible for you blog the feature "Copy Website ..."? I tried it a couple of times to copy my new changes to my production site from my local. It always give me "Unable to open the site" error.

    Thanks
    Helen

  • thanks a lot

  • The one issue I have with the publish profiles is that you can't set the Build configuration.

    Since we have differing Web.config (connection strings mostly) for each of our three environments (dev, stage, prod) I have to remember to select the correct build configuration, then the correct publish profile, before hitting the publish button.

    Not a big deal since I'm doing it often enough, but it makes me (more than usually) nervous to hand this off to someone else in the team.

  • I recently converted a VS 2008 (.NET v3.5 Framework target) web site/solution to VS 2010 (.NET 4.0 target) and the converted site does not even show the option to Add Config Transformations when I right-click with the web.config is selected. Furthermore, configuration manager does not allow me to add any solution configurations with the create new project configurations option checked (that checkbox is disabled). The Build Deployment Package option is not even present either.

    Any ideas on how correct this so that I can utilize the features mentioned in this post?

  • I would like to see web.config transformation support for web setup projects.
    We are heavily using .msi files in the enterprise environment since all deployments are done by computing and we don't even have access to the servers. You can also check from the add/remove program list which versions are installed. Managing web.config files for multiple environments is painful and web config transformations feature looks very promising.

Comments have been disabled for this content.