@@ -12,8 +12,14 @@ import { languageServerOptions } from '../../shared/options';
1212import { existsSync } from 'fs' ;
1313import { CSharpExtensionId } from '../../constants/csharpExtensionId' ;
1414import { readFile } from 'fs/promises' ;
15- import { IDotnetAcquireResult , IDotnetFindPathContext } from './dotnetRuntimeExtensionApi' ;
15+ import {
16+ DotnetInstallMode ,
17+ IDotnetAcquireContext ,
18+ IDotnetAcquireResult ,
19+ IDotnetFindPathContext ,
20+ } from './dotnetRuntimeExtensionApi' ;
1621import { DotNetRuntimeExtensionId } from '../../checkDotNetRuntimeExtensionVersion' ;
22+ import { getCSharpDevKit } from '../../utils/getCSharpDevKit' ;
1723
1824const DotNetMajorVersion = '9' ;
1925const DotNetMinorVersion = '0' ;
@@ -41,14 +47,18 @@ export class DotnetRuntimeExtensionResolver implements IHostExecutableResolver {
4147 return this . hostInfo ;
4248 }
4349
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+
4454 this . channel . appendLine ( `Locating .NET runtime version ${ DotNetRuntimeVersion } ` ) ;
4555 const extensionArchitecture = ( await this . getArchitectureFromTargetPlatform ( ) ) ?? process . arch ;
4656 const findPathRequest : IDotnetFindPathContext = {
4757 acquireContext : {
4858 version : DotNetRuntimeVersion ,
4959 requestingExtensionId : CSharpExtensionId ,
5060 architecture : extensionArchitecture ,
51- mode : 'runtime' ,
61+ mode : runtimeMode ,
5262 } ,
5363 versionSpecRequirement : 'greater_than_or_equal' ,
5464 // 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 {
6272 this . channel . appendLine (
6373 `Did not find .NET ${ DotNetRuntimeVersion } on path, falling back to acquire runtime via ${ DotNetRuntimeExtensionId } `
6474 ) ;
65- acquireResult = await this . acquireDotNetProcessDependencies ( ) ;
75+ acquireResult = await this . acquireDotNetProcessDependencies ( runtimeMode ) ;
6676 }
6777
6878 const dotnetExecutablePath = acquireResult . dotnetPath ;
@@ -103,21 +113,22 @@ export class DotnetRuntimeExtensionResolver implements IHostExecutableResolver {
103113 * Acquires the .NET runtime if it is not already present.
104114 * @returns The path to the .NET runtime
105115 */
106- private async acquireRuntime ( ) : Promise < IDotnetAcquireResult > {
116+ private async acquireRuntime ( mode : DotnetInstallMode ) : Promise < IDotnetAcquireResult > {
107117 // The runtime extension doesn't support specifying a patch versions in the acquire API, so we only use major.minor here.
108118 // That is generally OK, as acquisition will always acquire the latest patch version.
109119 const dotnetAcquireVersion = `${ DotNetMajorVersion } .${ DotNetMinorVersion } ` ;
110- let status = await vscode . commands . executeCommand < IDotnetAcquireResult > ( 'dotnet.acquireStatus' , {
120+
121+ const acquireContext : IDotnetAcquireContext = {
111122 version : dotnetAcquireVersion ,
112123 requestingExtensionId : CSharpExtensionId ,
113- } ) ;
124+ mode : mode ,
125+ } ;
126+
127+ let status = await vscode . commands . executeCommand < IDotnetAcquireResult > ( 'dotnet.acquireStatus' , acquireContext ) ;
114128 if ( status === undefined ) {
115129 await vscode . commands . executeCommand ( 'dotnet.showAcquisitionLog' ) ;
116130
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 ) ;
121132 if ( ! status ) {
122133 throw new Error ( 'Could not resolve the dotnet path!' ) ;
123134 }
@@ -130,8 +141,8 @@ export class DotnetRuntimeExtensionResolver implements IHostExecutableResolver {
130141 * Acquires the .NET runtime and any other dependencies required to spawn a particular .NET executable.
131142 * @param path The path to the entrypoint assembly. Typically a .dll.
132143 */
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 ) ;
135146
136147 const args = [ this . getServerPath ( this . platformInfo ) ] ;
137148 // This will install any missing Linux dependencies.
0 commit comments