You can use Microsoft Web Deploy and batch files to update one or many IIS-hosted MDriven Turnkey and MDrivenServer applications from downloaded deployment packages.
Use this procedure when the IIS applications already exist and you want to apply new MDriven Turnkey and MDrivenServer package versions consistently across development or test sites. For initial IIS setup, application pools, HTTPS, and first-time MDrivenServer configuration, see HowTos:Installing MDriven Server on Windows.
Before you begin
Make sure that the following are in place:
- IIS hosts the applications that you intend to update.
- You have downloaded the MDriven Turnkey and MDrivenServer ZIP deployment packages from MDriven downloads.
- Microsoft Web Deploy V3 is installed. This procedure calls
msdeploy.exefrom its default installation location. - You run the commands from an elevated Command Prompt. The commands stop and start IIS application pools and deploy to IIS.
- Each Turnkey application has a corresponding MDrivenServer application at the expected IIS path. For example, a Turnkey application named
Testhas its MDrivenServer application atTestMDrivenServerin the multi-site example below.
Web Deploy updates application files from the package. The deployment command uses the DoNotDeleteRule so that existing setting files and other resources are retained.
Update one IIS application from a package
Create a batch file named UpdateSiteFromPackage.cmd. Save it in a folder from which you will run the update scripts.
"%PROGRAMFILES%\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -setParam:"Application Path"="Default Web Site/%2" -source:package=%1 -dest:iisApp="Default Web Site/%2" -enableRule:DoNotDeleteRule
The script accepts two arguments:
| Argument | Meaning | Example |
|---|---|---|
%1
|
Full path or relative path to the downloaded ZIP package. | %USERPROFILE%\Downloads\MDrivenTurnkey_20220321.zip
|
%2
|
IIS application name and normally its folder name below Default Web Site.
|
Test
|
The -setParam:"Application Path" option replaces the application path built into the deployment package. Use it to target the IIS application you already created. This is equivalent to changing or clearing the application-path value when importing a package through the IIS Manager user interface.
The -enableRule:DoNotDeleteRule option prevents Web Deploy from deleting files that are already present but are not part of the package. This retains existing setting files and other resources during the update.
Example
To update an IIS application named Test with a Turnkey package stored in the current user's Downloads folder, run:
UpdateSiteFromPackage.cmd "%USERPROFILE%\Downloads\MDrivenTurnkey_20220321.zip" Test
Update Turnkey and MDrivenServer together
A Turnkey installation consists of Turnkey and MDrivenServer. Update them in that order: Turnkey first, then MDrivenServer. See HowTos:Troubleshoot Turnkey Deployment for deployment failures that occur while the MDrivenServer package is being processed.
For a group of applications, stop the relevant IIS application pools before deployment and start them again after both packages are updated. This prevents the applications from serving while their files are being replaced.
Create a batch file named UpdateTkAndMdSites.cmd with the following content:
"%WINDIR%\system32\inetsrv\appcmd.exe" stop apppool /apppool.name:"%3"
"%WINDIR%\system32\inetsrv\appcmd.exe" stop apppool /apppool.name:"%3MDrivenServer"
CALL UpdateSiteFromPackage "%USERPROFILE%\Downloads\%1" Intranet%3
CALL UpdateSiteFromPackage "%USERPROFILE%\Downloads\%1" %3
CALL UpdateSiteFromPackage "%USERPROFILE%\Downloads\%2" %3MDrivenServer
"%WINDIR%\system32\inetsrv\appcmd.exe" start apppool /apppool.name:"%3MDrivenServer"
"%WINDIR%\system32\inetsrv\appcmd.exe" start apppool /apppool.name:"%3"
This script expects the packages in %USERPROFILE%\Downloads and accepts these arguments:
| Argument | Meaning | Example |
|---|---|---|
%1
|
Turnkey package file name. | MDrivenTurnkey_20220321.zip
|
%2
|
MDrivenServer package file name. | MDrivenServer_20220321.zip
|
%3
|
Site-name prefix used in application-pool and IIS-application names. | Test
|
With Test as %3, the script performs these actions:
- Stops application pools
TestandTestMDrivenServer. - Updates IIS applications
IntranetTestandTestwith the Turnkey package. - Updates IIS application
TestMDrivenServerwith the MDrivenServer package. - Starts
TestMDrivenServer, thenTest.
The names in this example are conventions used by the script, not generated by IIS. Match the names in the batch file to your existing IIS applications and application pools before running it.
Update all development and test sites
Create a third batch file named UpdateAllTestAndDevSites.cmd. Add one call line for each site prefix that you want to update.
call UpdateTkAndMdSites.cmd %1 %2 Test
call UpdateTkAndMdSites.cmd %1 %2 Dev1
For example, run the following command from an elevated Command Prompt:
UpdateAllTestAndDevSites.cmd MDrivenTurnkey_20220321.zip MDrivenServer_20220321.zip
The command updates the Test and Dev1 site groups using the two named packages from %USERPROFILE%\Downloads. Add more lines to UpdateAllTestAndDevSites.cmd for every installed development or test site that follows the same naming convention.
Validate the update
- Confirm that both application pools are started in IIS Manager.
- Open the Turnkey application using its configured HTTPS URL.
- Open the associated MDrivenServer application at its configured
__MDrivenServerURL when applicable. - If deployment reports an error while copying an MDrivenServer file, use HowTos:Troubleshoot Turnkey Deployment.
Scope and limits
This automation targets IIS deployment packages through Web Deploy. It does not create IIS applications, configure application pools, configure certificates, or perform initial MDrivenServer setup. Use HowTos:Installing MDriven Server on Windows for those tasks.
For MDriven Server and Turnkey Core deployments on IIS, follow Documentation:Deploying MDriven Server & Turnkey Core on IIS. For Azure hosting, use HowTos:Install MDriven Server and Turnkey on Microsoft Azure.
