When building an ASP.NET Core project in Azure Pipelines, the YAML file below only works when placing the solution and project in the same directory. What can be done to the YAML file below without the need of placing the solution and project in the same directory? This matters in case there are multiple projects in a single solution.
Here are the steps taken:
- Created new ASP.NET Core 3.1 project with support for Linux Docker container using Visual Studio 2019.
- Pushed to Azure repository "DockerTest".
- Created pipeline using template "Docker: Build and push an image to Azure Container Registry", which essentially generated the YAML below.
Which resulted in the following error during the build:
COPY failed: stat /var/lib/docker/tmp/docker-builder701699653/DockerTest/DockerTest.csproj: no such file or directory
azure-pipelines.yml
# Docker
# Build and push an image to Azure Container Registry
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
- master
resources:
- repo: self
variables:
# Container registry service connection established during pipeline creation
dockerRegistryServiceConnection: 'example-connection-string'
imageRepository: 'dockertest'
containerRegistry: 'example.azurecr.io'
dockerfilePath: '$(Build.SourcesDirectory)/DockerTest/Dockerfile'
tag: '$(Build.BuildId)'
# Agent VM image name
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)