Azure Pipelines: Exclude folders using Azure App Service Deploy
As @yang-shen-msft notes on Stack Overflow, there doesn't appear to be a way to honor the MSDeploySkipRules defined in the csproj file. Instead, files and folders can be skipped by defining the Additional Arguments (AdditionalArguments) parameter of the Azure App Service Deploy (AzureRmWebAppDeployment) task, as discussed in another Stack Overflow answer.
Since there doesn't appear to be any official documentation for the -skip rules, and the MSDeploy.exe documentation that Azure Pipelines references is out-of-date, the following provides additional details.
First, it's useful to recognize that when you deploy a project via Visual Studio, it's simply taking the MSDeploySkipRules configured in the csproj file and adding them to it's internal call of msdeploy.exe as -skip rules. So, given the following rule defined in the csproj:
&lt;Project Sdk=&quot;Microsoft.NET.Sdk.Web&quot;&gt;
  …
  &lt;ItemGroup&gt;
    &lt;MsDeploySkipRules Include=&quot;CustomSkipFolder&quot;&gt;
      &lt;ObjectName&gt;dirPath&lt;/ObjectName&gt;
      &lt;AbsolutePath&gt;wwwroot\\Uploads&lt;/AbsolutePath&gt;
    &lt;/MsDeploySkipRules&gt;
  &lt;/ItemGroup&gt;
&lt;/Project&gt;

The -skip rule is interpreted as:
msdeploy.exe -skip:objectName=dirPath,absolutePath=wwwroot\\Uploads

Translating this to the Azure App Service Deploy (AzureRmWebAppDeployment) task, the resulting yml might look like:
- task: AzureRmWebAppDeployment@4
  inputs:
    ConnectionType: 'AzureRM'
    azureSubscription: 'Azure Subscription'
    appType: 'webApp'
    WebAppName: 'MyStagingSite'
    packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'
    enableCustomDeployment: true
    DeploymentType: 'webDeploy'
    enableXmlTransform: false
    enableXmlVariableSubstitution: true
    RemoveAdditionalFilesFlag: true
    AdditionalArguments: '-skip:objectName=dirPath,absolutePath=wwwroot\\Uploads'


Note: Multiple -skip rules can be defined on the same msdeploy.exe call.

Unfortunately, as mentioned above, there doesn't appear to be any official, first-party documentation for the -skip rules on msdeploy.exe. The 2014 documentation acknowledges them, and provides two examples, but doesn't expand on the options. That said, way back in 2012, @richard-szalay wrote a useful article, &quot;Demystifying MSDeploy skip rules&quot;, which provides useful direction here for anyone requiring additional control over their -skip rules.