Azure devops 与工件包丢失相关的IIS Web应用程序部署中出错

Azure devops 与工件包丢失相关的IIS Web应用程序部署中出错,azure-devops,azure-pipelines,web-deployment,azure-pipelines-release-pipeline,azure-artifacts,Azure Devops,Azure Pipelines,Web Deployment,Azure Pipelines Release Pipeline,Azure Artifacts,我在部署到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.

我在部署到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.
作为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: CopyFiles@2
  displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
  inputs:
    SourceFolder: '$(Build.SourcesDirectory)'
    TargetFolder: '$(Build.ArtifactStagingDirectory)'
在发布工件任务之前

我寻找过类似的问题,但只找到了这样的解决方案:这些解决方案并不相关,因为我的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
编辑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
我想不出这是什么了

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

因此Azure Devops实际上提供了不同的虚拟机来运行构建yaml和发布yaml,构建yaml和发布yaml中的
ArtifactStagingDirectory
不在同一个位置(它们甚至不在同一台机器上)。另外,
$(Build.ArtifactStagingDirectory)
代替了。我相信以上几点就是您的
iisweb应用程序部署任务
抱怨缺少工件包的原因

对此问题的建议:

构建工件可用于在构建和发布管道之间共享文件。正确的使用方法是:1。使用或在构建管道中发布工件。2.然后使用或在发布管道中从构建管道下载发布的工件

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

对于您的场景:您的构建yaml和发布yaml可能不在同一个位置,所以现在更推荐您使用管道工件


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

我简化了您的案例,并在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,我有:


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

您能把完整的YAML文件放进去吗?我想知道您的任务是按什么顺序进行的。@Krzysztof我已经在上面展示了IIS Web App Deploy
YAML
。我现在已经粘贴了完整构建的YAML。虽然我不确定复制文件是否应该存在于构建中,因为现在所有构建都需要很长时间才能复制整个源目录。对我来说,这是一个错误。您已经将包发布到ArtifactStagingDirectory。我建议您删除CopyFiles任务,并在PublishBuildArtifact之前添加powershell任务(将其放在任务之后:VSBuild@1任务)检查ArtifactStagingDirectory中的内容。-任务:PowerShell@2输入:targetType:'inline'脚本:ls'$(build.artifactstagingdirectory)@Krzysztof我已经完成了,不确定它应该做什么?另外,如果我不复制文件,我会得到
##[warning]目录“D:\a\1\a”为空。将不会向生成工件“drop”添加任何内容。
生成时发出警告,这可能也是我的错误来源。您是否验证了生成实际上是正确发布的?现在,我删除了
复制文件任务
后,生成日志中再次出现错误:
2020-04-07T15:37:16.1260382Z.[警告]目录“D:\a\1\a”为空。不会向构建工件“drop”添加任何内容。
以及前面提到的错误消息。实际上
D:\a\1\a
应该位于哪里?在目标计算机上?否,
D:\a\1\a'是生成代理上的目录。能否附上您的
VSBuild@1`任务?我已经编辑了我的问题并添加了构建日志@Krzysztof@nickornotto您确定您的解决方案中有web项目吗?你能告诉我你的解决方案中有什么样的项目吗?这些问题可能看起来很愚蠢,但我得到了类似的输出,用于无web项目的解决方案。你能把你的VisualStudio解决方案浏览器放在一个屏幕上吗?你说构建和发布在同一个yaml管道中是什么意思?你的意思是我的版本是否使用与拉请求相同的构建?我对@Lance感到困惑,我的意思是,根据您在上面共享的内容,您似乎使用了一个yaml管道来构建,而使用了另一个yaml管道来部署。但是,无论您使用
one构建和部署
还是
one build yaml+one deploy yaml
,下载管道工件任务都应该对您的问题有所帮助。你可以试试这个任务。。。
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
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()
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