【问题标题】:Error in IIS Web App Deploy related to artifact package missing与工件包相关的 IIS Web App 部署错误
【发布时间】:2020-07-18 11:55:10
【问题描述】:

我在部署到 IIS 时遇到错误:

2020-04-06T10:51:49.9302914Z ##[error]Error: No package found with specified pattern.<br/>Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.

我有:

$(System.DefaultWorkingDirectory)\**\*.zip

作为 IIS Web App Deploy 任务中的包文件夹,首先我收到错误消息,我通过选择文件夹位置更改了文件夹:

$(System.DefaultWorkingDirectory)/_MyProject-ASP.NET-CI

但它没有任何帮助。错误保持不变。

这是我的 YAML:

steps:
- task: IISWebAppDeploymentOnMachineGroup@0
  displayName: 'IIS Web App Deploy'
  inputs:
    WebSiteName: '$(Parameters.WebsiteName)'
    VirtualApplication: dev.myproject.com
    Package: '$(System.DefaultWorkingDirectory)/_MyProject-ASP.NET-CI'
    ExcludeFilesFromAppDataFlag: true
    TakeAppOfflineFlag: True
    XmlTransformation: true
    XmlVariableSubstitution: True

发布工件任务如下:

steps:
- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
    ArtifactName: '$(Parameters.ArtifactName)'
  condition: succeededOrFailed()

我的构建中还有一个复制文件任务:

steps:
- task: CopyFiles@2
  displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
  inputs:
    SourceFolder: '$(Build.SourcesDirectory)'
    TargetFolder: '$(Build.ArtifactStagingDirectory)'

发布工件任务之前。

我已经寻找过类似的问题,但只找到了这样的解决方案:Azure DevOps pipeline release Error: No package found with specified pattern: D:\a\r1\a\**\*.zip 这不相关,因为我的 YAML 看起来像是在提供建议,并且我已经提到了复制文件任务。

此阶段的完整日志:

2020-04-06T10:51:48.3476113Z ##[section]Starting: IIS Web App Deploy
2020-04-06T10:51:48.3785215Z ==============================================================================
2020-04-06T10:51:48.3786130Z Task         : IIS web app deploy
2020-04-06T10:51:48.3786911Z Description  : Deploy a website or web application using Web Deploy
2020-04-06T10:51:48.3787618Z Version      : 0.156.9
2020-04-06T10:51:48.3788205Z Author       : Microsoft Corporation
2020-04-06T10:51:48.3789263Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/iis-web-app-deployment-on-machine-group
2020-04-06T10:51:48.3790410Z ==============================================================================
2020-04-06T10:51:49.9302914Z ##[error]Error: No package found with specified pattern.<br/>Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.
2020-04-06T10:51:49.9420801Z ##[section]Finishing: IIS Web App Deploy

我想不出这是什么!

我是新发布的,所以我完全不确定还有什么遗漏或者我是否设置正确。

编辑

这是完整的构建 YAML:

pool:
  name: Azure Pipelines
  demands:
  - msbuild
  - visualstudio

    steps:
    - task: NuGetToolInstaller@0
      displayName: 'Use NuGet 4.4.1'
      inputs:
        versionSpec: 4.4.1

    - task: NuGetCommand@2
      displayName: 'NuGet restore'
      inputs:
        restoreSolution: '$(Parameters.solution)'

    - task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@3
      displayName: 'Use Yarn 1.22.1'
      inputs:
        versionSpec: 1.22.1

    - task: geeklearningio.gl-vsts-tasks-yarn.yarn-task.Yarn@3
      displayName: 'Yarn install'
      inputs:
        projectDirectory: Web
        arguments: install

    - task: geeklearningio.gl-vsts-tasks-yarn.yarn-task.Yarn@3
      displayName: 'Yarn build'
      inputs:
        projectDirectory: Web
        arguments: build

    - task: VSBuild@1
      displayName: 'Build solution'
      inputs:
        solution: '$(Parameters.solution)'
        msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"'
        platform: '$(BuildPlatform)'
        configuration: '$(BuildConfiguration)'

    - task: VSTest@2
      displayName: 'Test Assemblies'
      inputs:
        testAssemblyVer2: |
         **\$(BuildConfiguration)\*test*.dll
         !**\obj\**
        platform: '$(BuildPlatform)'
        configuration: '$(BuildConfiguration)'
      enabled: false

    - task: PublishSymbols@2
      displayName: 'Publish symbols path'
      inputs:
        SearchPattern: '**\bin\**\*.pdb'
        PublishSymbols: false
      continueOnError: true

    - task: CopyFiles@2
      displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
      inputs:
        SourceFolder: '$(Build.SourcesDirectory)'
        TargetFolder: '$(Build.ArtifactStagingDirectory)'

    - task: PublishBuildArtifacts@1
      displayName: 'Publish Artifact'
      inputs:
        PathtoPublish: '$(build.artifactstagingdirectory)'
        ArtifactName: '$(Parameters.ArtifactName)'
      condition: succeededOrFailed()

编辑 2

VSBuild 任务的日志:

2020-04-07T15:37:05.6665411Z ##[section]Starting: Build solution
2020-04-07T15:37:05.7033615Z ==============================================================================
2020-04-07T15:37:05.7034084Z Task         : Visual Studio build
2020-04-07T15:37:05.7034450Z Description  : Build with MSBuild and set the Visual Studio version property
2020-04-07T15:37:05.7034755Z Version      : 1.166.0
2020-04-07T15:37:05.7034990Z Author       : Microsoft Corporation
2020-04-07T15:37:05.7035347Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/visual-studio-build
2020-04-07T15:37:05.7036406Z ==============================================================================
2020-04-07T15:37:13.7071155Z ##[command]"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [16.0,17.0) -latest -format json
2020-04-07T15:37:13.7989257Z ##[command]"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [16.0,17.0) -products Microsoft.VisualStudio.Product.BuildTools -latest -format json
2020-04-07T15:37:13.8796977Z ##[command]"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,16.0) -latest -format json
2020-04-07T15:37:14.2358042Z ##[command]"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe" "D:\a\1\s\myproject.com.sln" /nologo /nr:false /dl:CentralLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=0ce4c4e1-c2fb-42a2-b03b-860f664e3238|SolutionDir=D:\a\1\s"*ForwardingLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.166.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="D:\a\1\a\\" /p:platform="any cpu" /p:configuration="release" /p:VisualStudioVersion="15.0" /p:_MSDeployUserAgent="VSTS_ec7516ed-027d-4f0f-95e9-525fa5443e34_build_6_0"
2020-04-07T15:37:14.3407720Z Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
2020-04-07T15:37:14.3741342Z Build started 4/7/2020 3:37:14 PM.
2020-04-07T15:37:14.5565930Z ##[warning]D:\a\1\s\myproject.com.sln.metaproj(0,0): Warning MSB4126: The specified solution configuration "release|any cpu" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration.
2020-04-07T15:37:14.5685931Z Project "D:\a\1\s\myproject.com.sln" on node 1 (default targets).
2020-04-07T15:37:14.5693512Z D:\a\1\s\myproject.com.sln.metaproj : warning MSB4126: The specified solution configuration "release|any cpu" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration. [D:\a\1\s\myproject.com.sln]
2020-04-07T15:37:14.5773938Z Done Building Project "D:\a\1\s\myproject.com.sln" (default targets).
2020-04-07T15:37:14.5806168Z 
2020-04-07T15:37:14.5806758Z Build succeeded.
2020-04-07T15:37:14.5931062Z 
2020-04-07T15:37:14.5943625Z "D:\a\1\s\myproject.com.sln" (default target) (1) ->
2020-04-07T15:37:14.5945416Z (ValidateSolutionConfiguration target) -> 
2020-04-07T15:37:14.5948111Z   D:\a\1\s\myproject.com.sln.metaproj : warning MSB4126: The specified solution configuration "release|any cpu" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration. [D:\a\1\s\myproject.com.sln]
2020-04-07T15:37:14.5952737Z 
2020-04-07T15:37:14.5952959Z     1 Warning(s)
2020-04-07T15:37:14.5953123Z     0 Error(s)
2020-04-07T15:37:14.5954912Z 
2020-04-07T15:37:14.5955667Z Time Elapsed 00:00:00.20
2020-04-07T15:37:14.6534792Z ##[section]Finishing: Build solution

【问题讨论】:

  • 你能把你的完整 YAML 文件放上去吗?我想知道你的任务是按什么顺序完成的。
  • @Krzysztof 我已经在上面展示了 IIS Web App Deploy YAML。我现在已经粘贴了完整版本的 YAML。虽然我不确定复制文件是否应该存在于构建中,因为现在所有构建都需要很长时间
  • 复制整个源目录。对我来说这是一个错误。而且您已经将您的包发布到 ArtifactStagingDirectory。我建议您删除 CopyFiles 任务并在 PublishBuildArtifact 添加 powershell 任务(将其放在任务之后:VSBuild@1 任务之后)以检查 ArtifactStagingDirectory 中的内容。 - 任务:PowerShell@2 输入:targetType:'inline' 脚本:ls '$(build.artifactstagingdirectory)'
  • @Krzysztof 我已经做到了,不知道它应该做什么?另外,如果我不复制文件,我会在构建时收到##[warning]Directory 'D:\a\1\a' is empty. Nothing will be added to build artifact 'drop'. 警告,这也可能是我的错误的根源。
  • 您是否验证了构建实际上正在正确发布?

标签: azure-devops azure-pipelines web-deployment azure-pipelines-release-pipeline azure-artifacts


【解决方案1】:

我想不出这是什么!

您似乎正在使用Microsoft-hosted agent 来运行您的构建和发布管道。注意:每次运行管道(作业/阶段)时,都会获得一个新的虚拟机。

所以 Azure Devops 实际上提供了不同的 VM 来运行您的构建 yaml 和发布 yaml,构建 yaml 和发布 yaml 中的ArtifactStagingDirectory不一样 位置(它们'甚至不在同一台机器上)。此外,$(Build.ArtifactStagingDirectory)build variables 而不是 release variables。我相信以上几点是您的 IIS Web App Deploy task 抱怨缺少工件包的原因。

对此问题的建议:

Build Artifact 可用于在构建和发布管道之间共享文件。正确的使用方法是: 1. 在 Build pipeline 中使用Publish Build ArtifactPublish Pipeline Artifact 发布工件。 2. 然后在发布管道中使用Download Build ArtifactsDownload Pipeline Artifacts task 从构建管道下载已发布的工件。

您需要一项额外的任务才能将工件从构建管道下载到运行您的发布管道的 VM。之后,您的部署任务可以访问发布管道中缺少的工件。

对于您的方案:您的构建 yaml 和发布 yaml 可能不在同一个 multi-stage pipeline 中,因此现在更建议您使用管道工件。

如果您的构建和发布在同一个 yaml 管道中,请选择当前运行,如果您想使用来自另一个构建管道的源,请选择特定运行(构建标签不是必需的选项)。执行后,此任务将下载并从您的发布代理中的构建中提取工件。

【讨论】:

  • 构建和发布在同一个 yaml 管道中是什么意思?你的意思是我的发布是否使用与拉取请求相同的构建?我很困惑@Lance
  • 我的意思是根据您上面分享的内容,您似乎使用了一个 yaml 管道来构建和另一个 yaml 管道来部署。但是无论您使用one to build and deploy 还是one build yaml+one deploy yaml,下载管道工件任务都应该对您的问题有所帮助。你可以试试任务...
【解决方案2】:

我稍微简化了你的情况,并在 build.artifactstagingdirectory 中获得了包

这是我的 YAML 文件

trigger:
- master

pool:
  vmImage: 'windows-latest'

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'

- task: NuGetToolInstaller@1
  displayName: 'Use NuGet 5.5.1'
  inputs:
    versionSpec: 5.5.1

- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: 'stackoverflow/01/TestApp/TestApp.sln'

- task: VSBuild@1
  inputs:
    solution: 'stackoverflow/01/**/*.sln'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"'
    restoreNugetPackages: true

- script: |
    echo '$(build.artifactstagingdirectory)'
    ls '$(build.artifactstagingdirectory)'
  displayName: 'Run a multi-line script'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
    ArtifactName: 'SO-01'
  condition: succeededOrFailed()

这是我在 VSBuil 任务日志中的内容

2020-04-07T09:33:49.9422539Z   Successfully executed Web deployment task.
2020-04-07T09:33:49.9523439Z   Package "WebApp.zip" is successfully created as single file at the following location:
2020-04-07T09:33:49.9526188Z   file:///d:/a/1/a

如果我检查目录 build.artifactstagingdirectory 我有这个:

您可以尝试像上面这样非常简单的构建管道吗?请移除所有纱线和其他不需要的任务(包装目的不需要)。 Here 如果您认为这很有价值,您有我的解决方案的链接。你能发布你的 VSBuild 任务的日志吗?

【讨论】:

  • 现在我删除了 Copy files 任务,我再次在构建日志中收到错误:2020-04-07T15:37:16.1260382Z ##[warning]Directory 'D:\a\1\a' is empty. Nothing will be added to build artifact 'drop'. 以及我上面提到的错误消息。
  • 而实际上D:\a\1\a 应该位于哪里?在目标机器上?
  • 否,D:\a\1\a' is a directory on build agent. Can you attach log of your VSBuild@1` 任务?
  • 我已经编辑了我的问题并添加了构建日志@Krzysztof
  • @nickornotto 你确定你的解决方案中有一个网络项目吗?你能说出你的解决方案中有什么样的项目吗?这些问题可能看起来很愚蠢,但是对于没有 Web 项目的解决方案,我得到了类似的输出。你能放一个你的 Visual Studio 解决方案资源管理器的屏幕吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多