visual-studio - 通过 2019 构建工具安装时未检测到 MSVC2015
问题描述
我正在尝试为 VS2015 C++ 构建创建一个 windows docker 容器。我找到了一些文档如何在容器中安装构建工具,它适用于 VS2017。
但是,在尝试设置 2015 版本时,MSBuild.exe 抱怨它找不到 v140 并且尽管添加--add Microsoft.VisualStudio.Component.VC.v140
了vs_buildtools.exe
调用。我也无法在任何子文件夹中找到任何 v140 cl.exe
。
显然,像这样的基于 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"]
解决方案
通过 2019 构建工具安装时未检测到 MSVC2015
Build Tool for VS2019 目前可以安装v140 build tool for VS2015。
主要问题是您为 v140 构建工具使用了错误的组件 ID。
正如本文档所说,您应该使用
Microsoft.VisualStudio.Component.VC.140
.
解决方案
用这个:
--add Microsoft.VisualStudio.Component.VC.140
而不是--add Microsoft.VisualStudio.Component.VC.v140
.
推荐阅读
- pdf - Cannot preview pdf-files larger than 2mb in chrome using FileReader
- firebase - I can't pull data from firebase to custom adapter Android
- linux - linux在while循环中从文件中读取;找不到命令
- apache-spark - Spark: which directory spark-submit will take to find --files?
- mongodb - MongoDB full text search with pymongo wrong type error
- android - How can i apply theme what is in my mind in the android application
- pine-script - How to Continue BUY or SELL Signals for next trading day as per the trend
- mysql - 在 id 1 上进行全文搜索的奇怪 mysql 行为
- java - the allure testng dependency is giving error
- bitbucket - Can you mirror bitbucket repos with REST API?