Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

551
Visualizações
Visual Studio Docker Support - Debugging with a Dockerfile outside of the startup project folder

I have a docker file for a .NET Core project that references some library projects in the same solution.

Given that Docker does not allow copying files from outside of the parent directory (Docker: adding a file from a parent directory), I have to keep my Dockerfile outside of the executable (start up) project directory.

So, how do I use Visual Studio debugging with a Dockerfile that is not located within the executable project?

It seems that Visual Studio only works with the Docker debug profile if it can find a Dockerfile in the directory for the startup project.

enter image description here

When the Dockerfile is not present in the startup directory, the build error points at lines in a file named Container.targets, located at:

C:\Users<user>\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.4.10\build

<Target Name="ContainerPrepareForLaunch" Condition="Exists('$(ContainerSemaphoreFilePath)')">
    <PrepareForLaunch DevelopmentMode="$(ContainerDevelopmentMode)"
                      DevEnvDir="$(DevEnvDir)"
                      Dockerfiles="@(_Dockerfile)" 
                      IntermediateOutputPath="$(ContainerIntermediateOutputPath)"
                      ProjectCapability="@(ProjectCapability)"
                      ProjectFilePath="$(MSBuildProjectFullPath)" 
                      NuGetPackageFolders="$(NuGetPackageFolders)"
                      NuGetPackageRoot="$(NuGetPackageRoot)"
                      TargetFrameworkWithVersion ="$(TargetFramework)"
                      TargetPath="$(TargetPath)"
                      ErrorLogFilePath="$(ContainerSemaphoreFilePath)"
                      DockerLabelBuiltImages="$(DockerLabelBuiltImages)"
                      DockerImageLabel="$(DockerImageLabel)" 
                      ProjectTypeGuids="$(ProjectTypeGuids)" />
  </Target>

However I need to be able to manage the path to the Dockerfile on a per-project basis.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You can specify DockerfileFile in your project file. The list of available recognized properties can be found here

over 4 years ago · Santiago Trujillo Relatório

0

For Dockerfile, you could only access the files in the parent folder. For Docker for VS debugging, it will access the dockerfile in the project root folder. You could not change this behavior.

For a workaround, you may consider adding docker-compose which could specicify the dockerfile location and run from VS directly.

  1. Right-click the project in Solution Explorer and select Add > Container Orchestrator Support.
  2. Choose Docker Compose
  3. Modify docker-compose.yml to change the dockerfilepath in dockerfile variable

    version: '3.4'
    
    services:
    hellodockertools:
        image: ${DOCKER_REGISTRY}hellodockertools
        build:
        context: .
        dockerfile: HelloDockerTools/Dockerfile
    
  4. Set docker-compose as startup project

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda