Skip to content

Fails to work with project uses central package management #342

Closed

Description

@VeselovAndrey
  • 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.

Activity

  1. ravipal commented on Jun 20, 2022

    @ravipal
    Contributor

    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.

  2. ravipal commented on Jul 25, 2022

    @ravipal
    Contributor

    The fix will be in 17.4 Preview 1.

  3. Meligy commented on Jan 5, 2023

    @Meligy

    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.

  4. patverb commented on Jan 6, 2023

    @patverb
    Contributor

    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.

  5. jimm98y commented on May 15, 2023

    @jimm98y

    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.

  6. dbreshears commented on May 15, 2023

    @dbreshears
    Contributor

    Lukas Volf (@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.

  7. oising commented on Aug 9, 2024

    @oising

    Devin Breshears (@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!

  8. patverb commented on Aug 12, 2024

    @patverb
    Contributor

    Oisin Grehan (@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.

  9. oising commented on Aug 12, 2024

    @oising

    Oisin Grehan (@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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions