Advanced Sitecore Deployments: How to Skip Files and Directories with SIF and WebDeploy
In the Sitecore ecosystem, there are various options for hosting solutions and deploying applications. In this article, I want to focus on the approach that involves deploying applications using WDP packages with WebDeploy. Sitecore, however, offers its own wrapper around WebDeploy called the Sitecore Installation Framework (SIF).
SIF provides a comprehensive set of tools and utilities, enabling flexible and efficient deployments. Notably, it supports the installation of SCWDP packages (which are essentially the same as WDP packages) and allows you to configure installation parameters and processes in a highly customizable way using JSON files.
However, in this article, I want to address a specific requirement you might encounter when working with Sitecore deployments. Imagine you are deploying your application using a WDP package, not just for the initial setup but as part of every deployment. This approach can make sense in certain scenarios, as it ensures that you always have a fresh and consistent setup of your application.
That said, when deploying the application to an existing site, you might want to preserve certain files—such as logs, analytics data, cache, etc.—from being overwritten during the deployment process. After reviewing the WebDeploy documentation, I discovered that this can be achieved using built-in parameters. Unfortunately, Sitecore’s documentation doesn’t provide detailed coverage of this topic.
The key lies in the WebDeploy task within the SIF configuration. To achieve this, you simply need to extend the JSON section of the task with the necessary additional parameters.
Below is an example of how the InstallWDP task is configured by default:
领英推荐
Now, here’s how the configuration looks when additional parameters are added to skip specific folders during deployment:
Essentially, we’ve just added a Skip section to the configuration:
"Skip": [
{
"objectName": "dirPath",
"absolutePath": "App_Data\\\\logs$"
},
{
"objectName": "dirPath",
"absolutePath": "App_Data\\\\viewstate$"
},
{
"objectName": "dirPath",
"absolutePath": "App_Data\\\\diagnostics$"
}
]
In my case, I excluded specific paths, but the Skip section also supports the use of wildcards. This allows you to exclude files or directories that match a specified pattern, offering greater flexibility for customizing your deployment process. The $ at the end ensures that only the App_Data\Logs folder is targeted and not any subfolders or files.