How to: Create IIS Site Package with Web deploy


one comment

I didnโ€™t write for a long time, and it feels like the first time again, so please be merciful ๐Ÿ™‚ , and I hope you’ll find this post helpful

I learned that changes in big organizations take some time, sometimes too long J. I asked our developers to hand me a full web installation instead of a long and tedious installation guide. Web Deploy tool was the best solution for me, but no one knows how to use it, and the installation guides piled up.

Web Deploy tool helps Administrators or Developers deploy Web applications and Web sites to IIS servers. This tool can be used to synchronize IIS servers or to migrate from older version to a newer one, for more information visit the following site.

A Web Deploy package can be built from the command line or by the IIS GUI extension (Not so user friendly, but very efficient). In this post I`ll try to guide you how to use the tool, through an example.

Tool Prerequisites

This guide requires the following prerequisites:

.NET Framework 2.0 SP1 or greater

Web Deployment Tool

IIS 7.0 or above, or IIS Remote Manager

Light bulbย Note: Don’t forget to backup your site before testing the toolย 

Prerequisites if you’re using SQL

Light bulbย Note: The second and third pre-requisites will be installed automatically if you install the Web Deployment Tool using the Web Platform Installer

  • SQL Server Express or Standard, either local or remote
  • SQL Server 2008 Management Objects (SMO) – x86 or x64
  • SQL CLR Types – x86 or x64

Download and Install the Web Deployment Tool

–> Run the MSI file to install the tool

–> Select a Custom installation.

–>ย Optionally Select the ‘Remote Agent Service’ to install.


Remote Agent Service โ€“ An administrator-only service, based on HTTP/HTTPS, that allows server administrators to connect and perform remote operations.

The remote service is not started by default and is set to Manual startup. It is only required to have it running during an operation, and it can be stopped when not in use.

–> Complete the installation operation

Create a Site package through the IIS Manager


–> Open the IIS Manager using its icon or by typing ‘inetmgr’ at command line

–> In IIS Manager, expand the Server node and the Sites node, then select the source site (From which you will create your installation package)

–> Right click and select Deploy/Export Application

–> By default Web Deploy is configured to export an application, which cannot be imported as a new site, therefore if the goal is to make a site package we need to change this default behavior.


–> As you can see the export operation is for a web application only.

–> If you try to import the package as a new site you will get the following error massage


Changing the default Content settings


–> The first step in changing the default settings is to click on the ‘Manage Components’ button.

ย clip_image009

–> Change the provider name to ‘appHostConfig’, then the package will be a site package instead of an application package.


–> Click on the OK button to see the result (as above)


–> If you continue with the installation wizard (by clicking on the ‘next’ button), you will see that two new parameters were created for you. These parameters allow you to change the packages default settings before and/or in the process of importing the package.

–> The first parameter defines the site path of your site, and the second defines the physical path on the disk.


–> By double clicking on the parameter name (Parameter 1 for instance), you can change the default settings: Change the name of the parameter (more convenient to manage your parameter this way ), change the description of the data, set the default value of the parameter and more


The parameters window after the change


During the import process you can change the values of these parameters


Now you can define the application pool

–> Go back to the Manage Components Page

ย image

–> Add a new provider by selecting ‘AppPoolConfig’ from the list (on the next available line).


–> Enter the existing application pool name (of the exported application)

–> Click OK to see the result (See above)


–> The Application Pool must be created first, so change the order of the tasks, set the application pool to be the first step (use the ‘Move Up’ button).


–> Click NEXT to edit the application pool parameter.

Light bulbย Note: Surely the operator, who imports the package later on, can change the Pool name, but then the import will fail (unless the original pool already exists), so I do recommend deleting it.

Light bulbย Note: If the application pool contains user and password, you will get a prompt to enter a password for the package (Use this password to open the package, when importing)

Adding Site Binding

IIS Server can host more than one site, but in order to do so, the sites must differ in their site bindings, differ in their IP, Port or Hostname, only then they can coexist on the same IIS host server. A new parameter can be added to achieve this goal

–> Navigate to the parameters page


–> Add new parameter (by clicking on the โ€˜Add Parameter buttonโ€™)


–> Set the parameter settings (Name, Default Value, Tags [SiteBinding])

–> The binding value syntax is as follows : IP:Port:HostName (use โ€˜*โ€™ or blank for empty value)

–> Click ‘OK’


–> Every parameter needs it`s parameter entry, so click on the ‘Add Parameter Entry’ button, and fill in the blanks:

ยง Type โ€“ Destination Binding

ยง Scope โ€“ the site path

ยง Match โ€“ The existing binding


–> You can use the validation option to validate the data and sometime ease the installation by supplying all the options for the user.

ยง Double click on the parameter name

ยง Under type select numeration

ยง Enter all the options separated by column (ex. *:80:DevServer,*:81:TestServer,*:80:ProdServer)


The result is a combo box for IIS Site binding (in the import wizard)


–> After clicking OK the parameter list will show on screen

Create SQL Connection

Most commonly, sites need to have SQL connection string to connect to the application Database, to this you need to add the following parameter


–> Create new parameter

ยง Name – Database Connection String (ex)

ยง Default Value – Data Source=ServerName;Initial Catalog=DBName;Integrated Security=TRUE; (ex)

ยง Tags โ€“ SqlConnectionString

–> Create new Parameter Entry


ยง Type โ€“ XML File

ยง Scope\\Web.config$

ยง Match – //connectionStrings/add/@connectionString. (The XML path in existing web.config , to the SQL connection string)


MySite Web.config file

Light bulbย Note: In a similar manner you can change any property in the web.config file

Set ASP.NET Authorization

Sometimes you might prefer to filter the users who are allowed to access the site. You can do this by using the DOT NET authorization (In the web.config file).


–> Create new parameter

ยง Name โ€“ Allowed Group

ยง Default Value โ€“ MyDomain\MySiteGroup

ยง Description โ€“ Enter Allowed Group Name


–> Create new Parameter Entry

ยง Type โ€“ XML File

ยง Scope\\Web.config$

ยง Match //authorization/allow/@roles

Light bulbย Note: You can use many other Web Deploy providers such as :

dbFullSql – This provider enables first-time publishing of databases from a local SQL Server development database to a remotely hosted SQL Server database.

regKey – This provider can be used to return registry content from a source computer, or to move registry content from a source computer to a destination computer

regValue โ€“ This provider returns a registry value from a source computer, or synchronizes a registry value from a source computer to a destination computer

And many more

–> Click on the ‘NEXT’ button

–> Save the package file

Import a Site package through the IIS Manager


–> Open the IIS Manager using the its icon or by typing ‘inetmgr’ at run command line

–> In IIS Manager, expand the Server node

–> Right click and select Deploy/Import Server or Site Package


–> Select the package file


–> On the next window you can review and choose to deselect some of the components.


–>ย  In the next window you can see all the parameters which were defined at the package building phase. Now it is the right time to change the parameter’s data

–> Click ‘next’ and the new site will be installed


Editing the package

Changes to the package can be made by running the wizard again and starting all over, but the easiest way I found is to edit the zip file itself.


The zip file contains three XML files and content folder. In order to change the package, open the zip file by double clicking it.

Editing the package ZIP file

–> The package`s parameters are in the parameters.xml file, just edit this file to change the parameters settings.

–> Change file content by copying new or changed file to the content file hierarchy.

Using web deploy command

Alternatively you can use the webdeploy.exe command for creating/editing a package.

–> Create a new folder (NewPackage)

–> Create new XML file called AppManifest.xml

WebAppManifest.xml should contain the site information Site path, site physical path and site application pool Name:


<appHostConfig path=”MySite” />

<dirPath path=”C:\inetpub\MySite” /> #

<appPoolConfig path=”MySitePool” />


–> Extract the parameters .xml file from the package zip file , to the new folder (NewPackage)

–> Edit parameters .xml file, adjust the parameters as you need.


–> To ease the “XML headache” you can edit it with XML Notepad

–> Create a new BATCH file which contains the following line :

"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:manifest="%~dp0AppManifest.xml" -dest:package="" -declareParamFile:"%~dp0Parameters.xml" > WebDeployPackage.log

–> Use WebDeployPackage.log the monitor the process.

–> Now you can run the BATCH file



Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


one comment

  1. Ortal09/09/2014 ื‘ 20:04

    Hey Dolav,

    Excellent post !!!

    It was very useful for me

    Thanks a lot ๐Ÿ™‚