Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rzls.dll on macOS #7300

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
}
Loading