Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to work with project uses central package management #342

Closed
VeselovAndrey opened this issue Jun 11, 2022 · 9 comments
Closed

Fails to work with project uses central package management #342

VeselovAndrey opened this issue Jun 11, 2022 · 9 comments

Comments

@VeselovAndrey
Copy link

  • Create default ASP.NET Core Web API project

    • .NET 6
    • Auth: None
    • HTTPS enabled
    • Docker enabled
    • Docker OS: Linux
  • Run (debug) app in Docker - Succeed

  • Switch to use central package management (re-start Visual Studio)

  • Run (debug) app in Docker - Failed with message

The NuGet package 'Microsoft.VisualStudio.Azure.Containers.Tools.Targets' is required by Visual Studio Tools for Containers. Should it be installed now?

Clicking "YES" does nothing and debug session fails.

@ravipal
Copy link
Contributor

ravipal commented Jun 20, 2022

This issue is caused by a bug in underlying Common Project System (CPS) API used in Docker Tools. Opened an internal bug against CPS. Will update once the CPS bug is fixed.

@ravipal
Copy link
Contributor

ravipal commented Jul 25, 2022

The fix will be in 17.4 Preview 1.

@Meligy
Copy link

Meligy commented Jan 5, 2023

Is this something that is implemented in VS for Mac? and is it supposed to work there or be broken?

I'm asking because I'm looking for guidance authoring Dockerfiles for projects with central package management.

Thanks.

@dbreshears dbreshears assigned patverb and unassigned ravipal Jan 5, 2023
@patverb
Copy link
Contributor

patverb commented Jan 6, 2023

From some quick testing it appears to work with a couple of caveats. I had an issue where I had to unload/reload the project the first time I added a PackageReference to a project that references a package from Directory.Pacakges.props for VS for Mac to be able to build a project

Another issue is that when building a docker project in Release mode, the dockerfile that we scaffolded does not copy the Directory.Packages.props file. If you manually add the line COPY Directory.Packages.props . right before the Run dotnet restore <project>.csproj line it should work.

@jimm98y
Copy link

jimm98y commented May 15, 2023

I am getting the following error with the central package management:
/root/.nuget/packages/microsoft.visualstudio.azure.containers.tools.targets/1.18.1/build/Container.targets(97,5): error : Docker is not installed or is not in the current PATH.

Our host app references the microsoft.visualstudio.azure.containers.tools.targets nuget in order to get the docker GUI in Visual Studio (the Build Docker Image menu command). We are using the "container fast mode" (https://aka.ms/containerfastmode) and our dockerfile includes:

... RUN dotnet build "MyApp.csproj" -c Release -o /app/build ...

Apparently including microsoft.visualstudio.azure.containers.tools.targets includes also microsoft.visualstudio.azure.containers.tools.targets/1.18.1/build/Container.targets which contains the ContainerVerifyDockerInstallation target. This target attempts to execute "docker --version" inside the docker container where the build is running, which of course fails since there is no "docker inside docker" and the entire build fails as a result.

One solution would be to not reference the nuget, but then it'll be a lot less convenient to work with. Why does "dotnet build" run this target? Is it intended?

Currently, I had to include this indo my dockerfile as a workaround:
RUN rm -r "/root/.nuget/packages/microsoft.visualstudio.azure.containers.tools.targets/1.18.1/build/"

This deletes all the targets/props files from this nuget and lets the build succeed.

@dbreshears
Copy link
Member

@jimm98y , Since the original issue of not working with central package managment has now been resolved in 17.6, I'm going to close this issue. Looking at our targets what you are describing shouldn't happen by default. Can you please open a new issue with an sample solution and we can look into.

@oising
Copy link

oising commented Aug 9, 2024

@dbreshears -- Hi Devin -- this is demonstrably still not fixed at this point in time. We're using VS 17.10 and the VS tools 1.21.0 and it fails to generate the COPY statements to bring across Directory.Build.props (containing the use cpm directive) nor the Directory.Packages.props file.

Can you give us an update please? Thanks!

@patverb
Copy link
Contributor

patverb commented Aug 12, 2024

@oising I was just checking, and it looks like we have do have a bug where if the Directory.Build.props file is in the same directory as the build context and project, we won't add the COPY statement. I'll get a fix out for that in 17.12.

Is that the same layout you have in your project that doesn't work or could you tell me the layout of your project with the locations of the solution, project, docker build context, and Directory.Build.props file please and I'll try to repo it.

@oising
Copy link

oising commented Aug 12, 2024

@oising I was just checking, and it looks like we have do have a bug where if the Directory.Build.props file is in the same directory as the build context and project, we won't add the COPY statement. I'll get a fix out for that in 17.12.

Is that the same layout you have in your project that doesn't work or could you tell me the layout of your project with the locations of the solution, project, docker build context, and Directory.Build.props file please and I'll try to repo it.

I've logged an independent issue at #439 to track my problem. Can we continue there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants