C++ Docker中的Microsoft编译器
我想设置一个DOCKER容器来支持完全基于C++编写的代码库的构建,生成的应用程序只在Windows上运行。 为此,我需要设置一个复制当前构建环境的容器来支持构建 我需要创建一个Dockerfile(如下所示)来构建这样的容器:C++ Docker中的Microsoft编译器,c++,windows,visual-studio,docker,dockerfile,C++,Windows,Visual Studio,Docker,Dockerfile,我想设置一个DOCKER容器来支持完全基于C++编写的代码库的构建,生成的应用程序只在Windows上运行。 为此,我需要设置一个复制当前构建环境的容器来支持构建 我需要创建一个Dockerfile(如下所示)来构建这样的容器: 请考虑以下类型的伪代码DOCKFILE(忽略APT GET并考虑Windows中的任何其他工具来从命令行安装工具): 注意:我们的组织中有一个定制构建系统(不使用GNU Make)来执行构建。debug是提供给构建系统的目标,因为我想构建一个调试可执行文件 我的怀疑是:
请考虑以下类型的伪代码DOCKFILE(忽略APT GET并考虑Windows中的任何其他工具来从命令行安装工具):
注意:我们的组织中有一个定制构建系统(不使用GNU Make)来执行构建。debug是提供给构建系统的目标,因为我想构建一个调试可执行文件 我的怀疑是:请提供相同的输入(尽量考虑所有的疑惑)。
< P>。 我说的不是在Windows上的Hyper-V虚拟机上运行Linux(Alpine)主机:它不会运行任何Windows映像,只运行Linux映像我说的是Docker for Windows(提供您的支持)。直到最近,这只可能在一个上运行。我假设您已经可以运行Windows容器,例如docker run-it microsoft/windowsservercore < P> >我的<强> DOCKFrase<强>在Dox容器中使用VisualC++构建工具2015使用<强> CopoLaTye< /St>>:
# escape=`
FROM microsoft/windowsservercore
# Install chocolatey
RUN @powershell -NoProfile -ExecutionPolicy unrestricted -Command "(iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))) >$null 2>&1"
# 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" ]
使用Choco更简单,但下载本机web安装程序并在安静模式下运行,可以获得相同的结果,例如:
visualcppbuildtools_full.exe /Q /L <LogFile> /Full
VisualCPBuildTools\u full.exe/Q/L/full
<>代码> 只回答你的第一点:这里有一个文档,我用它作为一个DOCKER图像的起点来编译一个Windows C++应用程序:
我正在Windows Server 2016上运行Docker,并编译一个面向XP的遗留应用程序
我最终的Dockerfile
如下所示:
# Use the latest Windows Server Core image.
FROM microsoft/windowsservercore
# Download the Visual Studio 2017 installer outside of the PATH.
# This is required for Windows SDK 7.1A (XP targetting)
ADD https://aka.ms/vs/15/release/vs_professional.exe C:\\TEMP\\vs_professional.exe
# Add C:\Bin to PATH and install Build Tools with components we need
RUN setx /m PATH "%PATH%;C:\Bin" \
&& C:\TEMP\vs_professional.exe --quiet --wait --norestart --nocache \
--add Microsoft.VisualStudio.Component.Static.Analysis.Tools \
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 \
--add Microsoft.VisualStudio.Component.VC.CMake.Project \
--add Microsoft.VisualStudio.Component.VC.CoreBuildTools \
--add Microsoft.VisualStudio.Component.VC.ATLMFC \
--add Microsoft.VisualStudio.Component.VC.ATL \
--add Microsoft.VisualStudio.Component.Windows10SDK.16299.Desktop \
--add Microsoft.VisualStudio.Component.Windows10SDK.16299.UWP \
--add Microsoft.VisualStudio.Component.Windows10SDK.16299.UWP.Native \
--add Microsoft.VisualStudio.Component.Windows10SDK \
--add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Win81 \
--add Microsoft.VisualStudio.Component.VC.Redist.14.Latest \
--add Microsoft.Component.VC.Runtime.UCRTSDK \
--add Microsoft.VisualStudio.Component.WinXP \
|| IF "%ERRORLEVEL%"=="3010" EXIT 0
# Start developer command prompt with any other commands specified.
ENTRYPOINT "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsDevCmd.bat" &&
# Default to PowerShell if no other command specified.
CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
这太酷了!Visual C++ 2019有什么更新吗?
# Use the latest Windows Server Core image.
FROM microsoft/windowsservercore
# Download the Visual Studio 2017 installer outside of the PATH.
# This is required for Windows SDK 7.1A (XP targetting)
ADD https://aka.ms/vs/15/release/vs_professional.exe C:\\TEMP\\vs_professional.exe
# Add C:\Bin to PATH and install Build Tools with components we need
RUN setx /m PATH "%PATH%;C:\Bin" \
&& C:\TEMP\vs_professional.exe --quiet --wait --norestart --nocache \
--add Microsoft.VisualStudio.Component.Static.Analysis.Tools \
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 \
--add Microsoft.VisualStudio.Component.VC.CMake.Project \
--add Microsoft.VisualStudio.Component.VC.CoreBuildTools \
--add Microsoft.VisualStudio.Component.VC.ATLMFC \
--add Microsoft.VisualStudio.Component.VC.ATL \
--add Microsoft.VisualStudio.Component.Windows10SDK.16299.Desktop \
--add Microsoft.VisualStudio.Component.Windows10SDK.16299.UWP \
--add Microsoft.VisualStudio.Component.Windows10SDK.16299.UWP.Native \
--add Microsoft.VisualStudio.Component.Windows10SDK \
--add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Win81 \
--add Microsoft.VisualStudio.Component.VC.Redist.14.Latest \
--add Microsoft.Component.VC.Runtime.UCRTSDK \
--add Microsoft.VisualStudio.Component.WinXP \
|| IF "%ERRORLEVEL%"=="3010" EXIT 0
# Start developer command prompt with any other commands specified.
ENTRYPOINT "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsDevCmd.bat" &&
# Default to PowerShell if no other command specified.
CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]