Skip to content

Commit e65deee

Browse files
committed
compatible with version > 6.0 of the .NET runtime
1 parent 4d3f701 commit e65deee

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

src/extension.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,9 @@ function exportEnvToSysPath(context?: vscode.ExtensionContext) {
819819
// 你可通过使用喜欢的 shell 将 DOTNET_CLI_TELEMETRY_OPTOUT 环境变量设置为 "1" 或 "true" 来选择退出遥测。
820820
// 阅读有关 .NET CLI 工具遥测的更多信息: https://aka.ms/dotnet-cli-telemetry
821821
process.env['DOTNET_CLI_TELEMETRY_OPTOUT'] = '1'; // disable telemetry
822+
// 支持运行时回滚
823+
// https://learn.microsoft.com/zh-cn/dotnet/core/whats-new/dotnet-core-3-0#major-version-runtime-roll-forward
824+
process.env['DOTNET_ROLL_FORWARD'] = 'Major';
822825
}
823826

824827
async function checkAndInstallRuntime() {
@@ -844,7 +847,7 @@ async function checkAndInstallRuntime() {
844847
// check/install .NET
845848
//
846849
try {
847-
GlobalEvent.emit('globalLog', newMessage('Info', 'Checking .NET6 runtime ...'));
850+
GlobalEvent.emit('globalLog', newMessage('Info', 'Checking .NET runtime ...'));
848851
GlobalEvent.emit('globalLog', newMessage('Info', `Exec cmd: '${dotnet_chk_cmd}'`));
849852
const dotnetInfo = ChildProcess.execSync(dotnet_chk_cmd).toString().trim();
850853
GlobalEvent.emit('globalLog.append', dotnetInfo + os.EOL);
@@ -853,14 +856,18 @@ async function checkAndInstallRuntime() {
853856
const lines = dotnetInfo.trim().split(/\r\n|\n/);
854857
for (const line_ of lines) {
855858
const line = line_.trim();
856-
if (line.toLowerCase().startsWith('Microsoft.NETCore.App 6.'.toLowerCase())) {
857-
dotnetVerLine = line;
858-
GlobalEvent.emit('globalLog', newMessage('Info', `.NET6 runtime: '${dotnetVerLine}' found !`));
859-
break;
859+
const m = /Microsoft\.NETCore\.App (\d+)\./i.exec(line);
860+
if (m && m.length > 1) {
861+
const rt_ver = parseInt(m[1]);
862+
if (rt_ver >= 6) {
863+
dotnetVerLine = line;
864+
GlobalEvent.emit('globalLog', newMessage('Info', `.NET runtime: '${dotnetVerLine}' found !`));
865+
break;
866+
}
860867
}
861868
}
862869
if (!dotnetVerLine) {
863-
throw new Error(`Can not match .NET6 runtime`);
870+
throw new Error(`Not found available .NET Core runtime`);
864871
}
865872
} catch (error) {
866873

@@ -879,7 +886,7 @@ async function checkAndInstallRuntime() {
879886
const msg = `Not found [.NET6 runtime](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) on your pc, please install it !`;
880887
vscode.window.showWarningMessage(msg);
881888
// https://dotnet.microsoft.com/en-us/download/dotnet/scripts
882-
utility.openUrl(`https://dotnet.microsoft.com/en-us/download/dotnet/scripts`);
889+
// utility.openUrl(`https://dotnet.microsoft.com/en-us/download/dotnet/scripts`);
883890
}
884891

885892
// win32, we can auto install it

0 commit comments

Comments
 (0)