Web Deploy "Starter" Commands for Common Scenarios

Posted: Apr 08, 2010  1 comments  

Average Rating

Share this Post

If you are new to Web Deploy and want to get up to speed quickly with its usage and syntax, here are a dozen tasks based on common scenarios and some command syntax that you can use to implement them. First, a word about designating remote computers.

Designating Remote Computers with the computerName parameter

In Web Deploy, the source Web server is indicated by a -source argument and the destination computer is indicated by a -dest argument.

A remote computer is designated as such by adding computername=<RemoteHostName> to its corresponding -source or -dest argument. If necessary, you can have Web Deploy supply credentials to the remote computer (for this, see Web Deploy Provider Settings). If a computer is local, don't use the "computerName=" syntax in its corresponding source or destination argument.

If neither the -source nor the -dest argument has a computerName parameter, Web Deploy carries out the operation on the local computer.

Now on to our sample scenarios and syntax.

Task 1: Show the difference between two IIS 7 Web servers.

msdeploy -verb:sync -source:webserver[,computername=<sourceServerName>] -dest:auto[,computername=<destinationServerName>] -whatif

The webServer provider in the source argument tells Web Deploy that the source computer is IIS 7,  and auto in the -dest argument just says "use the same provider for the destination."

The important point in this command is the -whatif flag. The -whatif flag turns any Web Deploy command into a "dry run," so nothing will actually be changed. Because Web Deploy synchronizes only the items that are different, the command output will reveal any differences that exist between the two servers.

For more information, see Web Deploy webServer Provider and Web Deploy auto Provider.

Task 2: Synchronize two IIS 7 Web servers.

Use the command in Task 1, but remove the -whatif flag.

Task 3: Synchronize two IIS 6.0 Web servers.

msdeploy -verb:sync -source:webServer60 -dest:webServer60,computerName=Server2

Here Web Deploy uses the webServer60 provider to synchronize the local Web server to the remote Web server Server2. You can use the webServer60 provider with IIS 6.0 (Windows Server 2003 and Windows XP 64-bit), or with IIS 5.1 (Windows XP 32-bit).

For more information, see Web Deploy webServer60 Provider.

Task 4: Migrate an IIS 6.0 server to an IIS 7 server

msdeploy -verb:sync -source:webserver60>[,computername=<sourceServerName>] -dest:auto>[,computername=<destinationServerName>]

Here again the webServer60 provider indicates that the source server is an IIS 6.0 server. The IIS 7 server will "pretend" to be an IIS 6.0 server for the purposes of the operation, so auto can be used for the -dest argument.

For more information, see Web Deploy webServer60 Provider.

Task 5: Show the differences between two IIS 7 Web sites.

msdeploy -verb:sync -source:apphostconfig=<Site1Name>[,computername=<sourceServerName>] -dest:apphostconfig=<Site2Name>[,computername=<destinationServerName>] -whatif

Here again you use the -whatif flag, but you use the appHostConfig provider instead of the webServer provider.

For more information, see Web Deploy appHostConfig Provider.

Task 6: Synchronize two IIS 7 Web sites.

Use the syntax in Task 5, but remove the -whatif flag.

Task 7: Synchronize two IIS 6.0 Web sites.

msdeploy -verb:sync -source:metaKey=lm/w3svc/1>[,computername=<sourceServerName>] -dest:metaKey=lm/w3svc/2[,computername=<destinationServerName>]

Here you use the metaKey provider, which works with IIS 6.0 metabase keys, to synchronize site 1 to site 2.

For more information, see Web Deploy metaKey Provider.

Task 8: Backup an IIS 7 Web server to a .zip (="package") file

msdeploy -verb:sync -source:webserver[,computername=<sourceServerName>] -dest:package=c:\<packageFileName>.zip

Here the contents of the Web server will be placed in a .zip file. Later, if you want to restore the Web server from the .zip file, just use the package=c:\<packageFileName>.zip syntax for the source argument.

For more information, see Web Deploy package Provider.

Task 9: Backup an IIS 7 Web site to a .zip file

msdeploy -verb:sync -source:apphostconfig=<SiteName>[,computername=<sourceServerName>] -dest:package=c:\package.zip

This is the same as the command in Task 8, but now you use apphostconfig=<SiteName> for the source.

For more information, see Web Deploy appHostConfig Provider.

Task 10: Import or export certificates

If a certificate is associated with a site, it will automatically be imported or exported with synchronization commands like the previous ones. However, if you want to explicitly export or import a site certificate, here are some ways to do it.

· To export a certificate to a package, you can use the following command syntax.

msdeploy -verb:sync -source:cert=<ThumbPrintOrFriendlyName> -dest:package=c:\<packageFileName>.zip

· To import a certificate from a package, use the following command syntax.

msdeploy -verb:sync -source:package=c:\<packageFileName>.zip -dest:cert=<ThumbPrintOrFriendlyName>

Alternatively, you can use the following syntax:

msdeploy -verb:sync -source:package=c:\package.zip -dest:auto

The location and characteristics of the certificate on the destination will correspond to whatever they were when the certificate was saved to the package.

· To do a "live" synchronization of a certificate, use the following syntax.

msdeploy -verb:sync -source:cert=<ThumbPrintOrFriendlyName> -dest:auto[,computername=<destinationServerName>]

For more information, see Web Deploy cert Provider.

Task 11: Export a COM component to a package

Use the comObject32 provider to synchronize a 32-bit COM component to a package file, as in the following example.

msdeploy -verb:sync -source:comobject32=<ProgIdOrCLSID> -dest:package=c:\package.zip

For 64-bit components, there is an analogous comObject64 provider.

For more information, see Web Deploy comObject32 Provider and Web Deploy comObject64 Provider.

Task 12: Export a GAC assembly

You can export a single-file GAC assembly to a package by using the gacAssembly provider.

msdeploy -verb:sync -source:gacassembly="<assemblyName>" -dest:package=c:\package.zip

If the assembly is multi-module, only the CodeBase (the file containing the assembly manifest) will be moved.

For more information, see Web Deploy gacAssembly Provider.

Conclusion

This sampling of commands gives just a small taste of the power and flexibility of the Web Deployment Tool. For more in-depth information about Web Deploy, see the following resources:

Web Deployment Tool (TechNet)

Web Deploy (IIS.NET)

Web Deploy Forum (IIS.NET)

Submit a Comment

  • Plain text is accepted.
  • URLs starting with http:// are converted to links.