Skip to content

Commit 4d819b6

Browse files
authored
Merge pull request #7302 from dotnet/dev/phil-allen-msft/cherrypick-prerelease-useRzlsDllOnMac
Cherrypick "use rzls dll on mac" to prerelease
2 parents e84be9d + ba14d98 commit 4d819b6

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

src/razor/src/razorLanguageServerOptionsResolver.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,30 @@ export function resolveRazorLanguageServerOptions(
3737
}
3838

3939
function findLanguageServerExecutable(withinDir: string) {
40-
// Prefer using executable over fallback to dll.
41-
const fileName = isWindows() ? 'rzls.exe' : 'rzls';
42-
let fullPath = path.join(withinDir, fileName);
43-
if (!fs.existsSync(fullPath)) {
44-
fullPath = path.join(withinDir, 'rzls.dll');
40+
// On Windows we use the executable, which is "rzls.exe".
41+
// On macOS we use the dll, which is "rzls.dll".
42+
// On everything else we use the executable, which is "rzls".
43+
44+
const fileName = 'rzls';
45+
let extension = '';
46+
47+
if (isWindows()) {
48+
extension = '.exe';
49+
}
50+
51+
if (isMacOS()) {
52+
// Use the DLL on MacOS to work around signing issue tracked by https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1767519/
53+
extension = '.dll';
4554
}
4655

56+
let pathWithExtension = `${fileName}${extension}`;
57+
if (!fs.existsSync(pathWithExtension)) {
58+
// We might be running a platform neutral vsix which has no executable, instead we run the dll directly.
59+
pathWithExtension = `${fileName}.dll`;
60+
}
61+
62+
const fullPath = path.join(withinDir, pathWithExtension);
63+
4764
if (!fs.existsSync(fullPath)) {
4865
throw new Error(
4966
vscode.l10n.t("Could not find Razor Language Server executable '{0}' within directory", fullPath)
@@ -56,3 +73,7 @@ function findLanguageServerExecutable(withinDir: string) {
5673
function isWindows() {
5774
return !!os.platform().match(/^win/);
5875
}
76+
77+
function isMacOS() {
78+
return os.platform() === 'darwin';
79+
}

0 commit comments

Comments
 (0)