@@ -49,15 +49,15 @@ export class DotnetRuntimeExtensionResolver implements IHostExecutableResolver {
49
49
} ,
50
50
versionSpecRequirement : 'greater_than_or_equal' ,
51
51
} ;
52
- const result = await vscode . commands . executeCommand < IDotnetAcquireResult | undefined > (
52
+ let acquireResult = await vscode . commands . executeCommand < IDotnetAcquireResult | undefined > (
53
53
'dotnet.findPath' ,
54
54
findPathRequest
55
55
) ;
56
- if ( result === undefined ) {
57
- throw new Error ( 'Failed to locate .NET runtime' ) ;
56
+ if ( acquireResult === undefined ) {
57
+ acquireResult = await this . acquireRuntime ( ) ;
58
58
}
59
59
60
- dotnetExecutablePath = result . dotnetPath ;
60
+ dotnetExecutablePath = acquireResult . dotnetPath ;
61
61
}
62
62
63
63
const hostInfo = {
@@ -92,6 +92,30 @@ export class DotnetRuntimeExtensionResolver implements IHostExecutableResolver {
92
92
return env ;
93
93
}
94
94
95
+ /**
96
+ * Acquires the .NET runtime if it is not already present.
97
+ * @returns The path to the .NET runtime
98
+ */
99
+ private async acquireRuntime ( ) : Promise < IDotnetAcquireResult > {
100
+ let status = await vscode . commands . executeCommand < IDotnetAcquireResult > ( 'dotnet.acquireStatus' , {
101
+ version : DotNetRuntimeVersion ,
102
+ requestingExtensionId : CSharpExtensionId ,
103
+ } ) ;
104
+ if ( status === undefined ) {
105
+ await vscode . commands . executeCommand ( 'dotnet.showAcquisitionLog' ) ;
106
+
107
+ status = await vscode . commands . executeCommand < IDotnetAcquireResult > ( 'dotnet.acquire' , {
108
+ version : DotNetRuntimeVersion ,
109
+ requestingExtensionId : CSharpExtensionId ,
110
+ } ) ;
111
+ if ( ! status ) {
112
+ throw new Error ( 'Could not resolve the dotnet path!' ) ;
113
+ }
114
+ }
115
+
116
+ return status ;
117
+ }
118
+
95
119
private async getArchitectureFromTargetPlatform ( ) : Promise < string | undefined > {
96
120
const vsixManifestFile = path . join ( this . extensionPath , '.vsixmanifest' ) ;
97
121
if ( ! existsSync ( vsixManifestFile ) ) {
0 commit comments