From 4dfec3ba56fa77a76202c5bb8f33cf5c1a5f3736 Mon Sep 17 00:00:00 2001 From: StefanStojanovic Date: Fri, 10 Mar 2023 21:51:22 +0100 Subject: [PATCH] fix: find visual studio arm64 support This enables running find visual studio script on Windows on ARM64 --- lib/find-visualstudio.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/find-visualstudio.js b/lib/find-visualstudio.js index d3815112e6..28718f9dc8 100644 --- a/lib/find-visualstudio.js +++ b/lib/find-visualstudio.js @@ -126,7 +126,19 @@ VisualStudioFinder.prototype = { // Invoke the PowerShell script to get information about Visual Studio 2017 // or newer installations findVisualStudio2017OrNewer: function findVisualStudio2017OrNewer (cb) { - var ps = path.join(process.env.SystemRoot, 'System32', + // 32-bit PowerShell (available in SysWOW64) is needed on ARM64 because of + // the COM classes and interfaces used by Find-VisualStudio.cs, which are + // not registered for being used from ARM64 processes. + // + // This fix is required for the clean installation of Windows 11. Old + // versions (e.g. Windows 10 upgraded to 11) work without it. + // + // Since VS v17.4 and later is natively supported on ARM64 it seems to + // register the ARM64 COM components correctly, but VS 2019 and 2017 will + // still have problems being detected. Once support for VS 2017 and 2019 + // is dropped, this change can be reverted. + var systemDirectory = process.arch === 'arm64' ? 'SysWOW64' : 'System32' + var ps = path.join(process.env.SystemRoot, systemDirectory, 'WindowsPowerShell', 'v1.0', 'powershell.exe') var csFile = path.join(__dirname, 'Find-VisualStudio.cs') var psArgs = [