Skip to content

Commit 8081622

Browse files
committed
fix acquire dependencies
1 parent 4f21c8e commit 8081622

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

src/lsptoolshost/dotnetRuntimeExtensionResolver.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export const DotNetRuntimeVersion = '8.0.10';
2222
export class DotnetRuntimeExtensionResolver implements IHostExecutableResolver {
2323
constructor(
2424
private platformInfo: PlatformInformation,
25+
/**
26+
* This is a function instead of a string because the server path can change while the extension is active (when the option changes).
27+
*/
28+
private getServerPath: (platform: PlatformInformation) => string,
2529
private channel: vscode.OutputChannel,
2630
private extensionPath: string
2731
) {}
@@ -57,7 +61,7 @@ export class DotnetRuntimeExtensionResolver implements IHostExecutableResolver {
5761
this.channel.appendLine(
5862
`Did not find .NET ${DotNetRuntimeVersion} on path, falling back to acquire runtime via ms-dotnettools.vscode-dotnet-runtime`
5963
);
60-
acquireResult = await this.acquireRuntime();
64+
acquireResult = await this.acquireDotNetProcessDependencies();
6165
}
6266

6367
dotnetExecutablePath = acquireResult.dotnetPath;
@@ -119,6 +123,23 @@ export class DotnetRuntimeExtensionResolver implements IHostExecutableResolver {
119123
return status;
120124
}
121125

126+
/**
127+
* Acquires the .NET runtime and any other dependencies required to spawn a particular .NET executable.
128+
* @param path The path to the entrypoint assembly. Typically a .dll.
129+
*/
130+
private async acquireDotNetProcessDependencies(): Promise<IDotnetAcquireResult> {
131+
const acquireResult = await this.acquireRuntime();
132+
133+
const args = [this.getServerPath(this.platformInfo)];
134+
// This will install any missing Linux dependencies.
135+
await vscode.commands.executeCommand('dotnet.ensureDotnetDependencies', {
136+
command: acquireResult.dotnetPath,
137+
arguments: args,
138+
});
139+
140+
return acquireResult;
141+
}
142+
122143
private async getArchitectureFromTargetPlatform(): Promise<string | undefined> {
123144
const vsixManifestFile = path.join(this.extensionPath, '.vsixmanifest');
124145
if (!existsSync(vsixManifestFile)) {

src/lsptoolshost/roslynLanguageServer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,7 @@ export async function activateRoslynLanguageServer(
10741074

10751075
const hostExecutableResolver = new DotnetRuntimeExtensionResolver(
10761076
platformInfo,
1077+
getServerPath,
10771078
outputChannel,
10781079
context.extensionPath
10791080
);

src/razor/src/extension.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ import TelemetryReporter from '@vscode/extension-telemetry';
4747
import { CSharpDevKitExports } from '../../csharpDevKitExports';
4848
import { DotnetRuntimeExtensionResolver } from '../../lsptoolshost/dotnetRuntimeExtensionResolver';
4949
import { PlatformInformation } from '../../shared/platform';
50+
import { RazorLanguageServerOptions } from './razorLanguageServerOptions';
51+
import { resolveRazorLanguageServerOptions } from './razorLanguageServerOptionsResolver';
5052
import { RazorFormatNewFileHandler } from './formatNewFile/razorFormatNewFileHandler';
5153
import { InlayHintHandler } from './inlayHint/inlayHintHandler';
5254
import { InlayHintResolveHandler } from './inlayHint/inlayHintResolveHandler';
@@ -73,8 +75,16 @@ export async function activate(
7375
const logger = new RazorLogger(eventEmitterFactory, languageServerLogLevel);
7476

7577
try {
78+
const razorOptions: RazorLanguageServerOptions = resolveRazorLanguageServerOptions(
79+
vscodeType,
80+
languageServerDir,
81+
languageServerLogLevel,
82+
logger
83+
);
84+
7685
const hostExecutableResolver = new DotnetRuntimeExtensionResolver(
7786
platformInfo,
87+
() => razorOptions.serverPath,
7888
logger.outputChannel,
7989
context.extensionPath
8090
);

0 commit comments

Comments
 (0)