Skip to content

Commit ff8ecca

Browse files
committed
Fix path to server when running platform neutral vsix
1 parent 170570a commit ff8ecca

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/lsptoolshost/roslynLanguageServer.ts

Lines changed: 12 additions & 6 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,8 +657,10 @@ 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) {
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';
@@ -673,7 +673,13 @@ function getServerFileName(platformInfo: PlatformInformation) {
673673
extension = '.dll';
674674
}
675675

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

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

0 commit comments

Comments
 (0)