Closed dominikjeske closed 1 year ago
I agree this tripped me up as well. If you can specify the location of the Dockerfile then it should be possible to debug with it in the specified location
Does anybody have a solution/workaround to share a single Dockerfile in parent folder for multiple .csproj
while still maintaining debugging through .dcproj
functional?
Would be super covenant for microservices architecture...
Hmm only symbolic link comes to my mind but i'm not sure it will work and how git will work with this
As a follow-up, tried to link my dotnet project to compose service by specifying build.labels
with com.microsoft.visual-studio.project-name: "My.Project"
in either docker-compose.yml
or docker-compose.vs.debug.yml
, but still no luck.
This is really annoying as we are adding more and more services to existing solution while Dockerfile keeps getting more and more complicated with multi-stage, hardening, testing, external tooling support, ...
@ggirard07, @dominikjeske, @DanBiscotti Visual Studio 2022 17.5 Preview 2 now allows for specifying the label com.microsoft.visual-studio.project-name
on a service to specify the associated project. For instance:
webapplication2:
image: ${DOCKER_REGISTRY-}webapplication2
labels:
com.microsoft.visual-studio.project-name: "WebApplication2"
build:
context: .
dockerfile: WebApplication2/Sub/Dockerfile
Allows for debugging WebApplication2 even though the Dockerfile is in a subfolder.
Note: the label can only be set in docker-compose.yml or docker-compose.override.yml
This is now fixed in 17.5. Closing
Yesterday I lost whole day trying to figure out why I can't debug my project (ASP.NET core web api) with docker compose and VS 2022 17.2.4 - after some research I found this https://developercommunity.visualstudio.com/t/debugger-silently-fails-to-attach-to-docker-compos/552563 with statement " In summary, the Visual Studio Docker Compose tools will attach to containers only if the Dockerfile is directly adjacent its corresponding project file" and I have docker file in parent folder of csproj I have some problems with this:
Are there any plans for changing this behavior? If not it should be at least better documented and tooling should inform about this in some way.