1

I previously had Visual Studio 2015 (14.0) Build tools installed, and I could build a simple C++ program, without any IDE, with:

call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
cl helloworld1.cpp

Now that I installed Visual Studio 2019 Build Tools, calling vcvarsall.bat gives this message:

Windows cannot find 'powershell.exe'

but after closing the dialog, it still continues (!). But then it fails with:

cl : Command line error D8027 : cannot execute 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64\c1xx.dll'

I don't see why powershell would be mandatory to just set a few environments variables and set up everything to use cl.exe.

Question: what's the proper way to call cl.exe with VS Build Tools 2019?

Shouldn't we call vcvarsall.bat first, like with previous versions?

(important: I'm looking for a 100% terminal mode, no IDE)

enter image description here

Basj
  • 41,386
  • 99
  • 383
  • 673

1 Answers1

1

The official way would be to to add %SystemRoot%\System32\WindowsPowerShell\v1.0 to your PATH either permanently or just before calling vcvarsall.bat.

An alternative is to do a set VSCMD_SKIP_SENDTELEMETRY=1 before calling vcvarsall.bat. This works because vcvarsall internally calls vsdevcmd, which in turn uses powershell to configure "send telemetry if user's VS is opted-in". However, the telemetry step is bypassed when VSCMD_SKIP_SENDTELEMETRY is defined (though this appears to be undocumented, and thus subject to change in future versions), then powershell is no longer used or required.

dxiv
  • 16,984
  • 2
  • 27
  • 49
  • Thanks a lot @dxiv, the problem was indeed that I did some "cleaning" in the PATH, and probably removed the PowerShell PATH accidentally... – Basj Jun 24 '20 at 18:41
  • For the second part of the question, why could be the reason for `cl : Command line error D8027 : cannot execute 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64\c1xx.dll'` ? This file is present in the filesystem, I wonder why it cannot be executed... Do you have any idea @dxiv? – Basj Jun 24 '20 at 18:43
  • @Basj That must have something to do with your build tools setup or configuration. I am using a full VS install and I am not seeing the error, or any errors for that matter. Is the path you quoted the *first* one in your `PATH` environment after `vcvarsall`? – dxiv Jun 24 '20 at 19:00