@@ -12,8 +12,14 @@ import { languageServerOptions } from '../../shared/options';
12
12
import { existsSync } from 'fs' ;
13
13
import { CSharpExtensionId } from '../../constants/csharpExtensionId' ;
14
14
import { readFile } from 'fs/promises' ;
15
- import { IDotnetAcquireResult , IDotnetFindPathContext } from './dotnetRuntimeExtensionApi' ;
15
+ import {
16
+ DotnetInstallMode ,
17
+ IDotnetAcquireContext ,
18
+ IDotnetAcquireResult ,
19
+ IDotnetFindPathContext ,
20
+ } from './dotnetRuntimeExtensionApi' ;
16
21
import { DotNetRuntimeExtensionId } from '../../checkDotNetRuntimeExtensionVersion' ;
22
+ import { getCSharpDevKit } from '../../utils/getCSharpDevKit' ;
17
23
18
24
const DotNetMajorVersion = '9' ;
19
25
const DotNetMinorVersion = '0' ;
@@ -41,14 +47,18 @@ export class DotnetRuntimeExtensionResolver implements IHostExecutableResolver {
41
47
return this . hostInfo ;
42
48
}
43
49
50
+ const usingDevkit = getCSharpDevKit ( ) !== undefined ;
51
+ // If we're using devkit, acquire aspnetcore as well - this avoids two separate acquisitions (devkit requires aspnetcore).
52
+ const runtimeMode : DotnetInstallMode = usingDevkit ? 'aspnetcore' : 'runtime' ;
53
+
44
54
this . channel . appendLine ( `Locating .NET runtime version ${ DotNetRuntimeVersion } ` ) ;
45
55
const extensionArchitecture = ( await this . getArchitectureFromTargetPlatform ( ) ) ?? process . arch ;
46
56
const findPathRequest : IDotnetFindPathContext = {
47
57
acquireContext : {
48
58
version : DotNetRuntimeVersion ,
49
59
requestingExtensionId : CSharpExtensionId ,
50
60
architecture : extensionArchitecture ,
51
- mode : 'runtime' ,
61
+ mode : runtimeMode ,
52
62
} ,
53
63
versionSpecRequirement : 'greater_than_or_equal' ,
54
64
// Reject previews because we are not setting `DOTNET_ROLL_FORWARD_TO_PRERELEASE` when starting the server.
@@ -62,7 +72,7 @@ export class DotnetRuntimeExtensionResolver implements IHostExecutableResolver {
62
72
this . channel . appendLine (
63
73
`Did not find .NET ${ DotNetRuntimeVersion } on path, falling back to acquire runtime via ${ DotNetRuntimeExtensionId } `
64
74
) ;
65
- acquireResult = await this . acquireDotNetProcessDependencies ( ) ;
75
+ acquireResult = await this . acquireDotNetProcessDependencies ( runtimeMode ) ;
66
76
}
67
77
68
78
const dotnetExecutablePath = acquireResult . dotnetPath ;
@@ -103,21 +113,22 @@ export class DotnetRuntimeExtensionResolver implements IHostExecutableResolver {
103
113
* Acquires the .NET runtime if it is not already present.
104
114
* @returns The path to the .NET runtime
105
115
*/
106
- private async acquireRuntime ( ) : Promise < IDotnetAcquireResult > {
116
+ private async acquireRuntime ( mode : DotnetInstallMode ) : Promise < IDotnetAcquireResult > {
107
117
// The runtime extension doesn't support specifying a patch versions in the acquire API, so we only use major.minor here.
108
118
// That is generally OK, as acquisition will always acquire the latest patch version.
109
119
const dotnetAcquireVersion = `${ DotNetMajorVersion } .${ DotNetMinorVersion } ` ;
110
- let status = await vscode . commands . executeCommand < IDotnetAcquireResult > ( 'dotnet.acquireStatus' , {
120
+
121
+ const acquireContext : IDotnetAcquireContext = {
111
122
version : dotnetAcquireVersion ,
112
123
requestingExtensionId : CSharpExtensionId ,
113
- } ) ;
124
+ mode : mode ,
125
+ } ;
126
+
127
+ let status = await vscode . commands . executeCommand < IDotnetAcquireResult > ( 'dotnet.acquireStatus' , acquireContext ) ;
114
128
if ( status === undefined ) {
115
129
await vscode . commands . executeCommand ( 'dotnet.showAcquisitionLog' ) ;
116
130
117
- status = await vscode . commands . executeCommand < IDotnetAcquireResult > ( 'dotnet.acquire' , {
118
- version : dotnetAcquireVersion ,
119
- requestingExtensionId : CSharpExtensionId ,
120
- } ) ;
131
+ status = await vscode . commands . executeCommand < IDotnetAcquireResult > ( 'dotnet.acquire' , acquireContext ) ;
121
132
if ( ! status ) {
122
133
throw new Error ( 'Could not resolve the dotnet path!' ) ;
123
134
}
@@ -130,8 +141,8 @@ export class DotnetRuntimeExtensionResolver implements IHostExecutableResolver {
130
141
* Acquires the .NET runtime and any other dependencies required to spawn a particular .NET executable.
131
142
* @param path The path to the entrypoint assembly. Typically a .dll.
132
143
*/
133
- private async acquireDotNetProcessDependencies ( ) : Promise < IDotnetAcquireResult > {
134
- const acquireResult = await this . acquireRuntime ( ) ;
144
+ private async acquireDotNetProcessDependencies ( mode : DotnetInstallMode ) : Promise < IDotnetAcquireResult > {
145
+ const acquireResult = await this . acquireRuntime ( mode ) ;
135
146
136
147
const args = [ this . getServerPath ( this . platformInfo ) ] ;
137
148
// This will install any missing Linux dependencies.
0 commit comments