Search code examples
c++jenkins-pipelinebuild-tools

Installed C++ with VS Build Tools, but can't find CL.exe


We have a Jenkins build agent based on docker pull mcr.microsoft.com/dotnet/framework/sdk:4.8

Part of the Docker file for the container pulls in additional workloads as follows

vs_buildtools.exe --quiet --wait --norestart --nocache modify \
--installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools" \
--add Microsoft.VisualStudio.Workload.VCTools \
--add Microsoft.VisualStudio.Workload.DataBuildTools \
--add Microsoft.VisualStudio.Workload.UniversalBuildTools

But builds of C++ projects fail saying they can't find CL.EXE.

I've Googled this problem and everybody who's had errors saying they couldn't find CL.EXE got the answer to just run vsvars.bat and that fixed it for them. But the CL.exe is physically not there. We go to C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.31.31103 and there is no bin folder.
We searched the whole container for cl.exe and do see it in some c:\windows\WinSxS\ folder, and we tried adding that to the PATH environment, but it got an error about it not being compatible with the version of Windows.

Is there some reason it won't install the actual compiler?


Solution

  • You also need to pass either --includeRecommended or --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 as an argument.

    MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest) is listed among Components included by VCTools workload as Recommended and thus is not installed with Microsoft.VisualStudio.Workload.VCTools by default.

    Here's the description of the --add parameter from VS Installer command-line parameter reference:

    During an install or modify command, this repeatable parameter specifies one or more workload or component IDs to add. The required components of the artifact are installed, but not the recommended or optional components. You can control additional components globally using --includeRecommended and/or --includeOptional parameters.