Skip to content

Commit

Permalink
fix acquire dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dibarbet committed Nov 5, 2024
1 parent 4f21c8e commit 8081622
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/lsptoolshost/dotnetRuntimeExtensionResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export const DotNetRuntimeVersion = '8.0.10';
export class DotnetRuntimeExtensionResolver implements IHostExecutableResolver {
constructor(
private platformInfo: PlatformInformation,
/**
* This is a function instead of a string because the server path can change while the extension is active (when the option changes).
*/
private getServerPath: (platform: PlatformInformation) => string,
private channel: vscode.OutputChannel,
private extensionPath: string
) {}
Expand Down Expand Up @@ -57,7 +61,7 @@ export class DotnetRuntimeExtensionResolver implements IHostExecutableResolver {
this.channel.appendLine(
`Did not find .NET ${DotNetRuntimeVersion} on path, falling back to acquire runtime via ms-dotnettools.vscode-dotnet-runtime`
);
acquireResult = await this.acquireRuntime();
acquireResult = await this.acquireDotNetProcessDependencies();
}

dotnetExecutablePath = acquireResult.dotnetPath;
Expand Down Expand Up @@ -119,6 +123,23 @@ export class DotnetRuntimeExtensionResolver implements IHostExecutableResolver {
return status;
}

/**
* Acquires the .NET runtime and any other dependencies required to spawn a particular .NET executable.
* @param path The path to the entrypoint assembly. Typically a .dll.
*/
private async acquireDotNetProcessDependencies(): Promise<IDotnetAcquireResult> {
const acquireResult = await this.acquireRuntime();

const args = [this.getServerPath(this.platformInfo)];
// This will install any missing Linux dependencies.
await vscode.commands.executeCommand('dotnet.ensureDotnetDependencies', {
command: acquireResult.dotnetPath,
arguments: args,
});

return acquireResult;
}

private async getArchitectureFromTargetPlatform(): Promise<string | undefined> {
const vsixManifestFile = path.join(this.extensionPath, '.vsixmanifest');
if (!existsSync(vsixManifestFile)) {
Expand Down
1 change: 1 addition & 0 deletions src/lsptoolshost/roslynLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,7 @@ export async function activateRoslynLanguageServer(

const hostExecutableResolver = new DotnetRuntimeExtensionResolver(
platformInfo,
getServerPath,
outputChannel,
context.extensionPath
);
Expand Down
10 changes: 10 additions & 0 deletions src/razor/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ import TelemetryReporter from '@vscode/extension-telemetry';
import { CSharpDevKitExports } from '../../csharpDevKitExports';
import { DotnetRuntimeExtensionResolver } from '../../lsptoolshost/dotnetRuntimeExtensionResolver';
import { PlatformInformation } from '../../shared/platform';
import { RazorLanguageServerOptions } from './razorLanguageServerOptions';
import { resolveRazorLanguageServerOptions } from './razorLanguageServerOptionsResolver';
import { RazorFormatNewFileHandler } from './formatNewFile/razorFormatNewFileHandler';
import { InlayHintHandler } from './inlayHint/inlayHintHandler';
import { InlayHintResolveHandler } from './inlayHint/inlayHintResolveHandler';
Expand All @@ -73,8 +75,16 @@ export async function activate(
const logger = new RazorLogger(eventEmitterFactory, languageServerLogLevel);

try {
const razorOptions: RazorLanguageServerOptions = resolveRazorLanguageServerOptions(
vscodeType,
languageServerDir,
languageServerLogLevel,
logger
);

const hostExecutableResolver = new DotnetRuntimeExtensionResolver(
platformInfo,
() => razorOptions.serverPath,
logger.outputChannel,
context.extensionPath
);
Expand Down

0 comments on commit 8081622

Please sign in to comment.