通过 2019 构建工具安装时未检测到 MSVC2015
MSVC2015 not detected when installed via 2019 build tools
我正在尝试为 VS2015 C++ 构建创建一个 windows docker 容器。我找到了一些 documentation 如何在容器中安装构建工具,它适用于 VS2017。
然而,在尝试设置 2015 版本时,MSBuild.exe 抱怨找不到 v140,尽管在 vs_buildtools.exe
调用中添加了 --add Microsoft.VisualStudio.Component.VC.v140
。我也无法在任何子文件夹中找到任何 v140 cl.exe
。
显然,this 等基于 GUI 的解决方案不是一个选项。
这是我修改后的 Dockerfile:
# escape=`
# Use the latest Windows Server Core image with .NET Framework 4.8.
FROM mcr.microsoft.com/windows/servercore:1903
# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]
ARG BUILD_TOOLS_VERSION=16
# Download the Build Tools bootstrapper.
ADD https://aka.ms/vs/${BUILD_TOOLS_VERSION}/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
--installPath C:\BuildTools `
--add Microsoft.VisualStudio.Workload.VCTools `
--add Microsoft.VisualStudio.Component.VC.CLI.Support `
--add Microsoft.VisualStudio.Component.VC.v140 `
--add Microsoft.VisualStudio.Component.Windows10SDK.18362 `
--add Microsoft.VisualStudio.Component.VC.CMake.Project `
|| IF "%ERRORLEVEL%"=="3010" EXIT 0
# put MSBuild.exe on PATH
RUN setx path "%path%;C:\BuildTools\MSBuild\Current\Bin"
# Define the entry point for the docker container.
# This entry point starts the developer command prompt and launches the PowerShell shell.
ENTRYPOINT ["C:\BuildTools\Common7\Tools\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
MSVC2015 not detected when installed via 2019 build tools
Build Tool for VS2019 目前可以安装v140 build tool for VS2015。
主要问题是您为 v140 构建工具使用了错误的组件 ID。
正如this document所说,你应该使用
Microsoft.VisualStudio.Component.VC.140
.
解决方案
使用这个:
--add Microsoft.VisualStudio.Component.VC.140
而不是 --add Microsoft.VisualStudio.Component.VC.v140
.
我正在尝试为 VS2015 C++ 构建创建一个 windows docker 容器。我找到了一些 documentation 如何在容器中安装构建工具,它适用于 VS2017。
然而,在尝试设置 2015 版本时,MSBuild.exe 抱怨找不到 v140,尽管在 vs_buildtools.exe
调用中添加了 --add Microsoft.VisualStudio.Component.VC.v140
。我也无法在任何子文件夹中找到任何 v140 cl.exe
。
显然,this 等基于 GUI 的解决方案不是一个选项。
这是我修改后的 Dockerfile:
# escape=`
# Use the latest Windows Server Core image with .NET Framework 4.8.
FROM mcr.microsoft.com/windows/servercore:1903
# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]
ARG BUILD_TOOLS_VERSION=16
# Download the Build Tools bootstrapper.
ADD https://aka.ms/vs/${BUILD_TOOLS_VERSION}/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
--installPath C:\BuildTools `
--add Microsoft.VisualStudio.Workload.VCTools `
--add Microsoft.VisualStudio.Component.VC.CLI.Support `
--add Microsoft.VisualStudio.Component.VC.v140 `
--add Microsoft.VisualStudio.Component.Windows10SDK.18362 `
--add Microsoft.VisualStudio.Component.VC.CMake.Project `
|| IF "%ERRORLEVEL%"=="3010" EXIT 0
# put MSBuild.exe on PATH
RUN setx path "%path%;C:\BuildTools\MSBuild\Current\Bin"
# Define the entry point for the docker container.
# This entry point starts the developer command prompt and launches the PowerShell shell.
ENTRYPOINT ["C:\BuildTools\Common7\Tools\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
MSVC2015 not detected when installed via 2019 build tools
Build Tool for VS2019 目前可以安装v140 build tool for VS2015。
主要问题是您为 v140 构建工具使用了错误的组件 ID。
正如this document所说,你应该使用
Microsoft.VisualStudio.Component.VC.140
.
解决方案
使用这个:
--add Microsoft.VisualStudio.Component.VC.140
而不是 --add Microsoft.VisualStudio.Component.VC.v140
.