Automating Deployment with Microsoft Web Deploy

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

This blog post continues a series of posts I’m doing that cover the new improvements we made around web deployment.  In my first post in the deployment series I provided an overview of the new VS 2010 Web Deployment features.

In today’s post I’m going to be discussing Microsoft Web Deploy – which is a free server technology that enables a comprehensive publishing and deployment mechanism.  Web Deploy enables you to not only publish files – but also provision database schema/data, run database change scripts, set security ACLs, and more.  All of these deployment steps can be automated using Visual Studio.

This post will provide a step by step tutorial on how to install Web Deploy and enable it on a web-server.  I’ll then demonstrate how you can use Visual Studio 2010 to directly publish to servers using Web Deploy, as well as how you can use Visual Studio to create installation packages that you can use to automate the deployment of your applications.

Web Deploy – And Why Should You Care

Deploying a web application or site involves several steps. You typically need to:

  • Copy files and folders
  • Provision database schema and optionally populate database content
  • Set appropriate read/write and security ACLs on files and folders
  • Install and configure SSL certificates
  • Deploy other misc dependencies (Event logs, GAC libraries, COM objects, etc)

Performing all of these steps manually is tiresome, slow, and dangerous (since manual deployment steps are error prone).  Enabling an automated process that allows you to quickly provision and deploy applications on a server helps reduce the chances of things going wrong, and can dramatically improve the cycle time it takes for you to get a change you make in an application into production. 

Microsoft Web Deploy

Web Deploy is a free technology built by my team that can improve web deployment. It is a deployment service that runs on a server, and enables you to either locally or remotely deploy applications onto it.  Web Deploy includes built-in support for creating virtual directories and applications within IIS, copying files and folders, provisioning databases (both SQL Server and MySQL), setting file-system ACLs and more (it even includes built-in providers for things like setting registry entries, registering COM components, etc).  In addition to having these built-in deployment features, it also supports a .NET based provider API that enables you to create and plug-in your own custom deployment actions – which allow you to customize it however you want.

The wire-protocol for Web Deploy is HTTPS – which means Web Deploy can be used through firewalls (enabling easy, secure, deployment to remote hosted servers).  Web Deploy also supports both admin and non-admin deployment scenarios.  The non-admin scenarios enable administrators to configure Web Deploy on a server, and then delegate a subset of deployment capabilities to developers who do not have admin accounts on the production server.  This enables a very secure and flexible deployment approach.  I’ll cover the configuration steps to enable delegated deployment scenarios in my next blog post in this series.

Installing Web Deploy on Windows Server 2008

Visual Studio 2010 (and Visual Web Developer 2010 Express) will by default install Web Deploy on your development machine as part of their setup.  This provides you with what you need to create Web Deployment setup packages within VS, as well as publish them to remote servers that have the Web Deploy service installed and enabled.

Below are the steps for how to install Web Deploy on a production server running IIS 7.x on Windows Server 2008 or Windows Server 2008 R2:

1) Download and run the Microsoft Web Platform Installer on your production server.

2) Click the “Web Platform” tab within the Web Platform Installer, then click the “Customize” link under the “Web Server” section.  Select the “Web Deployment Tool 1.1” feature as well as the “Management Service” feature:

image

3) Press the Install Button.  This will download and install the Web Deployment Package, and enable the IIS Management Service feature that is built-into Windows.

Enabling Deployments with Windows Server 2008

We now have Web Deploy installed – next we need to enable deployments with it.

Web Deploy supports deployments by administrators, as well as deployments by non-administrators (aka delegated deployments). In this blog post, I’m going to cover how to enable deployments using an account that has administrator permissions on the server.  I will cover how to enable delegated deployments by developers that do not have an administrator account in my next blog post in this series.

1) The first step to enable Web Deploy is to start the IIS Admin Tool (Start -> Run -> inetmgr.exe).  Then double-click the “Management Service Delegation” icon on the home-screen:

image

When you double-click the “Management Service Delegation” icon it will bring you to a page that looks like below.  In the Actions pane, click the “Edit Feature Settings…” link.  This will bring up the “Edit Feature Settings” dialog - check the “Allow administrators to bypass rules” option within this dialog box.  This will allow those with Administrator accounts on the server to bypass the delegation capabilities of the Web Management Service and perform actions using their administrator capabilities:

image

Then return back to the IIS Admin Tool home-screen and double click the “Management Service” icon:

image 

When you double-click the “Management Service” icon it will bring you to a page that looks like below.  Click the “Enable Remote Connections” checkbox to enable remote deployments.  You can optionally choose which IP address and port the management service runs on – as well as what client IP addresses are allowed to connect with it.  You can tweak these settings to lock down who can access the deployment service.

When you are done click the “Start” link within the “Actions” tab to start the Web Management Service on the server:

image

The server is now setup for deployments using an administrator account with Web Deploy.

Important Tip: One thing to watch for is whether you have a firewall enabled on your server, or within the cluster where your server is hosted.  By default the Management Service runs using the HTTPS protocol on port 8172.  This port might be locked down by default depending on your hosting configuration.  If so you should either unlock it with your firewall/hoster – or pick a different port number that is allowed.  You can test to see whether the management service is available simply by opening up a browser and accessing it using a URL like: https://yourservername:8172/MsDeploy.axd – if you are prompted for a username/password then you know it is working, and there is no firewall blocking access to it.  If it times out then it is likely that a firewall is blocking it.

Enabling Web Deploy on a non-Windows Server 2008 Operating System

The steps above demonstrate how to enable the Web Deploy service on a Windows Server 2008 or Windows Server 2008 R2 operating system.  The IIS 7 Management Service is built-into these operating systems, and Web Deploy takes advantage of it.

If you try and follow the above steps on Windows 7, Windows Vista, or Windows Server 2003, though, you’ll notice that the IIS Management Service (and its icon within the IIS admin tool) isn’t available.  Instead you need to follow a slightly different set of steps to enable the Web Deploy service.

Enabling Web Deploy on Windows 7, Windows Vista, and Windows Server 2003

You can enable the Web Deploy publishing service on Windows 7, Windows Vista, and Windows Server 2003 using the below steps:

1) Open an elevated command prompt (meaning you right-click and launch it using the “run as administrator” command)

2) Type “net start msdepsvc” to start the “Web Deploy Agent Service”:

image

3) To confirm that the publishing service is working, change directory to the “c:\Program Files\IIS\Microsoft Web Deploy”, and then type the command “msdeploy –verb:dump –source:appHostConfig,computername=localhost”:

image

This should cause the local msdeploy client to connect to the publishing service you just enabled and dump out the current status of your web-servers ApplicationHost.Config file:

image

If a bunch of spew comes out then you know that everything is working and you have just enabled Web Deploy for publishing.  Using this approach won’t allow you to enable “delegated access” (which allows non-admin accounts to deploy – and which I’ll cover in more depth in my next blog post) – but will allow those with an account with admin permissions to deploy to the machine.

Using the “Publish Web” Dialog within Visual Studio

Now that we have our web server enabled with Web Deploy, let’s try deploying something to it within the Visual Studio IDE.

VS 2010 includes a new “Publish Web" feature that you can use to quickly deploy a web application to a remote server.  You can activate it by right-clicking on any ASP.NET Web Application Project (both Web Forms and MVC varieties), and then select the “Publish” context menu item:

image

Selecting this will bring up a “Publish Web” dialog which allows you to configure publish settings.  You can use this dialog to publish an ASP.NET application to a remote user using FTP/FTPS, Web Deploy, or FrontPage Server Extensions.

We’ll select the “Web Deploy” option from the drop-down, and then enter the publishing information of our Web Deploy server:

image

Note that you only have to fill these settings out once – you can then save them as a “Publish Profile” using the “Save/Rename/Delete” buttons at the top.  Publish profiles allow you to save multiple deployment/publishing options and quickly flip between them depending on what server you want to use.

A few notes about the various options you can specify:

Service URL: This is the URL of the Web Deploy Management Service.  If you are using Windows Server 2008 the default format of the URL is https://mysite:8172/MsDeploy.axd Note the protocol is “https://” and the port should match whatever you specified when you enabled the IIS Management Service above. 

If you are publishing against a Windows Server 2003, Windows 7, or Windows Vista machine then the default format of the URL is http://server-name/ (not https – since the security credentials are sent using built-in Windows authentication which is encrypted). You also don’t need to specify a port number with Windows Server 2003, Windows 7 or Windows Vista.
Site/Application: This allows you to specify the site name (and optional application name) on the remote server that you want to install the application to.  You can publish your project as a site, in which case you might specify something like www.mysite.com as the sitename, or “Default Web Site” if you just want to publish at whatever the default root site name is. 

Important: The site name you specify needs to correspond to the same site-name that shows up in the IIS admin tool.  So if you’ve registered the www.scottgu.com site using the friendly name “ScottGu’s Site” or just “scottgu.com” when you created it in IIS you need to make sure the site name you specify as a publish setting corresponds to the friendly name (so you’d specify “ScottGu’s site” instead of www.scottgu.com if that is what shows up in the IIS admin tool as the site name).  If you specify this incorrectly you’ll get an error that says the the remote agent “could not be contacted”.

Alternatively you can publish to a sub-application location using a value like “www.mysite.com/myapplication” or “ScottGu Site/myapplication”.  If the /myapplication vdir and application doesn’t already exist, then the Web Deploy service will create it for you and then publish your project to it. 

You can optionally indicate that you want this sub-path to be a virtual directory (the default) or an application by checking the “Mark as IIS Application on Destination” checkbox.
Credentials: If you are publishing to a remote server that is not part of your windows domain, then you can specify your username/password in the publish dialog.  This username/password combination can either map to a Windows account on the remote server – or alternatively map to IIS usernames (which enable more flexible locked-down delegation options – which I’ll cover in my next blog post).

Important: Unless you’ve installed a signed SSL certificate on your remote server, make sure you check the “Allow untrusted certificate” checkbox.  By default Web Deploy will install a cert for you to use that is unique (and unsigned) – and if you don’t check this checkbox your login will fail because VS won’t trust an unsigned cert.
Other Notes: There is a checkbox provided that allows you to indicate whether you want to “Leave extra files on destination” or not.  If you uncheck this then the existing files in the site/application you are publishing to will be deleted if they don’t match what is currently in your VS project.

Once you have filled out the Publish settings, you can click the “Publish” button and it will connect to the remote Web Deploy service and deploy your application to the location you provided.  Your “Output” windows within Visual Studio will show output like below that explains how it was deployed and the actions that occurred with the publish step:

image

The above project is a basic web project with just a few files and directories within it.  Web Deploy will handle copying all of the file and setting appropriate ACLs on the remote server (for example: making the \app_data directory to be read/write).  In later blog posts in this series I’ll discuss how to enable database deployment as part of the Web Deploy process – as well as how to automatically switch web.config file settings (e.g. connection-strings) as part of it.

And with that we’ve published our site on a remote server.  To re-publish it again you can right-click on the project and once-again select the “Publish” command – which will bring up the publish dialog again (with the same settings as last time populated in it by default). Alternatively, you can enable the “Web One Click Publish” toolbar within VS 2010 – which enables you to quickly switch between saved publishing profiles (using a drop-down) and then click the “"Publish” button to the right of it to public the project to the target server (no dialog required):

image

Note that Web Deploy is smart enough to compare the remote server with your local project – and only copy the files it needs to.  So if you make a quick few changes to a large project, and then re-publish again – only those files that changed will be copied over.  The files that weren’t updated won’t need to be copied again.  This makes re-deploying/updating a site much faster – especially when there is a lot of static content and large images in the project.

Web Deploy also by default compresses files before it copies them to the Web Deploy service – which shrinks the wire-size and enables faster deployments.

Creating Deployment Packages from VS 2010

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 Web Deploy understands.  You can then hand-off the deployment package file to someone who can deploy it either via the IIS Admin Tool, or via a command-line/powershell script that installs it on a remote server using Web Deploy.

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 will 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 be passed as arguments on the command-line when using a command-line or Powershell script to deploy the application via a remote Web Deploy service.

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

image

Selecting this option will cause VS 2010 to build a Web Deploy compatible deployment package.  You can configure where this package is created on disk within the project’s “Properties” dialog (select the Package/Publish Web tab).  Note that the disk location of the generated Web Deploy package is always displayed in the “Output” window build content (which makes it easier to find):

image

The generated package file is literally a .zip file that contains a Web Deploy manifest that enables you to easily deploy it on a remote server using either the IIS Admin Tool or a command-line.

Installing a Package Using the IIS Admin Tool

Once you have created the .zip deployment package file, you can use the IIS Admin Tool to install it.  Within the IIS Admin tool simply click the “Import Server or Site Package…” link on the “Actions” panel of the admin tool (these links are present if Web Deploy is installed):

image

This will launch a dialog that allows you to select the .zip package file.  When you do this the IIS Admin Tool will show the administrator the exact deployment steps that have been automated by the package:

image

If you continue through the wizard it will automate provisioning the application for you onto your server.

Deploying a Package from the Command-Line

Alternatively, you can use a command-shell to deploy the package onto a remote server.

To do this, open a command window, and navigate to the location of the deployment package .zip file on disk.  In addition to the .zip package file, you’ll find that VS also added a few additional files to the directory:

image

The ProjectName.deploy.cmd file provides a pre-built script that you can use to deploy the package onto a remote server. 

The ProjectName.SetParameters.xml file contains some deployment parameters that you can set (like site-name, connection-string locations, etc).  You can use Visual Studio’s project properties pane to set the default values for the parameters that are generated into this file.  Admins can then optionally edit/change them later if they want (avoiding the need to explicitly specify them as command-line parameters). Make sure to open/view this file to see what the current defaults in it are.  In particular, check to make sure that the site name/application name is where you want the application deployed.

To install the package on a remote Web Deploy server, run the deployment script with the following parameters:

ProjectName.deploy.cmd /y /M:https://WebDeployUrl:8172/MsDeploy.axd /u:username /p:password –allowUntrusted /A:basic

A couple of quick notes on the various parameters above:

/y Indicates that Web Deploy should deploy the application onto the remote server. 

Alternatively instead of /y you can specify /t to perform a trial install that will simulate deployment and help you verify everything is ready (without actually provisioning it).
/M: parameter Specifies the Web Deploy publishing endpoint of the server you want to deploy the package onto.  It should match whatever publishing service URL you setup (and will be the same as the “Service URL” parameter in the Publish Web dialog). It should be an “https” based URL if you are publishing to a Windows Server 2008 or 2008 R2 server.
-allowUntrusted Required if the SSL certificate on the remote Web Deploy server is unsigned (which it isn’t by default)
/A:basic Required if the remote server is not using Windows Authentication to identify the user (it instead specifies that you will use http basic auth over SSL)

When you run the command it will deploy the package to the remote server, perform all of the deployment steps (including things like provisioning databases, setting file ACLs, etc), and output the status back to the command-prompt as it makes progress.

Automating Deployment from a Build Server or Continuous Integration Server

In addition to having a developer/administrator kick off deployment explicitly, you can alternatively automate it to happen as part of a continuous integration process or as part of a build server.  The commands necessary to automate creating a Web Deploy .zip package are available as MSBuild tasks.  You can use them to either create a deployment package as part of the build process – or optionally have an automated build also deploy the app as well.

I’ll be covering how to enable these automated build scenarios in a future blog post.

Deploying Across a Web Farm

Web Deploy can be used together with the Microsoft Web Farm Framework to enable automated deployment across a web-farm.  You can install and configure Web Deploy on a primary server in a Web Farm Framework cluster – and the secondary servers within the web farm cluster will then monitor and clone any applications you deploy with it.  This allows you to use the exact same steps as above to deploy sites and applications across any number of machines within a web farm in an automated way.

Read my previous blog post about the Microsoft Web Farm Framework to learn more about how to enable this.

Summary

Web Deploy provides a powerful and flexible way to automate the deployment of ASP.NET Web Applications to a remote server.  Web Deploy enables you to not only publish files – but also provision database schema/data, run database change scripts, set security ACLs, and more. 

You can use Visual Studio 2010 to directly publish to web servers that have Web Deploy enabled, or create deployment package files that can be installed either via an admin tool or the command-line.  You can also integrate packaging and deployment as part of a build server or continuous integration process to better enable a continuous delivery model.

I’ll cover more about how to enable Web Deploy with delegated security scenarios in my next blog post.  I’ll then do blog posts that cover how to modify/customize web.config files as part of deployment, how to deploy databases as part of a Web Deploy process, and how to integrate all of this as part of an automated build process.

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

83 Comments

  • Is there anyway with this to exclude files when deploying? The most obvious being the web.config file?

    Cheers

  • @Andy,

    >>>>>>>> Is there anyway with this to exclude files when deploying? The most obvious being the web.config file? Cheers

    Code files and those files not marked as content will by default not be deployed. So your code-behind files, class files, etc will not be deployed.

    Web.config files (post-transform - which I'll cover soon and which allows you to tweak the final file as part of deployment) are deployed by default. What is the scenario for when you don't want to deploy your web.config file?

    Thanks,

    Scott

  • Hi Scott

    You say that MSDeploy can be installed on Windows Server 2003. But when I type the command to test the installation, I have an error message saying "you must have IIS 7 or above".

    Is it something I am missing ?

    Thanks

  • The connectionstring and appconfigs vary from our live environment to our development environment. So the server web.config file would already exist on the server and when we update a site and re-deploy we wouldn't want the web.config to be updated with our dev one.

  • Thank for your great article, one off topic question: will next release of asp.net mvc 3 support VS intellisense? and when will it be released? thanks again!

  • You can exclude files or folders by using the skip command:

    For files (regular expression):
    -skip:objectName=filePath,absolutePath=.*cmsservices\.config

    For folders:
    -skip:objectName=dirPath,absolutePath=app_data

    We use the following in our build script (TFS 2008):




    This will execute the generated package and deploys it to a server. Make sure you let the build server also build the package by setting this:



    DeployOnBuild=true;DeployTarget=Package;

  • Hi Scott,

    Can you clarify / point to info about sql change script management and deployment for this? Whats the best way to implement?

    Also, in the web farm scenario, how do you manage sql changes when the various different servers are in the process of being updated and not all be up to date yet?

    P.

  • Is there a way to include code in a package that will be run at deployment time? My application already solves the 'set up the database schema' problem its own way with C# code that runs when we 'install' the website, and as far as my research so far has shown, that's mutually exclusive with using webdeploy. The only things I've found about running arbitrary code talks about copying files into the server's Program Files folder...

    Is this possible, and if not, can you say anything about why that decision was made? It sounds like a security measure, almost, but that doesn't make sense to me - the deployed code will be run once someone hits the website so it can run arbitrary code anyway, just at a less convenient time.

  • Hey Scott,

    I've tried this about a month ago (deploying from VS2010 on Win7 to a Windows 2008 R2 server), and it has worked beautifully. The only concern I have is the Output tab.
    I've initially set it up with orcsweb.com when they provided the beta, and I got the same output as you have in your screen shot, but when I started deploying the website to my own server - the output doesn't list what actions have been done (files uploaded, folders created etc).

    It's all very simple, quiet, and mostly empty (except a couple lines about the project being built and deployed successfully.

    Did I miss something, or is there a hidden setting somewhere? :(

    Thanks

  • Hi Scott
    The Web Deploy tool is great; we use it nearly every day.
    Is there any way that we can get Web Deploy to make a backup before deploying? Maybe through the ".NET based provider API that enables you to create and plug-in your own custom deployment actions" that you mentioned?

  • Hi Scott - totally awesome article - this blog post has LONG been overdue! Thank you heaps. I can't wait for the next one about CI + TFS Builds (which u said is coming :) )

    Now to my question: In this blog post you started out by explaining how to install Web Deploy on W2K8, etc. Then on Win7/W2k3 . If I wish to use Visual Studio 2010 to publish my web application from my localhost "development" machine to our internal "development" or "UAT" server, do I need to have MS Web Deploy installed on BOTH my localhost machine AND the destination server? Or (obviously) just the destination server?

    Once more, thanks heaps Scott for this post (and the CI + TFS Build one, when it comes) - I can't stress how important an easy and seamless deployment scenario is .. and now we're getting there with MS Deploy :)

    -PK-

  • The web deploy feature is fantastic when it is possible to use it. But is there a way to choose another way to compare files that filedate? We use subversion and subversion sets the filedate to checkout/update date and this makes the web deploys larger than need to be.

  • Whenever I try to run this process with a "Release" configuration, I get a "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS" error.

    Do I actually need to designate the output directory for the zipped up deployment package as an IIS application?

  • I wonder if all the development effort that went into this would have been better spent improving the already existing IIS support within WiX and MSI.

  • Hi Scott,

    The web deployment tool is awesome, but I have to ask: Why is the integration between it and Team Build so poor? It feels like the TFS team never met the ASP.NET guys, or even considered web deployment when developing the new build functionality for 2010. In most other ways the 2010 developer products are fantastic, but this aspect has been a real disappointment to us.

  • Thank for your great article, one off topic question: will next release of asp.net mvc 3 support VS intellisense? and when will it be released? thanks again!

  • Any way you can give instructions on how the publishing can be done with TFS 2010? I have found some sites that give instructions (that work for me) but are very poorly documented.

  • This looks very promising Scott. As someone who is deploying the output of multiple solutions and projects that span multiple technologies to over a hundred servers, the ability to easily script all of this out, as well as the ability to handle configuration separately from the code is essential. Any chance you could post how to generate the packages from your CI server, and how your team would best recommend handling different settings in different environments? I would ideally like to remove configuration management from code management entirely, because we have to manage configuration for java, .net, database, and lucene projects, which at the moment introduces a lot of redundancy, and opportunity for user error. What we're doing at the moment is creating a higher-level configuration data store, that is flexible enough to be used to update configurations in other types of projects via a simple templating language. (Like T4 I guess, but we're using ERB at the moment)

    Thanks!

  • Hi,

    I would like to use Microsoft Web Deploy technology but I need to package up multiple web site projects in a single install with rather complicated post-build steps. Is there a path of execution for mutlipe project packaging?

  • Thanks for the useful article.

    Sorry, but I haven't got about the database project? How do I include it to the deployment package and how it will be deployed on the production server?

  • Will Web Deploy be added to Visual Studio 2008, or is it exclusive to 2010?

  • Hi Andy

    >>>>>>>> Is there anyway with this to exclude files when deploying? The most obvious being the web.config file? Cheers

    You can exclude files (and other objects) during a sync using skip actions and skip directives. For e.g. in your case if you want to skip web.config you can specify from the command line: -skip:objectName=filepath,absolutepath=\\web\.config$
    Here the objectname and absolutepath are regex strings and follow the standard regex rules.

    Thanks
    Owais

  • Scott, this is great, but can this all be scripted in order to implement a continuous integration environmnet? Any chances to use all this without VS2010? (in a build server)

  • gr8

  • Hello Scott,

    Useful article, but in my windows server 2008 R2 I cant found "Management delegation" icon, I`ve installed web deployment tool 1.1 and management service.

    Thanks

  • Can you use Web Deploy with pre-compiled ASPX pages (bin\*.compiled). I use Web Deployment Projects using aspnet merge and was hoping to deploy those builds.

  • Please make these features work with Azure!

  • Scott,

    I understand the "Build Deployment Package" option will include IIS settings like logging, mime-types, error pages, etc. However, in a well-managed environment these IIS settings should be pulled from a version-controlled source of truth, not from an arbitrary developer or build machine's current IIS installation. Is this supported by MSDeploy?

    Regards,

    Jason

  • Please contribute to the WiX project! Why do we have to invent yet another installation/deployment technology?

  • I currently use the “Publish Web” dialog but with FTP.
    Is Web Deploy better? Why?

    (I don't need to set ACL or deploy DBs)

  • @Thomas,

    >>>>>> You say that MSDeploy can be installed on Windows Server 2003. But when I type the command to test the installation, I have an error message saying "you must have IIS 7 or above".

    Sorry about that - the command I specified was one which uses an IIS7 specific feature. Have you tried the steps to deploy something - did that work?

    Thanks,

    Scott

  • @Andy,

    >>>>>>>> The connectionstring and appconfigs vary from our live environment to our development environment. So the server web.config file would already exist on the server and when we update a site and re-deploy we wouldn't want the web.config to be updated with our dev one.

    There are a couple of ways to handle this:

    1) Use the new Web.config transform feature that I'll cover in a blog post soon

    2) If you are using the create package option, have the administrator override the config setting in the web.config file. This is useful for cases where you don't know the connection-string at build time.

    3) Use the approach that Michiel van Oudheusden recommended above to explicitly exclude that file from deployment and not have it update as part of a deploy.

    Hope this helps,

    Scott

  • @Tao,

    >>>>>>> Thank for your great article, one off topic question: will next release of asp.net mvc 3 support VS intellisense? and when will it be released? thanks again!

    The final release of MVC3 will definitely include intellisense for the new razor syntax. We will probably do one private beta of the VS intellisense support before going broad with it. Send me email (scottgu@microsoft.com) once the next preview comes out and I can get you access to this.

    Hope this helps,

    Scott

  • @Michiel van Oudheusden

    Good tip!

    Thanks,

    Scott

  • @Paul,

    >>>>>> Can you clarify / point to info about sql change script management and deployment for this? Whats the best way to implement? Also, in the web farm scenario, how do you manage sql changes when the various different servers are in the process of being updated and not all be up to date yet?

    I'm going to do a dedicated blog post on database management with Web Deploy in the future - there is a long post worth of recommendations on that!

    Thanks,

    Scott

  • @Stuart,

    >>>>>>>> Is there a way to include code in a package that will be run at deployment time? My application already solves the 'set up the database schema' problem its own way with C# code that runs when we 'install' the website, and as far as my research so far has shown, that's mutually exclusive with using webdeploy. The only things I've found about running arbitrary code talks about copying files into the server's Program Files folder... Is this possible, and if not, can you say anything about why that decision was made? It sounds like a security measure, almost, but that doesn't make sense to me - the deployed code will be run once someone hits the website so it can run arbitrary code anyway, just at a less convenient time.

    The best way to do this is via a Web Deploy provider - which you can use to run arbitrary code as part of the deployment process. Providers can then be enabled/disabled by the admin depending on security. So for example a shared web hoster might not allow your provider to run (since they store multiple customers on a box), whereas in an enterprise environment your admin might allow it.

    Hope this helps,

    Scott

  • @Artiom

    >>>>>>> I've initially set it up with orcsweb.com when they provided the beta, and I got the same output as you have in your screen shot, but when I started deploying the website to my own server - the output doesn't list what actions have been done (files uploaded, folders created etc). It's all very simple, quiet, and mostly empty (except a couple lines about the project being built and deployed successfully. Did I miss something, or is there a hidden setting somewhere? :(

    Can you send me email (scottgu@microsoft.com) about this? I can then loop you in with folks on the team. I bet there is a output verbosity flag somewhere that controls this.

    Thanks,

    Scott

  • @Esben,

    >>>>>>>> Is there any way that we can get Web Deploy to make a backup before deploying? Maybe through the ".NET based provider API that enables you to create and plug-in your own custom deployment actions" that you mentioned?

    Can you send me email (scottgu@microsoft.com) on this? I can then loop you in with some folks who can recommend the best way to do this.

    Thanks,

    Scott

  • @Pure Krome,

    >>>>>>> If I wish to use Visual Studio 2010 to publish my web application from my localhost "development" machine to our internal "development" or "UAT" server, do I need to have MS Web Deploy installed on BOTH my localhost machine AND the destination server? Or (obviously) just the destination server?

    VS 2010 will install Web Deploy for you locally - so no need to explicitly install it on your dev machine. You will want/need to install it on the destination server though - and follow the steps I listed above.

    Hope this helps,

    Scott

  • @Daniel,

    >>>>>>>>>The web deploy feature is fantastic when it is possible to use it. But is there a way to choose another way to compare files that filedate? We use subversion and subversion sets the filedate to checkout/update date and this makes the web deploys larger than need to be.

    Interesting issue - I hadn't heard that before. Can you send me email (scottgu@microsoft.com) about it and I'll loop you in with folks on the team to help?

    Thanks,

    Scott

  • @Kevin,

    >>>>>>>> Whenever I try to run this process with a "Release" configuration, I get a "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS" error.

    Do you have the "Mark as IIS Application on Destination" checkbox enabled in the Publish Web dialog? This sounds like an issue where you have an application-level setting but are publishing the project into a virtual directory.

    Hope this helps,

    Scott

  • @Jon,

    >>>>>>> The web deployment tool is awesome, but I have to ask: Why is the integration between it and Team Build so poor? It feels like the TFS team never met the ASP.NET guys, or even considered web deployment when developing the new build functionality for 2010. In most other ways the 2010 developer products are fantastic, but this aspect has been a real disappointment to us.

    Stay tuned - I'll do a blog post covering Team Build and CI scenarios in the future.

    Hope this helps,

    Scott

  • @Joel,

    >>>>>>>>> Any way you can give instructions on how the publishing can be done with TFS 2010? I have found some sites that give instructions (that work for me) but are very poorly documented.

    Yep - I'll be doing a blog post that covers how to do this in the future. I definitely agree that the steps to figure out how to set this up are pretty hard to discover...

    Thanks,

    Scott

  • @Jeff,

    >>>>>>>> This looks very promising Scott. As someone who is deploying the output of multiple solutions and projects that span multiple technologies to over a hundred servers, the ability to easily script all of this out, as well as the ability to handle configuration separately from the code is essential. Any chance you could post how to generate the packages from your CI server, and how your team would best recommend handling different settings in different environments? I would ideally like to remove configuration management from code management entirely, because we have to manage configuration for java, .net, database, and lucene projects, which at the moment introduces a lot of redundancy, and opportunity for user error. What we're doing at the moment is creating a higher-level configuration data store, that is flexible enough to be used to update configurations in other types of projects via a simple templating language. (Like T4 I guess, but we're using ERB at the moment)

    That is definitely on my list to cover. I'll be doing a few more posts before that - but the CI/build-server scenario is the one I'm ultimately leading up to getting to.

    Hope this helps,

    Scott

  • @Aslan,

    >>>>>>>> I would like to use Microsoft Web Deploy technology but I need to package up multiple web site projects in a single install with rather complicated post-build steps. Is there a path of execution for mutlipe project packaging?

    If you can send me email (scottgu@microsoft.com) about this I can loop you in with some folks to help recommend how to best handle this.

    Thanks,

    Scott

  • @Nikita,

    >>>>>>>> Sorry, but I haven't got about the database project? How do I include it to the deployment package and how it will be deployed on the production server?

    I'll be covering database deployment in a future blog post - stay tuned until then!

    Thanks,

    Scott

  • @Jeremy,

    >>>>>>>> Will Web Deploy be added to Visual Studio 2008, or is it exclusive to 2010?

    The dev tooling integration is built-into VS 2010. However, you can use the command-line Web Deploy functionality with VS 2008 and enable it that way.

    Hope this helps,

    Scott

  • @Camilo,

    >>>>>>>> Scott, this is great, but can this all be scripted in order to implement a continuous integration environmnet? Any chances to use all this without VS2010? (in a build server)

    Yep - I'm working my way towards that post. I'll cover CI scenarios in a few blog posts (after I cover delegated deployment, web.config file transforms, and database deployment).

    Thanks,

    Scott

  • @Rafah,

    >>>>>>>> Useful article, but in my windows server 2008 R2 I cant found "Management delegation" icon, I`ve installed web deployment tool 1.1 and management service.

    I pinged the team about this and they suggested two things:


    1) Maybe you didn’t close and re-open IIS Manager. This might be necessary to pick up the new feature.

    2) Management Delegation UI didn’t get installed with Web Deploy. This is odd, because WebPI by default installs all Web Deploy components (maybe you downloaded the Web Deploy MSI separately and clicked ‘Typical’?). There’s a straightforward way to check this:

    1. Start -> Control Panel
    2. Go to the Programs Control Panel
    3. Click Web Deploy 1.1 and click ‘Change’
    4. In the installer, click ‘Change’
    5. Make sure all items are checked

    Let me know if you still have problems with this,

    Scott

  • @Goudinov

    >>>>>>>>> Can you use Web Deploy with pre-compiled ASPX pages (bin\*.compiled). I use Web Deployment Projects using aspnet merge and was hoping to deploy those builds.

    Good question. Can you send me email (scottgu@microsoft.com) about this? I can then loop you in with folks on the team to check.

    Thanks,

    Scott

  • @Pete,

    >>>>>>> Please make these features work with Azure!

    We are talking with the Azure team about this now to see if we can make this work there as well. I agree it would be great to enable.

    Thanks,

    Scott

  • @Jason,

    >>>>>>>> I understand the "Build Deployment Package" option will include IIS settings like logging, mime-types, error pages, etc. However, in a well-managed environment these IIS settings should be pulled from a version-controlled source of truth, not from an arbitrary developer or build machine's current IIS installation. Is this supported by MSDeploy?

    All of the configuration data can be checked in under source control. The steps I showed above actually don't look at the local IIS settings at all - but rather use settings within the project file (and so are versioned under source control).

    Hope this helps,

    Scott

  • @edddy,

    >>>>>>> I currently use the “Publish Web” dialog but with FTP. Is Web Deploy better? Why?

    Two benefits of Web Deploy are:

    1) It is smart about only sending files that changed
    2) It compresses files before it sends them (making uploads faster).

    Hope this helps,

    Scott

  • Another great article, thanks!

    >>>>>>>>>The web deploy feature is fantastic when it is possible to use it. But is there a way to choose another way to compare files that filedate? We use subversion and subversion sets the filedate to checkout/update date and this makes the web deploys larger than need to be.


    We use TFS here but we're not currently using CI or build server capabilities.

    Every time a developer grabs a project from TFS, all the timestamps are the current time and date. This means that when I use "Publish Web" it copies up everything, rather than just the changes. So it's not that smart about sending up only files that have changed! Is there a reasonable solution to this?

    Thanks, Alex

  • Due to the security locked down I can't use the publish method, so I am using the package method and then importing into IIS. This is a full site rather than a virtual directory and when I finish the import I seem to have lost the Script permissions. Its not a major issue to reset these but its a pain.

    Anyone else had the same issue?

  • Scott, when I publish/update a site, I like to publish/update from vs2010 using web deploy. But when I do that, the remote server always resets the file ACL's. I know that the ACL stuff can be disabled by manually editing the deployment package, but if I have to go through all that trouble I might as well deploy manually.

    Is there a way to disable the changing of ACL's? Basically all I want to do is run the .config transforms and copy any changed files over. And I don't want to manually edit a deployment package xml file every-time. Basically I want the affect of using ftp deployment, but I still want to use web deploy.

  • Alex,
    I am not sure which TFS version you are using but one method I know is that, in your MS Build arguments, put "/p:SkipClean=true;SkipInitializeWorkspace=true;ForceGet=false"

    By the default, MS build will try get ForceGet so that all the time stamp gets downloaded with the build time.

    But when you set up ForceGet=false, it will not get everything latest on the build source.

    John.

  • @Si G: What do you mean you have lost "script permissions"? Can you please give some more details? I'll be happy to help.

    ~Bilal

  • and of course I find the solution right after I post my previous question. Apparently I neglected to run "net start msdepsvc" after a system restart. Looks like the service is set as Manual not Automatic. so it didn't come back up after the reboot. :-)

  • Hi Scott

    Great article and when I get this up and running it will be a joy :-)

    I am just about there getting it all up and running but have run in to a slight problem that I am not sure how to resolve. I am getting the following error on deploy:

    "Error 1 Web deployment task failed.((15/09/2010 7:59:12 AM) An error occurred when the request was processed on the remote computer.)
    (15/09/2010 7:59:12 AM) An error occurred when the request was processed on the remote computer.
    This access control list is not in canonical form and therefore cannot be modified. 0 0 Bradford"

    Is this one you have come across before and have a 5 second answer for?

    If not I shall soldier on.

    Cheers,
    BondiGeek

  • @viscius,

    >>>> Scott, when I publish/update a site, I like to publish/update from vs2010 using web deploy. But when I do that, the remote server always resets the file ACL's. I know that the ACL stuff can be disabled by manually editing the deployment package, but if I have to go through all that trouble I might as well deploy manually. Is there a way to disable the changing of ACL's? Basically all I want to do is run the .config transforms and copy any changed files over. And I don't want to manually edit a deployment package xml file every-time. Basically I want the affect of using ftp deployment, but I still want to use web deploy.

    There are project-level properties for everything we do in VS to publish or create a deployment package. To disable setting ACLs, you can:

    1) Edit the .csproj file and set False

    or set it via a command build:

    2) msbuild myproject.csproj /p:IncludeSetAclProviderOnDestination=False

    Hope this helps!

    Scott

  • @Si G,

    >>>>>>>>> Due to the security locked down I can't use the publish method, so I am using the package method and then importing into IIS. This is a full site rather than a virtual directory and when I finish the import I seem to have lost the Script permissions. Its not a major issue to reset these but its a pain.

    Can you send me email (scottgu@microsoft.com) with more details about this? I can then connect you with someone who can help.

    Thanks,

    Scott

  • @James,

    >>>> re: ACL problems

    Can you use your Windows Explorer to pull up the properties on the folder or files impacted? Right click on the folder from explorer -> Properties -> Go to security tab -> click Edit (or Advanced) At this point it should complain if there is an issue with permissions.

    If you are still having problems please send me email (scottgu@microsoft.com) and we can help investigate more.

    Thanks,

    Scott

  • @Alex,

    >>>>>>>>> We use TFS here but we're not currently using CI or build server capabilities. Every time a developer grabs a project from TFS, all the timestamps are the current time and date. This means that when I use "Publish Web" it copies up everything, rather than just the changes. So it's not that smart about sending up only files that have changed! Is there a reasonable solution to this?

    One way to work around this is to use the –useChecksum flag with MSDeploy. This does a checksum on the files as opposed to looking at the timestamp. It takes a little longer to find the changes than the default approach - but will avoid the need to send the files over teh network and so should be much faster.

    Can you give this a try and see if this fixes your issue?

    Thanks,

    Scott

  • Thanks, Scott, for letting me know that you and the Azure team are talking about this. It seems like the Azure *tools* teams should work for you. You really want to present this as one unified dev platform for it to work.

    We just need a way to patch it all together so that a webdeploy project can get packaged property and deployed to azure. (and be automated)

  • Hi again Scott

    This problem 'Error 55 Web deployment task failed' when trying to publish subsequent times has resolved itself over night which is nice.

    Hopefully it won't occur again but if you do know what the problem might have been I would be keen to know.

    Thanks again for the great post, looking forward to your follow ups in the series.

    Cheers,
    James

  • Thanks a lot

  • >>>>>>>>> One way to work around this is to use the –useChecksum flag with MSDeploy. This does a checksum on the files as opposed to looking at the timestamp.

    Thanks Scott - this sounds like it would work. But can I do that with Web One-Click Publishing?

    @John Roh - thanks for replying. We (currently) pull code out of TFS and build on a workstation, meaning that some/all files will have a 'current' timestamp. As a workaround, I created a quick tool that fixes all the timestamps of local files to the TFS check-in time.

  • Can the Web Deploy be used with Aspnet_compiler?

  • Ditto on @Jaap. I get a 404 too. Using windows server 2008 r2 on a VPS from appliedi.net

  • Hi Scott, we're using Windows XP SP3. Is there any chance to do a webdeploy for this OS?

  • Scott,
    This is great, and should be a little cleaner than the Powershell method we were using. I am looking for more information on how to do the following:

    * Set Application Pool, certs, etc. in the deployment package (not necessarily cmd line overrides).
    * Create the package in TFSBuild (2008) as you mentioned.

    Thanks!

  • Scott,
    This is great, and should be a little cleaner than the Powershell method we were using. I am looking for more information on how to do the following:

    * Set Application Pool, certs, etc. in the deployment package (not necessarily cmd line overrides).
    * Create the package in TFSBuild (2008) as you mentioned.

    Thanks!

  • Thanks for the posting scott.

    Looking forward to the blog posting on automated deployment via Web Deploy.

  • i have installed iis 7 on server 2008 and trying to run my mvc application on localhost but it is listing all the directories (bin,app_data,script...) rather running it.

  • Hi,

    Thanks for a great blog post.

    I would like to use the Build Deployment Package feature but there are two things that kind of stops me from being able to do this and I can't quite work them out.

    1) Our web application is divided into several web application projects. Is there any way to build one deployment package out of these several projects?
    2) We have to deploy these packages to different environments, all having a different directory structure and different application roots. Is there any way to work around this?

  • Hi Scott: Great Article. Now I have to design a strategy to automatically generate the deployment package once (for several environments) and then automate de deployment on each one of these environments programatically. Have you continued posting the following articles you mention ? I'm particularly interested on web config files transformation.

  • Where exactly in the .csproj file do I put False. I tried this (using visual web developer) and the output window still says “Updating setAcl” when I use webdeploy.

  • @Giancarlo,

    >>>>>>>> Where exactly in the .csproj file do I put False. I tried this (using visual web developer) and the output window still says “Updating setAcl” when I use webdeploy.

    If you send me email (scottgu@microsoft.com) I can have someone help you.

    Thanks,

    Scott

  • Scott

    This is great! Any idea when you are going to do the CI to web deploy build blog? This is a task that I *am* supposed to be undertaking in the next few days - and that documentation would be awesome to have.

  • It seems my version of Visual Studio 2010 is different from the version that everyone is using. I can't find the Webdeploy option in my own installation. Is there something like a service pack that i need to install

    Thanks

  • Scott,

    Yet another pearl! Thanks for this and other postings on you blog.

    I apologise for my ignorant fellow countrymen who soil your excellent contributions to the head-scratching development community!

    Thanks, Keith

  • Great article, now waiting for the "how enable delegated deployment scenarios" sequel.

Comments have been disabled for this content.