.csproj file not found when building docker image using Azure Pipeline

Viewed 1072

My goal

I want to publish a docker image to Dockerhub from the Azure DevOps Pipeline. The pipeline runs after a commit on the master branch in Gitlab. The application I want to build an image for is a .Net Core Web API project. I'm using the automatically created Dockerfile by dotnet.

Error

This is the error I get:

enter image description here

Information

The folder structure of my application looks like this:

 - APIGateway [Folder]
   - APIGateway [Folder]
     - Controller/Models/Services etc... [Folders]
     - APIGateway.csproj
     - APIGateway.csproj.user
     - **Dockerfile**
     - Program.cs
     - Startup.cs
     - Appsettings,json
     - Appsettings.Development.json
   - APIGateway.UnitTests [Folder]
   - .dockerignore
   - APIGateway.sln
 - Readme.md

My Dockerfile looks like this:

enter image description here

For the Azure Pipeline, I added the .Net Core template task (restore, build, test, publish, publish artifect) to the agent job. The pipeline executes these tasks successfully. I also added the Docker BuildAndPush task and configured my Dockerhub as a container registry.

The commands for the BuildAndPush task:

enter image description here

I already looked at this similar post: Azure Pipeline to build docker images fails using same docker file in Visual Studio. People mainly suggested to add 'Build.Repository.LocalPath' to the build context. But I still get the same error.

Does anyone know how to solve this issue?

0 Answers
Related