microsoft / DockerTools

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

Visual Studio reports "Docker is not installed" after docker-ce installation on Windows Server 2019 #392

Open iancward opened 1 year ago

iancward commented 1 year ago

I originally opened this in https://github.com/microsoft/Windows-Containers/issues/393, but maybe this is a better repository to pose the issue.

Hi there; I support some legacy .Net Framework applications and we had met with some degree of success putting them into containers and migrating them to the cloud. For our build environment, we have been leveraging Windows Server 2019 with Visual Studio 2019 Build Tools and Docker installed through the OneGet MicrosoftDockerProvider which is what the Microsoft documentation had a while back.

The OneGet provider has been deprecated since May, so we tried installing through the script provided in this repository for docker-ce; however, Visual Studio build tools complains that it can't locate Docker, even though it is, in fact, installed.

PS C:\Users\Administrator\git\myproject\Web> docker version
Client:
 Version:           24.0.2
 API version:       1.43
 Go version:        go1.20.4
 Git commit:        cb74dfc
 Built:             Thu May 25 21:53:15 2023
 OS/Arch:           windows/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          24.0.2
  API version:      1.43 (minimum version 1.24)
  Go version:       go1.20.4
  Git commit:       659604f9
  Built:            Thu May 25 21:52:13 2023
  OS/Arch:          windows/amd64
  Experimental:     false

PS C:\Users\Administrator\git\myproject\Web> msbuild.exe .\web.csproj /t:containerbuild /p:Configuration=Release
Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 7/3/2023 8:26:49 PM.
Project "C:\Users\Administrator\git\myproject\Web\web.csproj" on node 1 (containerbuild target(s)).
ContainerVerifyDockerInstallation:
  'docker' is not recognized as an internal or external command,
  operable program or batch file.
C:\Users\Administrator\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.11.1\build\Container.tar
gets(97,5): error : Docker is not installed or is not in the current PATH. [C:\Users\Administrator\git\myproject\Web\
web.csproj]
Done Building Project "C:\Users\Administrator\git\myproject\Web\web.csproj" (containerbuild target(s)) -- FAILED.

Build FAILED.

"C:\Users\Administrator\git\myproject\Web\web.csproj" (containerbuild target) (1) ->
(ContainerVerifyDockerInstallation target) ->
  C:\Users\Administrator\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.11.1\build\Container.t
argets(97,5): error : Docker is not installed or is not in the current PATH. [C:\Users\Administrator\git\myproject\We
b\web.csproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.47

Is there something missing from the install script that Visual Studio is looking for? Or is there any way to use Visual Studio to build with containerd instead of Docker?

It looks like the container target is running docker --version which runs fine in the same PowerShell prompt.

PS C:\Users\Administrator\git\myproject\Web> docker --version
Docker version 24.0.2, build cb74dfc

where.exe also reports that docker is in C:\Windows\System32:

PS C:\Users\Administrator\git\myproject\Web> where.exe docker
C:\Windows\System32\docker.exe
iancward commented 12 months ago

It looks like Visual Studio, being a 32 bit application, is redirected to C:\Windows\SysWow64 instead. The old MicrosoftDockerProvider updated the Path to add the docker installation directory, whereas the new installation script merely copies docker.exe and docker.exe to C:\Windows\System32.

I imagine the new script should probably add the docker installation directory to the PATH the same way that the old provider did.