1

I am trying to create a windows docker container for a VS2015 C++ build. I found some documentation how to install build tools in a container and it works for VS2017.

However, when trying to setup the 2015 version, MSBuild.exe complains that it cannot find v140 and despite adding --add Microsoft.VisualStudio.Component.VC.v140 to the vs_buildtools.exe call. I also was not able to find any v140 cl.exe in any of the subfolders.

Obviously, GUI based solutions like this are not an option.

Here is my changed 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"]
  • try this: `--add Microsoft.VisualStudio.Component.VC.140` – Mr Qian Jun 03 '20 at 06:35
  • Did it work eventually for you? I have the exact same problem with server core in docker but it's not building, I am getting a bunch of errors. – eri0o May 13 '21 at 19:49

1 Answers1

1

MSVC2015 not detected when installed via 2019 build tools

Build Tool for VS2019 can install v140 build tool for VS2015 so far.

enter image description here

The main issue is that you use the wrong Component ID for v140 build tool.

As this document said, you should use

Microsoft.VisualStudio.Component.VC.140.

Solution

Use this:

--add Microsoft.VisualStudio.Component.VC.140 rather than --add Microsoft.VisualStudio.Component.VC.v140.

Mr Qian
  • 21,064
  • 1
  • 31
  • 41
  • Thanks for spotting this. I thought I had copied the Component ID for v140 directly from the page you linked. But I probably started with `Microsoft.VisualStudio.Component.VC.v141.x86.x64` from an earlier trial and just edited it to v140, not noticing that the naming scheme is slightly different. – Nobody moving away from SE Jun 03 '20 at 06:58
  • 1
    I just wanted to verify it worked before upvoting/accepting. Now MSBuild complains that it cannot find SDK 8.1 which is not even listed for the 2019 Build Tools... – Nobody moving away from SE Jun 03 '20 at 07:48
  • 1
    Actually, the latest `Build Tool for VS2019` does not contain `SDK 8.1`. If you also want to use SDK 8.1, I suggest you could install Build Tool for VS2017 which contains `SDK 8.1` and it also has `v140` build tool. See [this document](https://learn.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2017#visual-c-build-tools). – Mr Qian Jun 03 '20 at 07:55
  • 1
    Use [this download link](https://my.visualstudio.com/Downloads?q=visual%20studio%202017&wt.mc_id=o~msft~vscom~older-downloads). – Mr Qian Jun 03 '20 at 07:57
  • Fur future reference: To successfully get SDK 8.1 working with `Build Tools for VS2017` I needed to install the optional components `Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Win81` and `Microsoft.VisualStudio.Component.Windows81SDK` too. – Nobody moving away from SE Jun 10 '20 at 08:13