From 7e89e27c2685948daf574bce91a72934cbe436d7 Mon Sep 17 00:00:00 2001 From: Brendan McShane Date: Mon, 6 Dec 2021 20:28:57 -0500 Subject: [PATCH] Better way to check version Checks to see if the dotnet 6 or greater is running. --- .../Commands/Actions/GetTargetPlatformInformation.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ElectronNET.CLI/Commands/Actions/GetTargetPlatformInformation.cs b/ElectronNET.CLI/Commands/Actions/GetTargetPlatformInformation.cs index af0561d..1496264 100644 --- a/ElectronNET.CLI/Commands/Actions/GetTargetPlatformInformation.cs +++ b/ElectronNET.CLI/Commands/Actions/GetTargetPlatformInformation.cs @@ -103,6 +103,7 @@ namespace ElectronNET.CLI.Commands.Actions private static bool Dotnet6Installed() { //check for .net 6: + //execute dotnet --list-sdks to get versions Process process = new Process(); process.StartInfo.FileName = "dotnet"; process.StartInfo.Arguments = "--list-sdks"; @@ -113,9 +114,13 @@ namespace ElectronNET.CLI.Commands.Actions string standard_output; bool dotnet6Exists = false; + + //get command output: while ((standard_output = process.StandardOutput.ReadLine()) != null) { - if (standard_output.StartsWith("6.")) + //get the major version and see if its greater than or equal to 6 + int majorVer = int.Parse(standard_output.Split(".")[0]); + if (majorVer >= 6) { dotnet6Exists = true; break;