Trying to deploy a multi-project app to azure using pipelines. After trying various combinations (pipeline log is showing about 75/80 runs in the last couple of days), it looks like the problem is with the Dockerfile by Visual Studio 2019 or with the Azure Pipeline somewhere.
Here's what I've narrowed it down to:
Project A-
- create a vs asp.net core webapp project, say test1sp,
- select the checkbox which says create solution and project in the same folder,
- select docker support (I selected Linux) or add it later
- no code added, the boilerplate code runs fine as-is
- add it to GitHub
- create a project/pipeline in azure, source Github, I use the classic editor without YAML
- create a docker build/push task and setup, I choose the most basic options, subscriptions, etc.
- build works great, I also added a deploy to app service task and it deploys to the app service
Project B - my project is called demo8
Same as project A, except for step #2 - do NOT select create solution and project in the same folder. Follow the rest of the steps and now you should get this error.
Step 7/17 : COPY ["demo8/demo8.csproj", "demo8/"]
...
...
##[error]COPY failed: file not found in build context or excluded by .dockerignore: stat demo8/demo8.csproj: file does not exist
It works fine on localhost/docker
. So, I'm guessing maybe vs2019 uses some more tolerant implementation to patch it over. Or, there's a problem with azure's implementation or something else?
I am relatively new to Dockerfile editing and see lots of detailed/complex scenarios, hopefully, someone can shed some light on how to get it working?
Here's a screenshot of the project files/structure:
UPDATE - Moving the Dockerfile to the solution folder in project B makes it work in azure BUT
- then it does NOT work in Visual Studio, no debugging, etc.
- make a copy of Dockerfile in project & parent folders ( + keep in sync )
- BUT if your solution has multiple projects like mine then
- you have to name the Dockerfile different to have unique names in the parent folder
- and modify the pipelines to use respective file names
Posting it here in case it helps someone.