@@ -22,6 +22,10 @@ export const DotNetRuntimeVersion = '8.0.10';
2222export 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 ) ) {
0 commit comments