diff --git a/src/razor/src/razorLanguageServerOptionsResolver.ts b/src/razor/src/razorLanguageServerOptionsResolver.ts index 3f9435a86..9804bbd9b 100644 --- a/src/razor/src/razorLanguageServerOptionsResolver.ts +++ b/src/razor/src/razorLanguageServerOptionsResolver.ts @@ -37,13 +37,30 @@ export function resolveRazorLanguageServerOptions( } function findLanguageServerExecutable(withinDir: string) { - // Prefer using executable over fallback to dll. - const fileName = isWindows() ? 'rzls.exe' : 'rzls'; - let fullPath = path.join(withinDir, fileName); - if (!fs.existsSync(fullPath)) { - fullPath = path.join(withinDir, 'rzls.dll'); + // On Windows we use the executable, which is "rzls.exe". + // On macOS we use the dll, which is "rzls.dll". + // On everything else we use the executable, which is "rzls". + + const fileName = 'rzls'; + let extension = ''; + + if (isWindows()) { + extension = '.exe'; + } + + if (isMacOS()) { + // Use the DLL on MacOS to work around signing issue tracked by https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1767519/ + extension = '.dll'; } + let pathWithExtension = `${fileName}${extension}`; + if (!fs.existsSync(pathWithExtension)) { + // We might be running a platform neutral vsix which has no executable, instead we run the dll directly. + pathWithExtension = `${fileName}.dll`; + } + + const fullPath = path.join(withinDir, pathWithExtension); + if (!fs.existsSync(fullPath)) { throw new Error( vscode.l10n.t("Could not find Razor Language Server executable '{0}' within directory", fullPath) @@ -56,3 +73,7 @@ function findLanguageServerExecutable(withinDir: string) { function isWindows() { return !!os.platform().match(/^win/); } + +function isMacOS() { + return os.platform() === 'darwin'; +}