gpt4 book ai didi

c# - 找不到用于部署到 Azure Web 服务的已发布 DLL

转载 作者:行者123 更新时间:2023-12-03 02:00:23 28 4
gpt4 key购买 nike

我从管道中得到以下信息。

Script contents: dotnet publish
========================== Starting Command Output ===========================/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/18bf48c0-d56c-4696-a002-26fa9f360fa5.sh
MSBuild version 17.6.1+8ffc3fe3d for .NET
Determining projects to restore...
Restored /home/vsts/work/1/s/Api/Api.csproj (in 3.05 sec).
Api -> /home/vsts/work/1/s/Api/bin/Debug/net7.0/Api.dll
Api -> /home/vsts/work/1/s/Api/bin/Debug/net7.0/publish/

我可以清楚地看到Api.dll已被创建。然而,在下一份工作中,代理声称没有任何内容与该模式匹配。

Got service connection details for Azure App Service:'app-temp'
##[error]Error: No package found with specified pattern: /home/vsts/work/1/s/**/*.dll
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.

我什至尝试显式设置路径,但看不出 DLL 的公布位置与部署者查看的位置之间有任何区别。

Got service connection details for Azure App Service:'app-aux-identity-temp'
##[error]Error: No package found with specified pattern: /home/vsts/work/1/s/Api/bin/Debug/net7.0/Api.dll
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.

我在这里缺少什么?

我只能推测该文件必须是ZIP,但我在文档中没有发现任何有关此类限制的信息。另外,在向导中,甚至提到内容可能是 ZIP、WAR 或 dotnet build 留下的内容。我的情况也是如此,因为我在 dotnetpublish 之前运行 dotnetbuild

我不知道如何解决这个问题。

最佳答案

如果您没有指定构建工件的正确路径,则会发生错误。引用 Krzysztof Madej 的 SO Thread 回答

当我在 AzureWebApp@1 任务的 package: 中使用了错误的路径时,即使我收到了与您相同的错误代码,请参阅以下内容:-

enter image description here

我使用下面的 YAML 默认管道将我的 Asp .Net 应用程序部署到 Azure Web 应用程序,并且成功,请参阅下面:-

我已经为下面的 YML 管道引用了 MS Document1MS Document2 并对其进行了修改。

trigger:
- master

pool:
vmImage: windows-latest

steps:

- task: UseDotNet@2
inputs:
version: '6.x'

- task: UseDotNet@2
displayName: 'Install .NET Core SDK'
inputs:
version: 6.x
performMultiLevelLookup: true
includePreviewVersions: true # Required for preview versions


- task: DotNetCoreCLI@2
displayName: Build
inputs:
command: build
projects: '**/*.csproj'
arguments: '--configuration $(buildConfiguration)' # Update this to match your need


- task: DotNetCoreCLI@2
inputs:
command: publish
publishWebProjects: True
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: True

# this code takes all the files in $(Build.ArtifactStagingDirectory) and uploads them as an artifact of your build.
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifactName: 'myWebsiteName'

- task: AzureWebApp@1
inputs:
azureSubscription: 'SID subscription(9)(0151c365-f598-44d6-b4fd-e2b6e97cb2a7)'
appType: 'webApp'
appName: 'siliconwebapp32'
package: '$(Build.ArtifactStagingDirectory)/**/*.zip'
deploymentMethod: 'auto'

输出:-

enter image description here

enter image description here

更新的答案:-

引用我的answer here

根据我的回答:-

I have tried the deployment in 2 separate stages here. Afterdownloading the Artifact from my build task to Deploy task I added '$(Agent.BuildDirectory)/**/*.zip' as my Artifact was downloaded in /home/vsts/work/1/publishedApp and the predefined variable for /home/vsts/work/1 is Agent.BuildDirectory Check the predefined value for the path where your artifact is downloaded in Deploy stage.

我的 YAML 脚本:-


trigger:
branches:
include:
- main

jobs:
- job: Build
displayName: 'Build and Publish'
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UseDotNet@2
displayName: 'Install .NET Core SDK'
inputs:
version: '6.x'

- task: DotNetCoreCLI@2
displayName: 'Restore Dependencies'
inputs:
command: 'restore'
projects: '**/*.csproj'

- task: DotNetCoreCLI@2
displayName: 'Build Project'
inputs:
command: 'build'
projects: '**/*.csproj'
arguments: '--configuration Release'

- task: DotNetCoreCLI@2
displayName: 'Publish Project'
inputs:
command: 'publish'
projects: '**/*.csproj'
publishWebProjects: true
arguments: '--configuration Release --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: true

- task: PublishPipelineArtifact@1
displayName: 'Publish Artifact'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifactName: 'publishedApp'
publishLocation: 'pipeline'

- job: Deploy
displayName: 'Deploy to Azure Web App'
dependsOn: Build
pool:
vmImage: 'ubuntu-latest'
steps:
- download: current
artifact: 'publishedApp'

- task: UseDotNet@2
displayName: 'Install .NET Core SDK'
inputs:
version: '6.x'

- task: AzureWebApp@1
displayName: 'Azure Web App Deploy'
inputs:
azureSubscription: 'subscription'
appType: 'webApp'
appName: 'app-name'
package: '$(Agent.BuildDirectory)/**/*.zip'
deploymentMethod: 'auto'

输出:-

enter image description here

enter image description here

enter image description here

enter image description here

关于c# - 找不到用于部署到 Azure Web 服务的已发布 DLL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76397280/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com