Merge pull request 're-add net 6 precheck until 3.8.0 drops' (#60) from waffle.lord/SPT-AKI-Installer:fix/net-6-check into master
Reviewed-on: CWX/SPT-AKI-Installer#60
This commit is contained in:
commit
1f9ace4763
74
SPTInstaller/Installer Tasks/PreChecks/NetCore6PreCheck.cs
Normal file
74
SPTInstaller/Installer Tasks/PreChecks/NetCore6PreCheck.cs
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
using Serilog;
|
||||||
|
using SPTInstaller.Models;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using SPTInstaller.Helpers;
|
||||||
|
|
||||||
|
namespace SPTInstaller.Installer_Tasks.PreChecks;
|
||||||
|
|
||||||
|
public class NetCore6PreCheck : PreCheckBase
|
||||||
|
{
|
||||||
|
public NetCore6PreCheck() : base(".Net Core 6 Desktop Runtime", true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task<PreCheckResult> CheckOperation()
|
||||||
|
{
|
||||||
|
var minRequiredVersion = new Version("6.0.0");
|
||||||
|
string[] output;
|
||||||
|
|
||||||
|
var failedButtonText = "Download .Net Core 6 Desktop Runtime";
|
||||||
|
|
||||||
|
var failedButtonAction = () =>
|
||||||
|
{
|
||||||
|
Process.Start(new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = "cmd.exe",
|
||||||
|
UseShellExecute = true,
|
||||||
|
WindowStyle = ProcessWindowStyle.Hidden,
|
||||||
|
ArgumentList = { "/C", "start", "https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-desktop-6.0.4-windows-x64-installer" }
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = ProcessHelper.RunAndReadProcessOutputs("dotnet", "--list-runtimes");
|
||||||
|
|
||||||
|
if (!result.Succeeded)
|
||||||
|
{
|
||||||
|
return PreCheckResult.FromError(result.Message + "\n\nYou most likely don't have .net 6 installed", failedButtonText, failedButtonAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
output = result.StdOut.Split("\r\n");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex, $"PreCheck::{Name}::Exception");
|
||||||
|
return PreCheckResult.FromException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
var highestFoundVersion = new Version("0.0.0");
|
||||||
|
|
||||||
|
foreach (var lineVersion in output)
|
||||||
|
{
|
||||||
|
var regex = Regex.Match(lineVersion, @"Microsoft.WindowsDesktop.App (\d\.\d\.\d)");
|
||||||
|
|
||||||
|
if (!regex.Success || regex.Groups.Count < 1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var stringVersion = regex.Groups[1].Value;
|
||||||
|
|
||||||
|
var foundVersion = new Version(stringVersion);
|
||||||
|
|
||||||
|
if (foundVersion >= minRequiredVersion)
|
||||||
|
{
|
||||||
|
return PreCheckResult.FromSuccess($".Net Core {minRequiredVersion} Desktop Runtime or higher is installed.\n\nInstalled Version: {foundVersion}");
|
||||||
|
}
|
||||||
|
|
||||||
|
highestFoundVersion = foundVersion > highestFoundVersion ? foundVersion : highestFoundVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PreCheckResult.FromError($".Net Core Desktop Runtime version {minRequiredVersion} or higher is required.\n\nHighest Version Found: {(highestFoundVersion > new Version("0.0.0") ? highestFoundVersion : "Not Found")}\n\nThis is required to play SPT, but you can install it later if and shouldn't affect the SPT install process.", failedButtonText, failedButtonAction);
|
||||||
|
}
|
||||||
|
}
|
@ -44,6 +44,7 @@ internal class Program
|
|||||||
|
|
||||||
#if !TEST
|
#if !TEST
|
||||||
ServiceHelper.Register<PreCheckBase, NetFramework472PreCheck>();
|
ServiceHelper.Register<PreCheckBase, NetFramework472PreCheck>();
|
||||||
|
ServiceHelper.Register<PreCheckBase, NetCore6PreCheck>();
|
||||||
ServiceHelper.Register<PreCheckBase, Net8PreCheck>();
|
ServiceHelper.Register<PreCheckBase, Net8PreCheck>();
|
||||||
ServiceHelper.Register<PreCheckBase, FreeSpacePreCheck>();
|
ServiceHelper.Register<PreCheckBase, FreeSpacePreCheck>();
|
||||||
ServiceHelper.Register<PreCheckBase, EftLauncherPreCheck>();
|
ServiceHelper.Register<PreCheckBase, EftLauncherPreCheck>();
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
<PackageIcon>icon.ico</PackageIcon>
|
<PackageIcon>icon.ico</PackageIcon>
|
||||||
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
|
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
|
||||||
<Configurations>Debug;Release;TEST</Configurations>
|
<Configurations>Debug;Release;TEST</Configurations>
|
||||||
<AssemblyVersion>2.43</AssemblyVersion>
|
<AssemblyVersion>2.44</AssemblyVersion>
|
||||||
<FileVersion>2.43</FileVersion>
|
<FileVersion>2.44</FileVersion>
|
||||||
<Company>SPT-AKI</Company>
|
<Company>SPT-AKI</Company>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user