C++ Visual Studio 2015构建工具/CPP运行时v140 Dockerfile isn';t工作不正常

C++ Visual Studio 2015构建工具/CPP运行时v140 Dockerfile isn';t工作不正常,c++,visual-studio,docker,dockerfile,C++,Visual Studio,Docker,Dockerfile,我一直在尝试设置Dockerfile,以便在CPP Runtime v140上运行Visual Studio 2015中开发的项目,现在已经有一两周了(特别是一周,我基本上只是docker cpit in,然后msbuild解决方案文件),我一直遇到问题 以下是我当前的Dockerfile: # escape=` FROM mcr.microsoft.com/windows/servercore:ltsc2019 # Restore the default Windows shell for

我一直在尝试设置Dockerfile,以便在CPP Runtime v140上运行Visual Studio 2015中开发的项目,现在已经有一两周了(特别是一周,我基本上只是
docker cp
it in,然后
msbuild
解决方案文件),我一直遇到问题

以下是我当前的Dockerfile:

# escape=`

FROM mcr.microsoft.com/windows/servercore:ltsc2019

# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]

# Install Visual Studio 2015 Build Tools
ADD https://download.microsoft.com/download/E/E/D/EEDF18A8-4AED-4CE0-BEBE-70A83094FC5A/BuildTools_Full.exe C:\TEMP\vs_buildtools.exe
RUN C:\TEMP\vs_buildtools.exe `
    --quiet --norestart --nocache --wait `
    --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended`
    --add Microsoft.Component.MSBuild

# Install C++ Runtime v140
ADD https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x64.exe C:\TEMP\cpp_runtime.exe
RUN C:\TEMP\cpp_runtime.exe /quiet /install

# Define the entry point for the docker container.
ENTRYPOINT ["cmd.exe"]
# escape=`

FROM mcr.microsoft.com/windows/servercore:ltsc2019

# Interpret as Powershell
# SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue'; $verbosePreference='Continue';"]

# Install chocolatey
ADD https://chocolatey.org/install.ps1 C:\install.ps1
RUN @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex C:\install.ps1" 

# Install Visual C++ Build Tools, as per: https://chocolatey.org/packages/visualcpp-build-tools
RUN choco install visualcpp-build-tools -version 14.0.25420.1 -y

# Add msbuild to PATH
RUN setx /M PATH "%PATH%;C:\Program Files (x86)\MSBuild\14.0\bin"

# Test msbuild can be accessed without path
RUN msbuild -version

CMD [ "cmd.exe" ]
在运行vs_buildtools.exe的第4/7步中,此选项的挂起时间过长(20分钟以上,如果不是永远的话)。如果我只是简单地执行ADD命令,然后在容器本身中运行它们,那么它们总是立即完成,实际上不会更改文件系统

我以前已经能够正确安装Visual Studio 2015 build tools,但它给我一个错误,即找不到
Microsoft.Cpp.Default.props
(类似于StackOverflow问题)。它是在寻找这些v160的地方,而不是我想要的v140


有没有人能发现我的Dockerfile有什么问题,或者提出一个更好的方法来实现这一点?我试过很多不同的方法。我对Docker还很陌生,所以我可能只是有一些基本的误解。谢谢。

我放弃了手动下载Build Tools+CPP运行时的方法,而是使用Chocolate进行设置。我以前试过,但我不知道,Windows容器中的internet当时坏了,所以我修复了它(需要一点,虽然两者都不是必需的),然后Chocolate对我的用例非常有效,允许我编译项目

以下是dockerfile:

# escape=`

FROM mcr.microsoft.com/windows/servercore:ltsc2019

# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]

# Install Visual Studio 2015 Build Tools
ADD https://download.microsoft.com/download/E/E/D/EEDF18A8-4AED-4CE0-BEBE-70A83094FC5A/BuildTools_Full.exe C:\TEMP\vs_buildtools.exe
RUN C:\TEMP\vs_buildtools.exe `
    --quiet --norestart --nocache --wait `
    --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended`
    --add Microsoft.Component.MSBuild

# Install C++ Runtime v140
ADD https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x64.exe C:\TEMP\cpp_runtime.exe
RUN C:\TEMP\cpp_runtime.exe /quiet /install

# Define the entry point for the docker container.
ENTRYPOINT ["cmd.exe"]
# escape=`

FROM mcr.microsoft.com/windows/servercore:ltsc2019

# Interpret as Powershell
# SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue'; $verbosePreference='Continue';"]

# Install chocolatey
ADD https://chocolatey.org/install.ps1 C:\install.ps1
RUN @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex C:\install.ps1" 

# Install Visual C++ Build Tools, as per: https://chocolatey.org/packages/visualcpp-build-tools
RUN choco install visualcpp-build-tools -version 14.0.25420.1 -y

# Add msbuild to PATH
RUN setx /M PATH "%PATH%;C:\Program Files (x86)\MSBuild\14.0\bin"

# Test msbuild can be accessed without path
RUN msbuild -version

CMD [ "cmd.exe" ]