Skip to content

Commit

Permalink
Merge pull request #7300 from davidwengier/UseRzlsDllOnMac
Browse files Browse the repository at this point in the history
Use rzls.dll on macOS
  • Loading branch information
davidwengier authored Jul 2, 2024
2 parents 77f769a + d416d1d commit bc88ac1
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions src/razor/src/razorLanguageServerOptionsResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -56,3 +73,7 @@ function findLanguageServerExecutable(withinDir: string) {
function isWindows() {
return !!os.platform().match(/^win/);
}

function isMacOS() {
return os.platform() === 'darwin';
}

0 comments on commit bc88ac1

Please sign in to comment.