Skip to content

Commit

Permalink
Add warning for .NET 8 Installation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sora-yx committed Aug 10, 2024
1 parent 7737248 commit cc3ac2c
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 9 deletions.
3 changes: 3 additions & 0 deletions SA-Mod-Manager/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ public static async Task<bool> PerformUpdateManagerCheck()
if (update.Item1 == false) //no update found
return false;

if (await Util.Net8Check() == false)
return false;

string changelog = await GitHub.GetGitChangeLog(update.Item2);

if (string.IsNullOrEmpty(changelog)) //update found but no changelog (?)
Expand Down
1 change: 1 addition & 0 deletions SA-Mod-Manager/Languages/MessageWindow/en-EN.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
<system:String x:Key="MessageWindow.Warnings.ProfileMigration.Message1" xml:space="preserve">The following files failed to be imported as profiles:</system:String>
<system:String x:Key="MessageWindow.Warnings.ProfileMigration.Message2" xml:space="preserve">&#x0a;&#x0a;Please ensure you are only using Game Profile JSON files or old Loader INI files.</system:String>

<system:String x:Key="MessageWindow.Warnings.Net8Missing" xml:space="preserve">The new Mod Manager update requires at least .NET 8.0.7 Desktop Runtime to work.&#x0a;&#x0a;Would you like to install it now?</system:String>
<!--#endregion-->

<!--#region Information-->
Expand Down
1 change: 1 addition & 0 deletions SA-Mod-Manager/Languages/MessageWindow/es-ES.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
<system:String x:Key="MessageWindow.Warnings.ProfileMigration.Title" xml:space="preserve">No se pudo Importar</system:String>
<system:String x:Key="MessageWindow.Warnings.ProfileMigration.Message1" xml:space="preserve">No se pudieron importar los siguientes archivos como perfiles:</system:String>
<system:String x:Key="MessageWindow.Warnings.ProfileMigration.Message2" xml:space="preserve">&#x0a;&#x0a;Por favor, asegúrate de que estás usando un archivo .JSON de Perfil de Juego o un archivo .INI del antiguo Mod Loader.</system:String>
<system:String x:Key="MessageWindow.Warnings.Net8Missing" xml:space="preserve">The new Mod Manager update requires at least .NET 8.0.7 Desktop Runtime to work.&#x0a;&#x0a;Would you like to install it now?</system:String>
<!--#endregion-->

<!--#region Information-->
Expand Down
2 changes: 2 additions & 0 deletions SA-Mod-Manager/Languages/MessageWindow/es-MX.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<system:String x:Key="MessageWindow.Errors.PermissionTitle">Access Denied</system:String>
<system:String x:Key="MessageWindow.Errors.FolderPermission" xml:space="preserve">Failed to create directory, the program does not have the authorization to write at this path: {0}&#x0a;&#x0a;Please restart the Manager with Administrator Privileges.</system:String>
<system:String x:Key="MessageWindow.Errors.GameNoLongerFound" xml:space="preserve">Failed to find the game path of {0} at {1}&#x0a;If you have moved your game directory to a different location, please re set the game path in the Manager Config tab.</system:String>

<!--#endregion-->

<!--#region Warnings-->
Expand Down Expand Up @@ -134,6 +135,7 @@
<system:String x:Key="MessageWindow.Warnings.ProfileMigration.Title" xml:space="preserve">Error al importar</system:String>
<system:String x:Key="MessageWindow.Warnings.ProfileMigration.Message1" xml:space="preserve">No se pudieron importar los siguientes archivos como perfiles:</system:String>
<system:String x:Key="MessageWindow.Warnings.ProfileMigration.Message2" xml:space="preserve">&#x0a;&#x0a;Por favor, asegúrate de que sólo utilizas archivos JSON de perfil de juego o archivos INI del antiguo cargador.</system:String>
<system:String x:Key="MessageWindow.Warnings.Net8Missing" xml:space="preserve">The new Mod Manager update requires at least .NET 8.0.7 Desktop Runtime to work.&#x0a;&#x0a;Would you like to install it now?</system:String>
<!--#endregion-->

<!--#region Information-->
Expand Down
2 changes: 1 addition & 1 deletion SA-Mod-Manager/Languages/MessageWindow/fr-FR.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<system:String x:Key="MessageWindow.Warnings.HealthCheckTitle">Bilan de Santé</system:String>
<system:String x:Key="MessageWindow.Warnings.HealthCheck" xml:space="preserve">Vous êtes sur le point d'exécuter le bilan de santé du jeu. Cette action vérifiera tous les fichiers du jeu, à l'exception des fichiers audio.&#x0a;&#x0a;Souhaitez-vous continuer?</system:String>
<system:String x:Key="MessageWindow.Warnings.GenerateManifest" xml:space="preserve">Cette action peut causer la perte des DONNÉES UTILISATEUR DU MOD (FICHIERS DE SAUVEGARDE ET CONFIG) lors de la prochaine mise à jour ! Pour éviter cela, vous ne devez jamais exécuter cette action sur des mods que vous n'avez pas développés.&#x0a;&#x0a;Êtes-vous sûr de vouloir continuer ?</system:String>

<system:String x:Key="MessageWindow.Warnings.Net8Missing" xml:space="preserve">La nouvelle mise à jour de Mod Manager nécessite au moins .NET 8.0.7 Desktop Runtime pour fonctionner.&#x0a;&#x0a;Souhaitez-vous l'installer maintenant ?</system:String>
<!--#endregion-->

<!--#region Information-->
Expand Down
1 change: 1 addition & 0 deletions SA-Mod-Manager/Languages/MessageWindow/it-IT.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<system:String x:Key="MessageWindow.Warnings.GenerateManifest" xml:space="preserve">I file utente relativi alla mod (SALVATAGGI, CONFIGURAZIONE) POTREBBERO ESSERE PERSI al prossimo aggiornamento! Per evitare ciò, non dovresti mai usare questa funzione per mod che non hai sviluppato tu stesso.&#x0a;&#x0a;Sei sicuro di voler continuare?</system:String>

<system:String x:Key="MessageWindow.Warnings.Net7Missing" xml:space="preserve">.NET 7.0 Desktop Runtime non è installato! &#x0a;&#x0a;Vuoi installarlo ora?</system:String>
<system:String x:Key="MessageWindow.Warnings.Net8Missing" xml:space="preserve">The new Mod Manager update requires at least .NET 8.0.7 Desktop Runtime to work.&#x0a;&#x0a;Would you like to install it now?</system:String>
<!--#endregion-->

<!--#region Information-->
Expand Down
1 change: 1 addition & 0 deletions SA-Mod-Manager/Languages/MessageWindow/ko-KR.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
<system:String x:Key="MessageWindow.Warnings.Net7Missing" xml:space="preserve">.NET 7.0 Desktop Runtime is not installed!&#x0a;&#x0a;Would you like to install it now?</system:String>

<system:String x:Key="MessageWindow.Warnings.NewCodeDelete" xml:space="preserve">This will delete all selected codes.&#x0a;&#x0a;Are you sure you want to continue?</system:String>
<system:String x:Key="MessageWindow.Warnings.Net8Missing" xml:space="preserve">The new Mod Manager update requires at least .NET 8.0.7 Desktop Runtime to work.&#x0a;&#x0a;Would you like to install it now?</system:String>
<!--#endregion-->

<!--#region Information-->
Expand Down
4 changes: 2 additions & 2 deletions SA-Mod-Manager/Languages/MessageWindow/pt-BR.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@
<system:String x:Key="MessageWindow.Warnings.GenerateManifest" xml:space="preserve">Isto pode fazer com que DADOS DE USÚARIO DO MOD (ARQUIVOS DE SAVE [JOGO SALVO], ARQUIVOS DE CONFIGURAÇÃO) SEJAM PERDIDOS na próxima atualização! Para prevenir isto, nunca execute isto em mods que você não desenvolveu.&#x0a;&#x0a;Você tem certeza que deseja continuar?</system:String>

<system:String x:Key="MessageWindow.Warnings.Net7Missing" xml:space="preserve">O Runtime do .NET 7.0 Desktop não está instalado!&#x0a;&#x0a;Você deseja instalar ele agora?</system:String>

<!--#endregion-->
<system:String x:Key="MessageWindow.Warnings.Net8Missing" xml:space="preserve">The new Mod Manager update requires at least .NET 8.0.7 Desktop Runtime to work.&#x0a;&#x0a;Would you like to install it now?</system:String>
<!--#endregion-->

<!--#region Information-->
<system:String x:Key="MessageWindow.Information.NoAvailableUpdates.Title">Nenhuma Atualização de Mod Encontrada</system:String>
Expand Down
4 changes: 2 additions & 2 deletions SA-Mod-Manager/Languages/MessageWindow/pt-PT.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@
<system:String x:Key="MessageWindow.Warnings.GenerateManifest" xml:space="preserve">Isto pode causar com que MOD USER DATA (SAVE FILES, CONFIG FILES) SEJAM PERDIDOS após a próxima atualização! Para evitar, Nunca deverá executar o manifesto em mods que não foram desenvolvidos pelo usuário.&#x0a;&#x0a;Tem a certeza que deseja continuar?</system:String>

<system:String x:Key="MessageWindow.Warnings.Net7Missing" xml:space="preserve">.NET 7.0 Desktop Runtime não está instalado!&#x0a;&#x0a;Gostaria de istalar agora?</system:String>

<!--#endregion-->
<system:String x:Key="MessageWindow.Warnings.Net8Missing" xml:space="preserve">The new Mod Manager update requires at least .NET 8.0.7 Desktop Runtime to work.&#x0a;&#x0a;Would you like to install it now?</system:String>
<!--#endregion-->

<!--#region Information-->
<system:String x:Key="MessageWindow.Information.NoAvailableUpdates.Title">Não foram encontradas Autalizações de Mods</system:String>
Expand Down
1 change: 1 addition & 0 deletions SA-Mod-Manager/Languages/MessageWindow/ru-RU.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
<system:String x:Key="MessageWindow.Warnings.ProfileMigration.Title" xml:space="preserve">Ошибка при импорте</system:String>
<system:String x:Key="MessageWindow.Warnings.ProfileMigration.Message1" xml:space="preserve">Указанные файлы не были импортированы как профили:</system:String>
<system:String x:Key="MessageWindow.Warnings.ProfileMigration.Message2" xml:space="preserve">&#x0a;&#x0a;Убедитесь, что используете только файлы профилей в JSON или файлы в INI старого загрузчика.</system:String>
<system:String x:Key="MessageWindow.Warnings.Net8Missing" xml:space="preserve">The new Mod Manager update requires at least .NET 8.0.7 Desktop Runtime to work.&#x0a;&#x0a;Would you like to install it now?</system:String>
<!--#endregion-->

<!--#region Information-->
Expand Down
2 changes: 2 additions & 0 deletions SA-Mod-Manager/Languages/MessageWindow/uk-UA.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
<system:String x:Key="MessageWindow.Errors.PermissionTitle">Access Denied</system:String>
<system:String x:Key="MessageWindow.Errors.FolderPermission" xml:space="preserve">Failed to create directory, the program does not have the authorization to write at this path: {0}&#x0a;&#x0a;Please restart the Manager with Administrator Privileges.</system:String>
<system:String x:Key="MessageWindow.Errors.GameNoLongerFound" xml:space="preserve">Failed to find the game path of {0} at {1}&#x0a;If you have moved your game directory to a different location, please re set the game path in the Manager Config tab.</system:String>

<!--#endregion-->

<!--#region Warnings-->
Expand Down Expand Up @@ -133,6 +134,7 @@
<system:String x:Key="MessageWindow.Warnings.ProfileMigration.Title" xml:space="preserve">Помилка Імпортування</system:String>
<system:String x:Key="MessageWindow.Warnings.ProfileMigration.Message1" xml:space="preserve">Наступні файли не вдалося імпортувати як профілі:</system:String>
<system:String x:Key="MessageWindow.Warnings.ProfileMigration.Message2" xml:space="preserve">&#x0a;&#x0a;впевніться що ви використовуєте тільки JSON файли або INI файли старого завантажувача модів.</system:String>
<system:String x:Key="MessageWindow.Warnings.Net8Missing" xml:space="preserve">The new Mod Manager update requires at least .NET 8.0.7 Desktop Runtime to work.&#x0a;&#x0a;Would you like to install it now?</system:String>
<!--#endregion-->

<!--#region Information-->
Expand Down
53 changes: 49 additions & 4 deletions SA-Mod-Manager/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
using System.IO.Compression;
using Microsoft.Win32;
using System.Security.Principal;
using System.Security.AccessControl;
using System.Reflection;
using NetCoreInstallChecker.Structs.Config;
using NetCoreInstallChecker;
using NetCoreInstallChecker.Structs.Config.Enum;

namespace SAModManager
{
Expand Down Expand Up @@ -297,7 +299,7 @@ await Application.Current.Dispatcher.InvokeAsync(() =>
{
new DownloadInfo("7-zip", "7z.exe", App.tempFolder, uri, DownloadDialog.DLType.Download)
};

var dl = new DownloadDialog(info);
dl.StartDL();
}
Expand Down Expand Up @@ -515,7 +517,7 @@ public static void MoveDirectory(string sourcePath, string destinationPath)
{

CreateSafeDirectory(destinationPath);

foreach (string file in Directory.GetFiles(sourcePath))
{
string destFile = Path.Combine(destinationPath, Path.GetFileName(file));
Expand Down Expand Up @@ -570,6 +572,49 @@ public static bool MoveAllFilesAndSubfolders(string sourceFolderPath, string des
return true;
}

public static async Task<bool> Net8Check()
{
var finder = new FrameworkFinder(Environment.Is64BitOperatingSystem);
var resolver = new DependencyResolver(finder);
var framework = new Framework("Microsoft.WindowsDesktop.App", "8.0.7");
var options = new RuntimeOptions("net8.0", framework, RollForwardPolicy.Minor);
var result = resolver.Resolve(options);

if (!result.Available)
{
var res = new MessageWindow(Lang.GetString("MessageWindow.DefaultTitle.Warning"), Lang.GetString("MessageWindow.Warnings.Net8Missing"), MessageWindow.WindowType.IconMessage, MessageWindow.Icons.Warning, MessageWindow.Buttons.YesNo);
res.ShowDialog();

if (res.isYes != true)
{
return false;
}

FrameworkDownloader frameworkDownloader = new(framework.NuGetVersion, framework.FrameworkName);
var url = await frameworkDownloader.GetDownloadUrlAsync(Environment.Is64BitOperatingSystem ? Architecture.Amd64 : Architecture.x86);
Uri uri = new(url + "\r\n");

if (url != null)
{
string name = "aspnetcore-runtime-8.0.exe";
string fullPath = Path.GetFullPath(Path.Combine(App.tempFolder, name));
var netDL = new List<DownloadInfo>
{
new("Net Core 8.0", name, App.tempFolder, uri, DownloadDialog.DLType.Download)
};
var DL = new DownloadDialog(netDL);
DL.StartDL();

if (File.Exists(fullPath))
Process.Start(fullPath);
}

return false;
}

return true;
}

private static string CombinePathURL(params string[] paths)
{
return string.Join("/", paths);
Expand Down Expand Up @@ -654,7 +699,7 @@ public static void CreateSafeDirectory(string path)
{
try
{
if (!string.IsNullOrEmpty(path) &&!Directory.Exists(path))
if (!string.IsNullOrEmpty(path) && !Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
Expand Down

0 comments on commit cc3ac2c

Please sign in to comment.