diff --git a/extensions/sql-database-projects/src/tools/netcoreTool.ts b/extensions/sql-database-projects/src/tools/netcoreTool.ts index 4c980d0524..8bf08e885a 100644 --- a/extensions/sql-database-projects/src/tools/netcoreTool.ts +++ b/extensions/sql-database-projects/src/tools/netcoreTool.ts @@ -44,18 +44,22 @@ export class NetCoreTool extends ShellExecutionHelper { /** * This method presents the installation dialog for .NET Core, if not already present/supported + * @param skipVersionSupportedCheck If true then skip the check to determine whether the .NET version is supported (for commands that work on all versions) * @returns True if .NET version was found and is supported * False if .NET version isn't present or present but not supported */ - public async findOrInstallNetCore(): Promise { - if ((!this.isNetCoreInstallationPresent || !await this.isNetCoreVersionSupported())) { - if (this.netCoreInstallState === netCoreInstallState.netCoreVersionSupported && vscode.workspace.getConfiguration(DBProjectConfigurationKey)[NetCoreDoNotAskAgainKey] !== true) { - void this.showInstallDialog(); // Removing await so that Build and extension load process doesn't wait on user input - } else if (this.netCoreInstallState === netCoreInstallState.netCoreVersionTooHigh && vscode.workspace.getConfiguration(DBProjectConfigurationKey)[NetCoreDowngradeDoNotShowAgainKey] !== true) { - void this.showDowngradeDialog(); + public async findOrInstallNetCore(skipVersionSupportedCheck = false): Promise { + if (!this.isNetCoreInstallationPresent || (this.isNetCoreInstallationPresent && !skipVersionSupportedCheck)) { + if (!this.isNetCoreInstallationPresent || !await this.isNetCoreVersionSupported()) { + if (this.netCoreInstallState === netCoreInstallState.netCoreVersionSupported && vscode.workspace.getConfiguration(DBProjectConfigurationKey)[NetCoreDoNotAskAgainKey] !== true) { + void this.showInstallDialog(); // Removing await so that Build and extension load process doesn't wait on user input + } else if (this.netCoreInstallState === netCoreInstallState.netCoreVersionTooHigh && vscode.workspace.getConfiguration(DBProjectConfigurationKey)[NetCoreDowngradeDoNotShowAgainKey] !== true) { + void this.showDowngradeDialog(); + } + return false; } - return false; } + this.netCoreInstallState = netCoreInstallState.netCoreVersionSupported; return true; } @@ -197,12 +201,18 @@ export class NetCoreTool extends ShellExecutionHelper { } } - public async runDotnetCommand(options: ShellCommandOptions): Promise { + /** + * Runs the specified dotnet command + * @param options The options to use when launching the process + * @param skipVersionSupportedCheck If true then skip the check to determine whether the .NET version is supported (for commands that work on all versions) + * @returns + */ + public async runDotnetCommand(options: ShellCommandOptions, skipVersionSupportedCheck = false): Promise { if (options && options.commandTitle !== undefined && options.commandTitle !== null) { this._outputChannel.appendLine(`\t[ ${options.commandTitle} ]`); } - if (!(await this.findOrInstallNetCore())) { + if (!(await this.findOrInstallNetCore(skipVersionSupportedCheck))) { if (this.netCoreInstallState === netCoreInstallState.netCoreNotPresent) { throw new DotNetError(NetCoreInstallationConfirmation); } else if (this.netCoreInstallState === netCoreInstallState.netCoreVersionTooHigh && vscode.workspace.getConfiguration(DBProjectConfigurationKey)[NetCoreDowngradeDoNotShowAgainKey] === true) { diff --git a/extensions/sql-database-projects/src/tools/packageHelper.ts b/extensions/sql-database-projects/src/tools/packageHelper.ts index 79334619ae..8e3e2f0b94 100644 --- a/extensions/sql-database-projects/src/tools/packageHelper.ts +++ b/extensions/sql-database-projects/src/tools/packageHelper.ts @@ -47,8 +47,8 @@ export class PackageHelper { commandTitle: constants.addPackage, argument: this.constructAddPackageArguments(projectUri, packageName, packageVersion) }; - - await this.netCoreTool.runDotnetCommand(addOptions); + // Add package can be done with any version of .NET so skip the supported version check + await this.netCoreTool.runDotnetCommand(addOptions, true); } /**