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

Fix path to server when running platform neutral vsix #5940

Merged
merged 2 commits into from
Jul 20, 2023
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
22 changes: 13 additions & 9 deletions src/lsptoolshost/roslynLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,12 +644,10 @@ export async function activateRoslynLanguageServer(
}

function getServerPath(options: Options, platformInfo: PlatformInformation) {
const clientRoot = __dirname;

let serverPath = options.commonOptions.serverPath;
if (!serverPath) {
// Option not set, use the path from the extension.
serverPath = path.join(clientRoot, '..', '.roslyn', getServerFileName(platformInfo));
serverPath = getInstalledServerPath(platformInfo);
}

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

function getServerFileName(platformInfo: PlatformInformation) {
const serverFileName = 'Microsoft.CodeAnalysis.LanguageServer';
function getInstalledServerPath(platformInfo: PlatformInformation): string {
const clientRoot = __dirname;
const serverFilePath = path.join(clientRoot, '..', '.roslyn', 'Microsoft.CodeAnalysis.LanguageServer');

let extension = '';
if (platformInfo.isWindows()) {
dibarbet marked this conversation as resolved.
Show resolved Hide resolved
extension = '.exe';
}

if (platformInfo.isMacOS()) {
} else if (platformInfo.isMacOS()) {
// MacOS executables must be signed with codesign. Currently all Roslyn server executables are built on windows
// and therefore dotnet publish does not automatically sign them.
// Tracking bug - https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1767519/
extension = '.dll';
}

return `${serverFileName}${extension}`;
let pathWithExtension = `${serverFilePath}${extension}`;
if (!fs.existsSync(pathWithExtension)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So on Linux we don't set extension, expect this to fail and then take the if block?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On linux, if the platform specific version is installed there will be a 'Microsoft.CodeAnalysis.LanguageServer' file (no extension). That will exist, so we won't take this block.

If we're using the neutral version, there will be no 'Microsoft.CodeAnalysis.LanguageServer' file, we'll hit this and find the dll instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, I forgot there'd be no extension. It might make sense to put a comment there that the lack of setting that is intentional, but...

// We might be running a platform neutral vsix which has no executable, instead we run the dll directly.
pathWithExtension = `${serverFilePath}.dll`;
}

return pathWithExtension;
}

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