我正在使用Azure Devops将asp.net core 3.1 Web应用自动构建和部署到Azure App Service。
问题在于它正在将应用程序部署到奇怪的文件夹中。它位于而不是wwwroot文件夹中
/home/site/wwwroot/Content/D_C/a/1/s/ExampleFolder/ExampleFolder2/ExampleFolder3/obj/Staging/netcoreapp3.1/PubTmp/Out
如果需要,该应用程序服务可以在Linux上使用。
我如何才能将其修复/更改为位于主文件夹中?
答案 0 :(得分:1)
我通过创建使用dotnet
代理而不是Visual Studio构建代理的新管道解决了我的问题。部署到Linux App Service时,请确保使用CLI。您可以在管道中看到@ martin-brandl答案。
您也可以参考这个Devops SE问题。问题很相似: https://devops.stackexchange.com/questions/9598/azure-devops-artifact-zip-folder-structure-for-net-core-3-0-application
我正在寻找这个事实:
我有一个ASP.NET Core 3.0应用程序,在Azure DevOps中有完整的CI / CD安装程序。该应用程序托管在Ubuntu 18.04服务器计算机上。
因此,我可以安全地假设您正在开发要在Ubuntu中托管的ASP.NET Core 3.0应用程序。任何.NET Core 3.0(或更高版本)应用程序都意味着您应该依靠
dotnet build
而不是使用VSBuild。您还说过,将在Ubuntu 18.x上托管该应用程序,然后还应在Ubuntu上运行的Azure DevOps代理上运行该版本。这意味着您仅应在
dotnet build
任务中使用DotNetCoreCLI@2
,因为VSBuild
任务仅在基于Windows的代理上运行,而不在Ubuntu上运行,并且旨在编译.NET Framework和除之外的其他平台。 NET核心。请通过https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops查阅DotNetCoreCLI @ 2任务的官方文档
使用
dotnet build
后,使用dotnet publish
发布工件。这要容易得多,它也是发布.NET Core应用程序的最佳方法。我在仓库中有
dotnet build
和dotnet publish
的示例用法:https://github.com/eriawan/dotnetcore-cicd-samples/blob/master/yaml-samples/sample_pipelines_check.yml
答案 1 :(得分:0)
您应该与我们共享您的管道,否则,我们无法告诉您您必须更改/修复的内容。
但是,这里有一个示例,该示例使用AzureWebApp@1任务将.NET Core 3.1应用程序部署到Azure Web App。
trigger:
branches:
include:
- master
stages:
- stage: Build
jobs:
- job: 'BuildArtifact'
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UseDotNet@2
inputs:
packageType: sdk
version: 3.1.x
- task: DotNetCoreCLI@2
displayName: Build
inputs:
command: 'build'
projects: PATH/TO/YOUR/Project.csproj
arguments: --output $(System.DefaultWorkingDirectory)/publish_output --configuration Release
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/publish_output'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
- publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
artifact: drop
- stage: Deploy
dependsOn: Build
condition: succeeded()
jobs:
- deployment: 'Deploy'
pool:
vmImage: 'ubuntu-latest'
environment: Development
strategy:
runOnce:
deploy:
steps:
- task: AzureWebApp@1
displayName: Azure Web App Deploy
inputs:
azureSubscription: YourAzureSubscription
appName: YourAppName
package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip
appType: webAppLinux