You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Central Package Management break Visual Studio docker integration #11972
tested with: nuget 6.2.1.7, dotnet 6.0.302, Visual Studio 17.2.6 as well as with nuget 6.3.0.114, dotnet 6.0.400-preview.22330.6 and Visual Studio 17.3 Preview 3
Worked before?
It works when Central Package Management is disabled.
The bug happens when you can create, for instance, an ASP.NET Core Web API project and enable Docker integration. This allows you to have a profile that launches the application on a Docker container. The expected behavior is:
Create an ASP.NET Core Web API project with Docker enabled.
Run the Web API app using the Docker profile from the launchSettings.json.
Visual Studio will build and run the Docker container and attach the debugger to the app running on the Docker container.
Impact
Other
Repro Steps & Context
Create an ASP.NET Core Web API project with Docker integration enabled and enable Central Package Management. Then when you try to run the application on a Docker container you get a prompt from Visual Studio which doesn't let the process carry on as expected. The bug is:
Create an ASP.NET Core Web API project with Docker enabled.
Run the Web API app using the Docker profile from the launchSettings.json.
Visual Studio displays a prompt to install a NuGet which is already installed.
Even if you say you want to install the package the debug process is aborted without further information on the output. You just get another prompt saying it failed.
I've created a repo edumserrano/example-cpm-docker that reproduces this bug. It's a solution with only one Web API project. The README of the repo contains all the information on how to run the code.
Yes, I did look at the readme, my comment was about including the expected/actual information in this issue itself.
I'm not saying you'd do this, but sometimes repos go private and we lose the information about the bug itself and we can't act on it.
For that reason we prefer as much of the details as possible in the issue body itself.
Hey, I'm just curious if you guys already did some planning on this and perhaps have an idea on when you plan on tackling it? As in, perhaps considering it for version VS 17.4? Besides curiosity I'm asking cause I want to use CPM but I ended up disabling it for my team's project due to this bug.
@edumserrano sorry I'm late to reply here, I was out of vacation. Thanks for the excellent amount of details on this issue. I'm still learning docker so correct me if I'm wrong but won't we need to copy more than just the .csproj? Like Directory.Packages.props for example and any other build logic that takes part in restore/build?
I did clone your example repo but of course it works for me. I am able to load the solution and debug without prompts. I also tried creating a new ASP .NET Core Web App with Docker support enabled and it seems to work.
You are correct in saying that the Dockerfile should contain everything it needs to do the restore which normally would include files like the Directory.Packages.props in this scenario.
However, I'm not building the Dockerfile from the command line, if I were then yes I would have to include that COPY instruction. I'm running from Visual Studio which only builds the base stage of the Dockerfile the rest of the file is for when the users actually want to build the full image for whatever purpose (ie: publishing to a registry, testing something, running locally outside of VS, etc).
In Fast mode, Visual Studio calls docker build with an argument that tells Docker to build only the base stage (you can change that by setting the MSBuild property, DockerfileFastModeStage, described later). Visual Studio handles the rest of the process without regard to the contents of the Dockerfile.
You can check the above in Visual Studio by going to the Output window and selecting view output from Container Tools. In there, once you try to debug the example repo from Visual Studio you will see something like:
note that the docker build commmand issued by Visual Studio has the --target base flag meaning only that stage of the Dockerfile gets build.
Starting up container(s)...
docker build -f "D:\Dev\edumserrano\example-cpm-docker\CentralPackageManagementWithDocker\Dockerfile" --force-rm -t centralpackagemanagementwithdocker:dev --target base --label "com.microsoft.created-by=visual-studio" --label "com.microsoft.visual-studio.project-name=CentralPackageManagementWithDocker" "D:\Dev\edumserrano\example-cpm-docker"
I probably should have updated the rest of the Dockerfile to avoid any confusion but since this was enough to reproduce the problem I missed that part.
Are you saying you do not get the error message if you try to debug the solution in the example repo using Visual Studio?
P.S. - I'm now running VS 17.3.3 and still getting the error.
@edumserrano its interesting that there are differences when building in Visual Studio. That seems unreliable if things work differently depending on the build environment. But again, I'm so new to Docker so I must still be missing something.
Are you saying you do not get the error message if you try to debug the solution in the example repo using Visual Studio?
Yes, that is correct, I am not able to reproduce the issue but I finally figured out why. I'm running a preview version of Visual Studio 2022 17.4. I am able to reproduce the issue in Visual Studio 2022 17.3.
@jeffkl I can confirm this is not happening on VS 17.4.0 Preview 1.
Feel free to close this bug report, I guess it might be nice if you could link it to the 17.4 release or to the PR/commit that fixed this issue just for history sake.
Activity
nkolev92 commentedon Jul 18, 2022
@edumserrano
Can you please provide information about the failure in this bug itself.
It's not immediately clear what the problem is.
edumserrano commentedon Jul 22, 2022
@nkolev92 did you see the The README of the repo? It explains what happens and expected behavior.
In short, if you enable CPM you can not run a VS solution with a docker launch option.
nkolev92 commentedon Jul 22, 2022
Hey @edumserrano
Yes, I did look at the readme, my comment was about including the expected/actual information in this issue itself.
I'm not saying you'd do this, but sometimes repos go private and we lose the information about the bug itself and we can't act on it.
For that reason we prefer as much of the details as possible in the issue body itself.
edumserrano commentedon Jul 24, 2022
@nkolev92 Apologies, I've updated the body of the issue. Let me know if you need anything else.
edumserrano commentedon Aug 30, 2022
Hey, I'm just curious if you guys already did some planning on this and perhaps have an idea on when you plan on tackling it? As in, perhaps considering it for version VS 17.4? Besides curiosity I'm asking cause I want to use CPM but I ended up disabling it for my team's project due to this bug.
jeffkl commentedon Aug 30, 2022
@edumserrano sorry I'm late to reply here, I was out of vacation. Thanks for the excellent amount of details on this issue. I'm still learning docker so correct me if I'm wrong but won't we need to copy more than just the
.csproj? LikeDirectory.Packages.propsfor example and any other build logic that takes part in restore/build?https://github.com/edumserrano/example-cpm-docker/blob/440138471c553d43755317db302bbeed34ef8705/CentralPackageManagementWithDocker/Dockerfile#L10
I did clone your example repo but of course it works for me. I am able to load the solution and debug without prompts. I also tried creating a new ASP .NET Core Web App with Docker support enabled and it seems to work.
edumserrano commentedon Aug 31, 2022
@jeffkl No worries, hope you had a great time =)
You are correct in saying that the
Dockerfileshould contain everything it needs to do the restore which normally would include files like theDirectory.Packages.propsin this scenario.However, I'm not building the
Dockerfilefrom the command line, if I were then yes I would have to include thatCOPYinstruction. I'm running from Visual Studio which only builds thebasestage of theDockerfilethe rest of the file is for when the users actually want to build the full image for whatever purpose (ie: publishing to a registry, testing something, running locally outside of VS, etc).For more information see How to customize Docker containers in Visual Studio:
You can check the above in Visual Studio by going to the
Outputwindow and selecting view output fromContainer Tools. In there, once you try to debug the example repo from Visual Studio you will see something like:I probably should have updated the rest of the
Dockerfileto avoid any confusion but since this was enough to reproduce the problem I missed that part.Are you saying you do not get the error message if you try to debug the solution in the example repo using Visual Studio?
P.S. - I'm now running
VS 17.3.3and still getting the error.jeffkl commentedon Aug 31, 2022
@edumserrano its interesting that there are differences when building in Visual Studio. That seems unreliable if things work differently depending on the build environment. But again, I'm so new to Docker so I must still be missing something.
Yes, that is correct, I am not able to reproduce the issue but I finally figured out why. I'm running a preview version of Visual Studio 2022 17.4. I am able to reproduce the issue in Visual Studio 2022 17.3.
Can you try installing 17.4 Preview and see if it happens still? https://visualstudio.microsoft.com/vs/preview/#download-preview
It looks like someone maybe fixed it...
edumserrano commentedon Aug 31, 2022
@jeffkl I can confirm this is not happening on
VS 17.4.0 Preview 1.Feel free to close this bug report, I guess it might be nice if you could link it to the 17.4 release or to the PR/commit that fixed this issue just for history sake.
jeffkl commentedon Aug 31, 2022
Okay great, I'm closing this as a duplicate of microsoft/DockerTools#342 then which I finally found