microsoft / DockerTools

Tools For Docker, including Visual Studio Provisioning and Publishing
Other
175 stars 26 forks source link

"Preparing Containers" not providing docker-compose.vs.debug.g.yml anymore #311

Closed JBBianchi closed 2 years ago

JBBianchi commented 2 years ago

Hello,

Since the beginning of the week, my Visual Studio 2019 seem to be unable to prepare my containers.

I installed the latest updates for VS2019 (16.11.5), Docker Desktop (4.1.1, engine 20.10.8, compose 1.29.2, cred helper 0.6.4, k8s 1.21.5, snyk 1.563.0) & all my Windows 10 Updates but the problem persist. I tried to repair, uninstall/reinstall, clean VS cache, reset settings/user data, still the same behavior:

When I launch Visual Studio with a "Docker Compose" project in it, VS starts to prepare the containers (for "fast start" or I don't recall the exact name of the process). In the Container Tools outputs:

Starting Docker Desktop...
========== Preparing Containers ==========
Getting Docker containers ready...
docker-compose  -f "C:\path-to-solution\deployment\docker-compose\docker-compose.yml" -p dockercompose9464286311065417946 --ansi never build
...
#15 [container build  3/30] COPY [src/Gateway/Gateway.Api/Gateway.Api.csproj, src/Gateway/Gateway.Api/]
#15 sha256:dfcd4c4f1e6bfac13a74e8fb1b8610e0ef71b4590e224402a1715c994e4525ab
#15 ERROR: "/src/Gateway/Gateway.Api/Gateway.Api.csproj" not found: not found
...
------
A non-critical error occurred while getting containers ready.  Your project will continue to function normally.  The error was: failed to solve: rpc error: code = Unknown desc = failed to compute cache key: "/src/Gateway/Gateway.Api/Gateway.Api.csproj" not found: not found

The same behavior appears in every solution, so it's not solution/project specific but "Visual studio-wide". As you can see, the docker-compose command misses an argument, it's supposed to add the -f C:\path-to-solution\deployment\docker-compose\obj\Docker\docker-compose.vs.debug.g.yml created by VS automagically but it doesn't. In consequence, any reference to src/ or app/ fails.

I don't have any idea where to look for to fix this issue. Any help would be greatly appreciated.

Best regards,

Edit: Note that when clicking the start button "Docker Compose", the build process do use the debug yml from VS:

Build started...
1>------ Build started: Project: docker-compose, Configuration: Debug Any CPU ------
1>docker-compose  -f "C:\path-to-solution\deployment\docker-compose\docker-compose.yml" -f "C:\path-to-solution\deployment\docker-compose\obj\Docker\docker-compose.vs.debug.g.yml" -p dockercompose9464286311065417946 --ansi never config

The build succeed, the container runs but the app doesn't run in the container (application unreachable, the "Logs" tab of the container displays "No logs found for this container").

Edit 2: It's working in VS 2022 Preview.

Edit 3: After installing VS 2022 Preview, VS 2019 works again ... makes total sense...

Edit 4: Nevermind Edit 3, it's even more funky. I boot my computer, I launch the project in VS2019, it's failing (no -f debug.yml, no access to src/app, empty logs container on start). I close and I launch the project in VS2022, it works. I close and relaunch VS2019, it works ...

JBBianchi commented 2 years ago

Idk if we can consider this issue close or not. I don't even know how you could reproduce this behavior, it seems so weird ...

martyt commented 2 years ago

Several of our developers just started having this problem in the last few days. It all seems to coincide with the update of Docker for Windows to v4.1.0 and then to 4.1.1. I have been running v4.1.1 for several days without issue, but suddenly started seeing the issue yesterday with no obvious correlation to any other changes. The primary symptom I see is that the build seems to go fine, the containers seem to get started, but all I see in the Container Tools window is

========== Debugging ==========

along with no logs on the console of any of the containers that were started.

I've verified that VS2022 preview can launch and debug just fine. But switching back to VS2019 immediately after running VS2022 doesn't work for me.

We're going to try reverting to Docker v4.0.1, which had been working fine for many weeks. It all seems strange to me that this issue would suddenly show up.

I'd definitely like to see this issue re-opened.

JBBianchi commented 2 years ago

I indeed think I've been a little "optimistic" saying in "works again" in VS2019 after running it in VS2022, I don't think it does. The weird this is that the -f "C:\path-to-solution\deployment\docker-compose\obj\Docker\docker-compose.vs.debug.g.yml" argument appears again in the Preparing Containers containers output but starting/building still behave is a strange way (no logs/no app...)

martyt commented 2 years ago

Can you try clearing out the bin and obj folders in your solution folder and trying again? I'm not sure if that's what fixed my issue or not, but I'm now able to debug using Docker v4.1.1 (I also repaired my VS2019 installation, but I don't think that had anything to do with the problem.)

You can run gci -include bin,obj -recurse | remove-item -force -recurse from a Powershell window to quickly clear those folders.

JBBianchi commented 2 years ago

@martyt I did already, it was one of my first thoughts. I removed the entire project and reclone it from our git server (so without bin/obj) but VS still failed. Just to be sure, I tried doing it again with your command but I end up with the same result.

martyt commented 2 years ago

@JBBianchi So things seem to be working for me now in Docker v4.1.1, but I'm not sure which of the changes I made resolved the issue:

Others in my organization are still having no success in VS2019 and have moved to VS2022 Preview for now, having failed to get Docker v3.6 or 4.01 to work -- leading me to believe this is more of a VS problem than a Docker problem.

JBBianchi commented 2 years ago

@JBBianchi So things seem to be working for me now in Docker v4.1.1, but I'm not sure which of the changes I made resolved the issue:

  • Debugged the solution in VS2022 Preview (latest update)
  • Repaired VS2019 installation
  • Cleared bin and obj folders in my solution
  • Deleted the %UserProfile%\vsdbg and %UserProfile%\onecoremsvsmon` folders
  • Deleted all solution-related containers and images
  • Rebooted my machine a few times

Others in my organization are still having no success in VS2019 and have moved to VS2022 Preview for now, having failed to get Docker v3.6 or 4.01 to work -- leading me to believe this is more of a VS problem than a Docker problem.

@martyt I tried > * Deleted the %UserProfile%\vsdbg and %UserProfile%\onecoremsvsmon folders` because I didn't try that (manually at least) but still facing the same problem. I did the same as your colleagues, running problematic projects on VS2022 preview. Thanks for your feedback.

ravipal commented 2 years ago

@martyt, your issue of the debugger is not doing anything other than building is related to a behavior change caused by docker compose v2 (https://github.com/docker/compose/issues/8760).

VS 2022 preview has the fix to handle the new compose v2 behavior and VS 2019 isn't (the next update will have the fix). To workaround please disable the compose v2 using the command docker-compose disable-v2

martyt commented 2 years ago

@ravipal Thanks for that information. I was able to confirm that running docker-compose disable-v2, then completely rebuilding the solution and images results in successful debugging under VS2019.

ravipal commented 2 years ago

Thanks for confirming @martyt!

ravipal commented 2 years ago

Will keep it open until the fix for VS2019 is released.

kondelik commented 2 years ago

Will keep it open until the fix for VS2019 is released.

is there any rough time estimate?

ravipal commented 2 years ago

The next VS update is on Nov 9th. It will have the fix.

Vaccano commented 2 years ago

@ravipal - After the fix is released, how do I undo the docker-compose disable-v2 command?

shobhitkasliwal-onbe commented 2 years ago

docker-compose enable-v2 worked for me.

carlos-takeapps commented 2 years ago

Today's fix release notes does not mention this issue. Has the fix been released?

ravipal commented 2 years ago

The latest update to VS 2019 (16.11.6) has the fix.