eclipse-cdt / cdt

Eclipse CDT™ C/C++ Development Tools
http://eclipse.org/cdt
Eclipse Public License 2.0
309 stars 201 forks source link

Visual C++ Support may not reliably detect MSVC #929

Open azuo opened 2 weeks ago

azuo commented 2 weeks ago

Currently, org.eclipse.cdt.internal.msw.build.VSInstallationRegistry detects the VS installation path using the following command line:

vswhere -version [m,n] -property installationPath

However, this may not be perfect in some cases - for example, it will ignore a tools-only installation with MSBuild + VC but no IDE. (but instead unnecessarily detect a VS installation without VC?)

Referring to https://github.com/microsoft/vswhere/wiki/Find-VC, is it more reliable to switch to the following command line?

vswhere -version [m,n] -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath

Or, more generally:

vswhere -version [m,n] -products * -requires Microsoft.VisualStudio.Component.VC.Tools.* -property installationPath
MarkZ3 commented 2 weeks ago

This makes sense. I would say sticking to x86.x64 for now since the plugin doesn't support other targets (there is no mechanism to select something else). If you make a MR I will test it.