@@ -644,12 +644,10 @@ export async function activateRoslynLanguageServer(
644
644
}
645
645
646
646
function getServerPath ( options : Options , platformInfo : PlatformInformation ) {
647
- const clientRoot = __dirname ;
648
-
649
647
let serverPath = options . commonOptions . serverPath ;
650
648
if ( ! serverPath ) {
651
649
// Option not set, use the path from the extension.
652
- serverPath = path . join ( clientRoot , '..' , '.roslyn' , getServerFileName ( platformInfo ) ) ;
650
+ serverPath = getInstalledServerPath ( platformInfo ) ;
653
651
}
654
652
655
653
if ( ! fs . existsSync ( serverPath ) ) {
@@ -659,21 +657,27 @@ function getServerPath(options: Options, platformInfo: PlatformInformation) {
659
657
return serverPath ;
660
658
}
661
659
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
+
664
664
let extension = '' ;
665
665
if ( platformInfo . isWindows ( ) ) {
666
666
extension = '.exe' ;
667
- }
668
-
669
- if ( platformInfo . isMacOS ( ) ) {
667
+ } else if ( platformInfo . isMacOS ( ) ) {
670
668
// MacOS executables must be signed with codesign. Currently all Roslyn server executables are built on windows
671
669
// and therefore dotnet publish does not automatically sign them.
672
670
// Tracking bug - https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1767519/
673
671
extension = '.dll' ;
674
672
}
675
673
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 ;
677
681
}
678
682
679
683
function registerRazorCommands ( context : vscode . ExtensionContext , languageServer : RoslynLanguageServer ) {
0 commit comments