Sitecore TDS can generate WebDeploy packages at build time. These packages can contain compiled C# projects and Sitecore items. The WebDeploy package generated by TDS supports all TDS deployment functions, and the result of installing a TDS WebDeploy package has the same result as installing an update package generated by Sitecore TDS or pointing Sitecore TDS at the server and building directly to the server.
There are many aspects to deploying a Sitecore website. Sitecore TDS tries to automate some of the more difficult parts of the deployment process, but will not be a complete end-to-end solution. The developer will still need to setup build and deployment pipelines using their preferred build and deployment automation tools. Sitecore TDS is designed to be easily integrated into the deployment process the DevOps team wants to use.
When Sitecore TDS generates a WebDeploy package containing items, the items are stored in the package in a folder under the /temp/WebDeployItems folder. These files are installed in Sitecore when the server restarts after the WebDeploy package is deployed.
The WebDeploy package also contains an assembly in the /bin folder that performs the deployment. This assembly also installs a WebAPI service to allow the deployment to be monitored. The WebAPI service can also remove itself after the deployment. See below for more details on the WebAPI service.
Sitecore TDS can be configured to build WebDeploy packages simply by enabling WebDeploy package generation in the WebDeploy package tab of the Sitecore TDS property pages.
The package is generated in a folder under the project root /bin/WebDeploy_[Configuration name]. The package is named [Package name].wdp.zip.
TDS also adds a file called PublishWebDeploy.ps1. This file contains scripts that can be used to deploy the web deploy package on a Sitecore server. This script can be run standalone or on a build/release server that supports executing Powershell scripts.
The PublishWebDeploy.ps1 script installs the package on a server using MSDeploy. It also uses the WebAPI endpoint exposed by the item installer assembly to monitor the installation of items in the package.
The PublishWebDeploy.ps1 script will wait until all items in the deployment are installed on the server. It can also display verbose installation logs from the server so the developer can monitor and/or log the progress of the items being installed.
The PublishWebDeploy.ps1 script accepts the following parameters:
Sitecore PaaS Azure instances use App Services to host Sitecore instances. This offers a number of advantages to managing the servers in Azure. One of the benefits is the installation and configuration of Web Deploy is built in automatically.
The Azure App Service can generate a .publishsettings file that will be used by the PublishWebDeploy.ps1 script. The .publishsettings file contains the fully qualified server name and credentials MSDeploy needs to deploy the WebDeploy package.
To generate a .publishsettings file, open the App Service in the Azure dashboard and click on the “Get publish profile” button:
Please note: If “Reset publish profile” is clicked, any existing publish profiles will cease to work, causing any deployments using them to fail.
This is an example of using the PublishWebDeploy.ps1 script deploy to a Sitecore instance using the publish profile from Azure:
.\PublishWebDeploy.ps1 -PackagePath .\MyPackage.wdp.zip -PublishSettingsPath .\MyAzure.PublishSettings -ViewLogs
This will deploy the package to the Azure App Service specified in the publish settings and display progress logs. The script will wait until the deployment completes before returning. This is useful for synchronizing and monitoring the deployment progress.
Visual Studio online allows users to create and manage very powerful release pipelines. There are a number of other build and release tools available in the marketplace. We are using VSO as an example of how to setup a release using the WebDeploy packages created by Sitecore TDS. In our sample release pipeline, we only had two steps:
The first step deploys the web deploy package using the VSO Azure App Service deployment step instead of the letting the Powershell script deploy it.
There are no other settings in the collapsed sections of the tasks. This task was configured exactly as shown above.
The second step runs the Powershell script supplied by Sitecore TDS:
There are no other settings in the collapsed sections of the tasks. This task was configured exactly as shown above.
The WebDeploy packages created by Sitecore TDS are not tied to the Azure infrastructure, so they can be used on any server that supports Web Deploy. This allows the same packages and scripts to be used across multiple environments, following best practices in release management.
The biggest challenge to using Web Deploy scripts on environments other than Azure is setting up Web Deploy. There are many resources on the web for this, so I will not reproduce the steps here. Here are the websites I found useful:
The first link above, shows how to switch the client machine to use TLS 1.2. Sitecore specifies that TLS 1.0 and 1.1 are disabled on the server, and MSDeploy defaults to TLS 1.0. I found this issue difficult to track down because MSDeploy would not communicate with my server at all until I forced it to TLS 1.2. Once I was communicating with the server, there were a few authentication issues to resolve. Solutions to the error I faced along with a number of other possible problems are covered in the other links.
Once Web Deploy is working on the server, installing the package works much like the example above:
.\PublishWebDeploy.ps1 -PackagePath .\HHogSSSS.Master.wdp.zip -ComputerName MyServer
-Username DeployUser -Password MyPassword -SiteName MySite -AuthType Basic
-MSDeployAllowUntrusted -ViewLogs
This example uses explicit connection information instead of a publish settings file.
When configuring Web Deploy on a server, you can generate a .publishsettings file. This file contains everything needed to deploy except the password. If you use this file, you can specify -PublishSettingsPath and -Password as parameters to the PublishWebDeploy.ps1 script.
The TDS WebAPI deployment service is designed to return status information and detailed logs while a deployment is taking place. The endpoint for the Deployment service is http://[server]/Api/TDS/WebDeploy. The WebAPI service exposes the following actions:
All actions use the HttpGet request verb to invoke their function.