From a5e4b745ef35223bf7cda9079c6e2f75605a392b Mon Sep 17 00:00:00 2001 From: MathieuG-P Date: Sat, 4 Mar 2023 19:28:01 +0100 Subject: [PATCH] fix dotnet notif not appear sometimes --- src/main/services/bs-installer.service.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/services/bs-installer.service.ts b/src/main/services/bs-installer.service.ts index 26a25aa3..c6c6ea35 100644 --- a/src/main/services/bs-installer.service.ts +++ b/src/main/services/bs-installer.service.ts @@ -10,6 +10,7 @@ import { BSLocalVersionService } from "./bs-local-version.service"; import isOnline from 'is-online'; import { WindowManagerService } from "./window-manager.service"; import { copy, copySync } from "fs-extra"; +import { clean, satisfies } from "semver"; export class BSInstallerService{ @@ -72,12 +73,16 @@ export class BSInstallerService{ public async isDotNet6Installed(): Promise{ try{ - const process = spawnSync(this.getDepotDownloaderExePath(), {shell: true}); - const out = process.output.toString(); - if(out.includes(".NET runtime can be found at")){ return false; } - return true; + const process = spawnSync("(dir (Get-Command dotnet).Path.Replace('dotnet.exe', 'shared\\Microsoft.NETCore.App')).Name", {shell: "powershell.exe"}); + if(process.stderr.toString()){ + log.error("try isDotNet6Installed", process.stderr.toString()); + return false; + } + const versions = process.stdout.toString().split("\n"); + return versions.some(version => satisfies(clean(version), "6.x")); } catch(e){ + log.error("catch isDotNet6Installed", e); return false; } }