Reputation: 13
I am using Azure Devops for automatic build & deploy of asp.net core 3.1 web app to Azure App Service.
The problem is that it's deploying the app to strange folder. Instead of the wwwroot folder it is in
/home/site/wwwroot/Content/D_C/a/1/s/ExampleFolder/ExampleFolder2/ExampleFolder3/obj/Staging/netcoreapp3.1/PubTmp/Out
The app service is on Linux if it matters.
How I can just fix/change it to be in the main folder?
Upvotes: 0
Views: 3912
Reputation: 13
I solved my issue by creating new Pipeline which is using dotnet
agents instead of Visual Studio build agents. When you are deploying to Linux App Service make sure to use CLI. You can see @martin-brandl answer for example pipeline.
You can also refer to this Devops SE question. The problem is similiar: https://devops.stackexchange.com/questions/9598/azure-devops-artifact-zip-folder-structure-for-net-core-3-0-application
I'm looking this fact:
I have an ASP.NET Core 3.0 application for which I have a full CI/CD setup in Azure DevOps. The Application is hosted on a Ubuntu 18.04 server machine.
Therefore I can safely assume that you are developing ASP.NET Core 3.0 app to be hosted in Ubuntu. Any .NET Core 3.0 (or later) application means that you should rely on the
dotnet build
instead of using VSBuild.Also you had stated that you will host the app on Ubuntu 18.x, then you should also run the build on Azure DevOps agent that runs on Ubuntu. This means you should only use
dotnet build
inDotNetCoreCLI@2
task, becauseVSBuild
task only runs on Windows based agent, not Ubuntu and it is intended to compile .NET Framework and other platform other than .NET Core.Please consult the official doc of DotNetCoreCLI@2 task at https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops
After you use
dotnet build
, usedotnet publish
to publish your artifact. It is much easier and it's also the best way to publish .NET Core apps.I have sample usage of
dotnet build
anddotnet publish
of this on my repo: https://github.com/eriawan/dotnetcore-cicd-samples/blob/master/yaml-samples/sample_pipelines_check.yml
Upvotes: 1
Reputation: 58931
You should share your Pipeline with us, otherwise, we can't tell you what you have to change/fix.
However, here an example that uses the AzureWebApp@1 Task to deploy a .NET Core 3.1 application to an 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
Upvotes: 1