以下是我的 YAML:
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(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
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'myWebsiteName'
- task: AzureWebApp@1
inputs:
azureSubscription: 'mySubscription'
appType: 'webApp'
appName: 'mySiteName'
package: '$(System.DefaultWorkingDirectory)/**/*.zip'
deploymentMethod: 'auto'
##[error]Error: No package found with specified pattern: D:\a\1\s\**\*.zip<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)
任务中将 $(Build.ArtifactStagingDirectory)
更改为 AzureWebApp
,但无济于事。
针对您目前的情况,我有一些建议可能会帮助您解决这个问题:
如果您可以在您的工件中找到 zip 文件。然后我们可以像这样修改你的yaml文件:
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
stages:
- stage: generate
jobs:
- job: Job_1
displayName: job_Create_Zip
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(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
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'myWebsiteName'
- stage:
jobs:
- job: Job_2
displayName: Deploy_zip
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'myWebsiteName'
itemPattern: '**/*.zip'
targetPath: '$(System.DefaultWorkingDirectory)'
- task: AzureWebApp@1
inputs:
azureSubscription: 'mySubscription'
appType: 'webApp'
appName: 'mySiteName'
package: '$(System.DefaultWorkingDirectory)/**/*.zip'
deploymentMethod: 'auto'
在
VSBuild
任务输出中,您应该看到一行:
上面示例中的包“{your_project_name}.zip”已在以下位置成功创建为单个文件: 文件:///D:/a/1/a
D:/a/1/a
来自您传递给 msbuild 的 /p:PackageLocation="$(build.artifactStagingDirectory)"
参数(与 DefaultWorkingDirectory 不同:D:\a\1\s\
)。
所以你的
AzureWebApp
任务必须查看内部$(build.artifactStagingDirectory)
。确保这些路径匹配。
这就是您需要做的全部,返回到构建部分并编辑您的 .YAML 文件。
在文件末尾添加
它会解决问题。