Automating deployment of Turnkey and MDrivenServer on IIS

Single TK or MDS webapp

If you want to deploy the installation packages you download from https://mdriven.net/downloads you can use msdeploy and then run that from the command line or in a batch file.

Command syntax;

"%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

In the example above

%1 is the name of the zip file you have downloaded.

%2 is the name of the web app and it's folder name. They could be different, but that is very unusual.

-setParam is needed to not use the built in path from the package. If you have used the GUI installer you will know that you many times have edited that name (or removed it).

enableRule:DoNotDeleteRule is needed to not remove existing setting files and other resources. (it's the default in the GUI installer)

Multiple TK and MDS

Putting the example above in a cmd file called UpdateSiteFromPackage.cmd, the following works.

Example of how to first stop two application pools, one for TK and one for MDS and then update two TK sites and the MDS and at last start the application pools again.

"%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"

Then, putting the names of sites in another file called UpdateAllTestAndDevSites.cmd file like this;

call UpdateTkAndMdSites.cmd %1 %2 Test
call UpdateTkAndMdSites.cmd %1 %2 Dev1

Makes it possible to call

UpdateAllTestAndDevSites.cmd MDrivenTurnkey_20220321.zip MDrivenServer_20220321.zip

Remember to execute all this from an elevated command prompt!

This page was edited 48 days ago on 02/10/2024. What links here