Azure管道:使用Azure App Service Deploy排除文件夹 [英] Azure Pipelines: Exclude folders using Azure App Service Deploy

本文介绍了Azure管道:使用Azure App Service Deploy排除文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Azure DevOps管道,其中包括用于部署 ASP.NET的 Azure App Service Deploy 任务( AzureRmWebAppDeployment ).核心3.1 项目:

I have an Azure DevOps Pipeline which includes an Azure App Service Deploy task (AzureRmWebAppDeployment) for deploying an ASP.NET Core 3.1 project:

- task: AzureRmWebAppDeployment@4
  inputs:
    ConnectionType: 'AzureRM'
    azureSubscription: 'Azure Subscription(01234567-89ab-cdef-0123-456789abcdef)'
    appType: 'webApp'
    WebAppName: 'MyStagingSite'
    packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'
    enableCustomDeployment: true
    DeploymentType: 'webDeploy'
    enableXmlTransform: false
    enableXmlVariableSubstitution: true
    RemoveAdditionalFilesFlag: false

Azure App Service 目标包含一些预先建立的文件夹中的文件,这些文件的管理与连续交付过程无关.我们想使用在目标位置删除其他文件标志( RemoveAdditionalFilesFlag ),同时保持这些文件夹不变.

The Azure App Service destination, however, contains files in several pre-established folders which are managed independent of the continuous delivery process. We would like to use the Remove additional files at destination flag (RemoveAdditionalFilesFlag) while leaving those folders intact.

免责声明:我认为这不是最佳做法,将来,我们会将这些文件移至单独的存储位置.在此之前,我想找到一个可以解决此问题的解决方案.

Disclaimer: I don't consider this a best practice and, in the future, we will be moving these files off to a separate storage location. Until then, I'd like to find a solution that will work resolve this.

Visual Studio 2019 中,我们使用 csproj 文件中的 MsDeploySkipRules 从发布过程中排除了这些文件,从而实现了这一目标:

In Visual Studio 2019, we achieve this by excluding those files from our publishing process using the MsDeploySkipRules in our csproj file:

<Project Sdk="Microsoft.NET.Sdk.Web">
  …
  <ItemGroup>
    <MsDeploySkipRules Include="CustomSkipFolder">
      <ObjectName>dirPath</ObjectName>
      <AbsolutePath>wwwroot\\Uploads</AbsolutePath>
    </MsDeploySkipRules>
  </ItemGroup>
</Project>

此方法对于Visual Studio效果很好,并因其Web部署发布过程而倍受赞誉.但是,即使使用"Web Deploy"部署方法( DeploymentType ),这些规则似乎也不受 AzureRmWebAppDeployment 任务的约束.

This approach works well for Visual Studio and is honored by its web deployment publishing process. These rules do not appear to be honored by the AzureRmWebAppDeployment task, however, even when using the "Web Deploy" deployment method (DeploymentType).

使用 AzureRmWebAppDeployDeploy 任务时,是否有办法兑现 MsDeploySkipRules ?如果不是,是否有办法提供在部署过程中应跳过或忽略的文件夹列表?或者,是否有其他任务发布到Azure App Service时将允许这些选项之一?

Is there a way to honor the MsDeploySkipRules when using the AzureRmWebAppDeployment task? If not, if there a way to provide a list of folders which should be skipped or ignored as part of the deployment process? Or, alternatively, if there another task that will permit one of these options when publishing to an Azure App Service?

注意:我还将其发布到

Note: I also posted this to the DevOps Beta, but as the site hasn't reached critical mass yet, I'm cross-posting it here.

推荐答案

使用AzureRmWebAppDeployment任务时是否有办法遵守MsDeploySkipRules?

Is there a way to honor the MsDeploySkipRules when using the AzureRmWebAppDeployment task?

不确定是否可以应用MsDeploySkipRules,但是有一种在部署过程中跳过特定文件的现成方法.

Not sure if there's a way to apply MsDeploySkipRules but there's exising way to skip specidic files during the deplyment process.

有关详细信息,请检查在VSTS Build中排除/跳过文件然后释放.

For detailed information, please check Exclude/Skip files in VSTS Build and release .

如上述线程中所建议,将其他参数添加到您的任务中以跳过特定文件.

As suggested in the above thread, add additional arguments to your task to skip the specific files.

在skip参数中填充文件路径.有关更多信息,请参见 Azure App Service部署任务(按Ctrl + F搜索其他参数)和语法的"Web部署操作设置" .

Fill your filepath in the skip argument. More information at Azure App Service Deploy task (press Ctrl+ F to search for additional arguments) and Web Deploy Operation Settings for the syntax.

请尝试一下,希望对您有所帮助.

Please have a try and hope this could help.

这篇关于Azure管道:使用Azure App Service Deploy排除文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆