mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Remove .net 6 version cutoff for building sql projects (#17736)
* remove .net 6 version cutoff for building sql projects
* Revert "Warning when .NET 6 SDK is detected (#17422)"
This reverts commit 2ed8aeb565.
* add back skipVersionSupportedCheck
* add back return false
* addressing comments
This commit is contained in:
@@ -51,10 +51,6 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "%sqlDatabaseProjects.netCoreDoNotAsk%"
|
"description": "%sqlDatabaseProjects.netCoreDoNotAsk%"
|
||||||
},
|
},
|
||||||
"sqlDatabaseProjects.netCoreDowngradeDoNotShow": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "%sqlDatabaseProjects.netCoreDowngradeDoNotShow%"
|
|
||||||
},
|
|
||||||
"sqlDatabaseProjects.nodejsDoNotAsk": {
|
"sqlDatabaseProjects.nodejsDoNotAsk": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "%sqlDatabaseProjects.nodejsDoNotAsk%"
|
"description": "%sqlDatabaseProjects.nodejsDoNotAsk%"
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
"sqlDatabaseProjects.Settings": "Database Projects",
|
"sqlDatabaseProjects.Settings": "Database Projects",
|
||||||
"sqlDatabaseProjects.netCoreInstallLocation": "Full path to .NET Core SDK on the machine.",
|
"sqlDatabaseProjects.netCoreInstallLocation": "Full path to .NET Core SDK on the machine.",
|
||||||
"sqlDatabaseProjects.netCoreDoNotAsk": "Whether to prompt the user to install .NET Core when not detected.",
|
"sqlDatabaseProjects.netCoreDoNotAsk": "Whether to prompt the user to install .NET Core when not detected.",
|
||||||
"sqlDatabaseProjects.netCoreDowngradeDoNotShow": "Whether to prompt the user to install .NET SDK version and add global.json to project when a newer unsupported version is detected.",
|
|
||||||
"sqlDatabaseProjects.nodejsDoNotAsk": "Whether to prompt the user to install Node.js when not detected.",
|
"sqlDatabaseProjects.nodejsDoNotAsk": "Whether to prompt the user to install Node.js when not detected.",
|
||||||
"sqlDatabaseProjects.autorestSqlVersion": "Which version of Autorest.Sql to use from NPM. Latest will be used if not set.",
|
"sqlDatabaseProjects.autorestSqlVersion": "Which version of Autorest.Sql to use from NPM. Latest will be used if not set.",
|
||||||
"sqlDatabaseProjects.welcome": "No database projects currently open.\n[New Project](command:sqlDatabaseProjects.new)\n[Open Project](command:sqlDatabaseProjects.open)\n[Create Project From Database](command:sqlDatabaseProjects.importDatabase)",
|
"sqlDatabaseProjects.welcome": "No database projects currently open.\n[New Project](command:sqlDatabaseProjects.new)\n[Open Project](command:sqlDatabaseProjects.open)\n[Create Project From Database](command:sqlDatabaseProjects.importDatabase)",
|
||||||
|
|||||||
@@ -321,14 +321,12 @@ export const postDeployScriptFriendlyName = localize('postDeployScriptFriendlyNa
|
|||||||
|
|
||||||
export const NetCoreInstallationConfirmation: string = localize('sqlDatabaseProjects.NetCoreInstallationConfirmation', "The .NET Core SDK cannot be located. Project build will not work. Please install .NET Core SDK version 3.1 or update the .NET Core SDK location in settings if already installed.");
|
export const NetCoreInstallationConfirmation: string = localize('sqlDatabaseProjects.NetCoreInstallationConfirmation', "The .NET Core SDK cannot be located. Project build will not work. Please install .NET Core SDK version 3.1 or update the .NET Core SDK location in settings if already installed.");
|
||||||
export function NetCoreSupportedVersionInstallationConfirmation(installedVersion: string) { return localize('sqlDatabaseProjects.NetCoreSupportedVersionInstallationConfirmation', "Currently installed .NET Core SDK version is {0}, which is not supported. Project build will not work. Please install .NET Core SDK version 3.1 or update the .NET Core SDK supported version location in settings if already installed.", installedVersion); }
|
export function NetCoreSupportedVersionInstallationConfirmation(installedVersion: string) { return localize('sqlDatabaseProjects.NetCoreSupportedVersionInstallationConfirmation', "Currently installed .NET Core SDK version is {0}, which is not supported. Project build will not work. Please install .NET Core SDK version 3.1 or update the .NET Core SDK supported version location in settings if already installed.", installedVersion); }
|
||||||
export function NetCoreVersionDowngradeConfirmation(installedVersion: string) { return localize('sqlDatabaseProjects.NetCoreVersionDowngradeConfirmation', "Installed .NET SDK version {0} is newer than the currently supported versions. Project build will not work. Please install .NET Core SDK version 3.1 and include a global.json in the project folder specifying the SDK version to use. [More Information](https://docs.microsoft.com/dotnet/core/versions/selection)", installedVersion); }
|
|
||||||
export const UpdateNetCoreLocation: string = localize('sqlDatabaseProjects.UpdateNetCoreLocation', "Update Location");
|
export const UpdateNetCoreLocation: string = localize('sqlDatabaseProjects.UpdateNetCoreLocation', "Update Location");
|
||||||
export const projectsOutputChannel = localize('sqlDatabaseProjects.outputChannel', "Database Projects");
|
export const projectsOutputChannel = localize('sqlDatabaseProjects.outputChannel', "Database Projects");
|
||||||
|
|
||||||
// Prompt buttons
|
// Prompt buttons
|
||||||
export const Install: string = localize('sqlDatabaseProjects.Install', "Install");
|
export const Install: string = localize('sqlDatabaseProjects.Install', "Install");
|
||||||
export const DoNotAskAgain: string = localize('sqlDatabaseProjects.doNotAskAgain', "Don't Ask Again");
|
export const DoNotAskAgain: string = localize('sqlDatabaseProjects.doNotAskAgain', "Don't Ask Again");
|
||||||
export const DoNotShowAgain: string = localize('sqlDatabaseProjects.doNotShowAgain', "Don't Show Again");
|
|
||||||
|
|
||||||
// SqlProj file XML names
|
// SqlProj file XML names
|
||||||
export const ItemGroup = 'ItemGroup';
|
export const ItemGroup = 'ItemGroup';
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import * as semver from 'semver';
|
|||||||
import { isNullOrUndefined } from 'util';
|
import { isNullOrUndefined } from 'util';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as nls from 'vscode-nls';
|
import * as nls from 'vscode-nls';
|
||||||
import { DoNotAskAgain, DoNotShowAgain, Install, NetCoreInstallationConfirmation, NetCoreSupportedVersionInstallationConfirmation, NetCoreVersionDowngradeConfirmation, UpdateNetCoreLocation } from '../common/constants';
|
import { DoNotAskAgain, Install, NetCoreInstallationConfirmation, NetCoreSupportedVersionInstallationConfirmation, UpdateNetCoreLocation } from '../common/constants';
|
||||||
import * as utils from '../common/utils';
|
import * as utils from '../common/utils';
|
||||||
import { ShellCommandOptions, ShellExecutionHelper } from './shellExecutionHelper';
|
import { ShellCommandOptions, ShellExecutionHelper } from './shellExecutionHelper';
|
||||||
const localize = nls.loadMessageBundle();
|
const localize = nls.loadMessageBundle();
|
||||||
@@ -19,19 +19,16 @@ const localize = nls.loadMessageBundle();
|
|||||||
export const DBProjectConfigurationKey: string = 'sqlDatabaseProjects';
|
export const DBProjectConfigurationKey: string = 'sqlDatabaseProjects';
|
||||||
export const NetCoreInstallLocationKey: string = 'netCoreSDKLocation';
|
export const NetCoreInstallLocationKey: string = 'netCoreSDKLocation';
|
||||||
export const NetCoreDoNotAskAgainKey: string = 'netCoreDoNotAsk';
|
export const NetCoreDoNotAskAgainKey: string = 'netCoreDoNotAsk';
|
||||||
export const NetCoreDowngradeDoNotShowAgainKey: string = 'netCoreDowngradeDoNotShow';
|
|
||||||
export const NetCoreNonWindowsDefaultPath = '/usr/local/share';
|
export const NetCoreNonWindowsDefaultPath = '/usr/local/share';
|
||||||
export const winPlatform: string = 'win32';
|
export const winPlatform: string = 'win32';
|
||||||
export const macPlatform: string = 'darwin';
|
export const macPlatform: string = 'darwin';
|
||||||
export const linuxPlatform: string = 'linux';
|
export const linuxPlatform: string = 'linux';
|
||||||
export const minSupportedNetCoreVersion: string = '3.1.0';
|
export const minSupportedNetCoreVersionForBuild: string = '3.1.0';
|
||||||
export const maxSupportedNetCoreVersionCutoff: string = '6.0.0'; // un-set this to allow latest
|
|
||||||
|
|
||||||
export const enum netCoreInstallState {
|
export const enum netCoreInstallState {
|
||||||
netCoreNotPresent,
|
netCoreNotPresent,
|
||||||
netCoreVersionNotSupported,
|
netCoreVersionNotSupported,
|
||||||
netCoreVersionSupported,
|
netCoreVersionSupported
|
||||||
netCoreVersionTooHigh
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const dotnet = os.platform() === 'win32' ? 'dotnet.exe' : 'dotnet';
|
const dotnet = os.platform() === 'win32' ? 'dotnet.exe' : 'dotnet';
|
||||||
@@ -50,11 +47,9 @@ export class NetCoreTool extends ShellExecutionHelper {
|
|||||||
*/
|
*/
|
||||||
public async findOrInstallNetCore(skipVersionSupportedCheck = false): Promise<boolean> {
|
public async findOrInstallNetCore(skipVersionSupportedCheck = false): Promise<boolean> {
|
||||||
if (!this.isNetCoreInstallationPresent || (this.isNetCoreInstallationPresent && !skipVersionSupportedCheck)) {
|
if (!this.isNetCoreInstallationPresent || (this.isNetCoreInstallationPresent && !skipVersionSupportedCheck)) {
|
||||||
if (!this.isNetCoreInstallationPresent || !await this.isNetCoreVersionSupported()) {
|
if ((!this.isNetCoreInstallationPresent || !await this.isNetCoreVersionSupportedForBuild())) {
|
||||||
if (this.netCoreInstallState === netCoreInstallState.netCoreVersionSupported && vscode.workspace.getConfiguration(DBProjectConfigurationKey)[NetCoreDoNotAskAgainKey] !== true) {
|
if (vscode.workspace.getConfiguration(DBProjectConfigurationKey)[NetCoreDoNotAskAgainKey] !== true) {
|
||||||
void this.showInstallDialog(); // Removing await so that Build and extension load process doesn't wait on user input
|
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;
|
||||||
}
|
}
|
||||||
@@ -89,15 +84,6 @@ export class NetCoreTool extends ShellExecutionHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async showDowngradeDialog(): Promise<void> {
|
|
||||||
const result = await vscode.window.showErrorMessage(NetCoreVersionDowngradeConfirmation(this.netCoreSdkInstalledVersion!), DoNotShowAgain);
|
|
||||||
|
|
||||||
if (result === DoNotShowAgain) {
|
|
||||||
const config = vscode.workspace.getConfiguration(DBProjectConfigurationKey);
|
|
||||||
await config.update(NetCoreDowngradeDoNotShowAgainKey, true, vscode.ConfigurationTarget.Global);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private get isNetCoreInstallationPresent(): boolean {
|
private get isNetCoreInstallationPresent(): boolean {
|
||||||
const netCoreInstallationPresent = (!isNullOrUndefined(this.netcoreInstallLocation) && fs.existsSync(this.netcoreInstallLocation));
|
const netCoreInstallationPresent = (!isNullOrUndefined(this.netcoreInstallLocation) && fs.existsSync(this.netcoreInstallLocation));
|
||||||
if (!netCoreInstallationPresent) {
|
if (!netCoreInstallationPresent) {
|
||||||
@@ -140,16 +126,16 @@ export class NetCoreTool extends ShellExecutionHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function checks if the installed dotnet version is between minSupportedNetCoreVersion (inclusive) and maxSupportedNetCoreVersionCutoff (exclusive).
|
* This function checks if the installed dotnet version is at least minSupportedNetCoreVersionForBuild.
|
||||||
* When maxSupportedNetCoreVersionCutoff is not set, the latest dotnet version is assumed to be supported and only the min version is checked.
|
* Versions lower than minSupportedNetCoreVersionForBuild aren't supported for building projects.
|
||||||
* Returns: True if installed dotnet version is supported, false otherwise.
|
* Returns: True if installed dotnet version is supported, false otherwise.
|
||||||
* Undefined if dotnet isn't installed.
|
* Undefined if dotnet isn't installed.
|
||||||
*/
|
*/
|
||||||
private async isNetCoreVersionSupported(): Promise<boolean | undefined> {
|
private async isNetCoreVersionSupportedForBuild(): Promise<boolean | undefined> {
|
||||||
try {
|
try {
|
||||||
const spawn = child_process.spawn;
|
const spawn = child_process.spawn;
|
||||||
let child: child_process.ChildProcessWithoutNullStreams;
|
let child: child_process.ChildProcessWithoutNullStreams;
|
||||||
let installState: netCoreInstallState = netCoreInstallState.netCoreVersionSupported;
|
let isSupported: boolean = false;
|
||||||
const stdoutBuffers: Buffer[] = [];
|
const stdoutBuffers: Buffer[] = [];
|
||||||
|
|
||||||
child = spawn('dotnet --version', [], {
|
child = spawn('dotnet --version', [], {
|
||||||
@@ -163,21 +149,10 @@ export class NetCoreTool extends ShellExecutionHelper {
|
|||||||
this.netCoreSdkInstalledVersion = Buffer.concat(stdoutBuffers).toString('utf8').trim();
|
this.netCoreSdkInstalledVersion = Buffer.concat(stdoutBuffers).toString('utf8').trim();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// minSupportedDotnetVersion <= supported version < maxSupportedDotnetVersion
|
if (semver.gte(this.netCoreSdkInstalledVersion, minSupportedNetCoreVersionForBuild)) { // Net core version greater than or equal to minSupportedNetCoreVersion are supported for Build
|
||||||
if (semver.gte(this.netCoreSdkInstalledVersion, minSupportedNetCoreVersion)) {
|
isSupported = true;
|
||||||
// If maxSupportedNetCoreVersionCutoff is not set, the latest .NET version is allowed
|
|
||||||
if (maxSupportedNetCoreVersionCutoff) {
|
|
||||||
if (semver.lt(this.netCoreSdkInstalledVersion, maxSupportedNetCoreVersionCutoff)) {
|
|
||||||
installState = netCoreInstallState.netCoreVersionSupported;
|
|
||||||
} else {
|
} else {
|
||||||
installState = netCoreInstallState.netCoreVersionTooHigh;
|
isSupported = false;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
installState = netCoreInstallState.netCoreVersionSupported;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// .NET version is too low
|
|
||||||
installState = netCoreInstallState.netCoreVersionNotSupported;
|
|
||||||
}
|
}
|
||||||
resolve({ stdout: this.netCoreSdkInstalledVersion });
|
resolve({ stdout: this.netCoreSdkInstalledVersion });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -192,8 +167,13 @@ export class NetCoreTool extends ShellExecutionHelper {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.netCoreInstallState = installState;
|
if (isSupported) {
|
||||||
return installState === netCoreInstallState.netCoreVersionSupported;
|
this.netCoreInstallState = netCoreInstallState.netCoreVersionSupported;
|
||||||
|
} else {
|
||||||
|
this.netCoreInstallState = netCoreInstallState.netCoreVersionNotSupported;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isSupported;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
this.netCoreInstallState = netCoreInstallState.netCoreNotPresent;
|
this.netCoreInstallState = netCoreInstallState.netCoreNotPresent;
|
||||||
@@ -215,8 +195,6 @@ export class NetCoreTool extends ShellExecutionHelper {
|
|||||||
if (!(await this.findOrInstallNetCore(skipVersionSupportedCheck))) {
|
if (!(await this.findOrInstallNetCore(skipVersionSupportedCheck))) {
|
||||||
if (this.netCoreInstallState === netCoreInstallState.netCoreNotPresent) {
|
if (this.netCoreInstallState === netCoreInstallState.netCoreNotPresent) {
|
||||||
throw new DotNetError(NetCoreInstallationConfirmation);
|
throw new DotNetError(NetCoreInstallationConfirmation);
|
||||||
} else if (this.netCoreInstallState === netCoreInstallState.netCoreVersionTooHigh && vscode.workspace.getConfiguration(DBProjectConfigurationKey)[NetCoreDowngradeDoNotShowAgainKey] === true) {
|
|
||||||
// Assume user has used global.json to override SDK version and proceed with build as is
|
|
||||||
} else {
|
} else {
|
||||||
throw new DotNetError(NetCoreSupportedVersionInstallationConfirmation(this.netCoreSdkInstalledVersion!));
|
throw new DotNetError(NetCoreSupportedVersionInstallationConfirmation(this.netCoreSdkInstalledVersion!));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user