Skip to content

Commit f62d8f1

Browse files
authored
Merge pull request #5940 from dibarbet/fix_neutral
Fix path to server when running platform neutral vsix
2 parents 3bac925 + 9e583cf commit f62d8f1

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/lsptoolshost/roslynLanguageServer.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -644,12 +644,10 @@ export async function activateRoslynLanguageServer(
644644
}
645645

646646
function getServerPath(options: Options, platformInfo: PlatformInformation) {
647-
const clientRoot = __dirname;
648-
649647
let serverPath = options.commonOptions.serverPath;
650648
if (!serverPath) {
651649
// Option not set, use the path from the extension.
652-
serverPath = path.join(clientRoot, '..', '.roslyn', getServerFileName(platformInfo));
650+
serverPath = getInstalledServerPath(platformInfo);
653651
}
654652

655653
if (!fs.existsSync(serverPath)) {
@@ -659,21 +657,27 @@ function getServerPath(options: Options, platformInfo: PlatformInformation) {
659657
return serverPath;
660658
}
661659

662-
function getServerFileName(platformInfo: PlatformInformation) {
663-
const serverFileName = 'Microsoft.CodeAnalysis.LanguageServer';
660+
function getInstalledServerPath(platformInfo: PlatformInformation): string {
661+
const clientRoot = __dirname;
662+
const serverFilePath = path.join(clientRoot, '..', '.roslyn', 'Microsoft.CodeAnalysis.LanguageServer');
663+
664664
let extension = '';
665665
if (platformInfo.isWindows()) {
666666
extension = '.exe';
667-
}
668-
669-
if (platformInfo.isMacOS()) {
667+
} else if (platformInfo.isMacOS()) {
670668
// MacOS executables must be signed with codesign. Currently all Roslyn server executables are built on windows
671669
// and therefore dotnet publish does not automatically sign them.
672670
// Tracking bug - https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1767519/
673671
extension = '.dll';
674672
}
675673

676-
return `${serverFileName}${extension}`;
674+
let pathWithExtension = `${serverFilePath}${extension}`;
675+
if (!fs.existsSync(pathWithExtension)) {
676+
// We might be running a platform neutral vsix which has no executable, instead we run the dll directly.
677+
pathWithExtension = `${serverFilePath}.dll`;
678+
}
679+
680+
return pathWithExtension;
677681
}
678682

679683
function registerRazorCommands(context: vscode.ExtensionContext, languageServer: RoslynLanguageServer) {

0 commit comments

Comments
 (0)