fix .net8 detection

This commit is contained in:
HorizonCode 2024-04-14 17:55:09 +02:00
parent f41ca92711
commit 8b30b7c1fa
1 changed files with 9 additions and 3 deletions

View File

@ -1,8 +1,8 @@
const { exec } = require("child_process");
async function isNet8Installed() {
return new Promise((resolve, reject) => {
exec("dotnet --version", (error, stdout, stderr) => {
return new Promise((resolve) => {
exec("dotnet --list-runtimes", (error, stdout, stderr) => {
if (error) {
resolve(false);
return;
@ -12,7 +12,13 @@ async function isNet8Installed() {
return;
}
const version = stdout.trim();
resolve(version.startsWith("8."));
for (const line of version.split('\n')) {
if (line.startsWith("Microsoft.WindowsDesktop.App 8.")) {
resolve(true);
break;
}
}
resolve(false);
})
});
}