From 1b14fe2e57ae3051fe03c7dc3be7b54be1386d05 Mon Sep 17 00:00:00 2001 From: WeeXnes Date: Tue, 13 Dec 2022 11:44:11 +0100 Subject: [PATCH] Rewrote Updater and Removed Compiler Warnings --- Update/Program.cs | 88 ------------------------------- Update/Properties/AssemblyInfo.cs | 34 +++++++++--- Update/Update.csproj | 62 ++++++++++++++++------ WeeXnes.sln | 10 ++-- WeeXnes/App.xaml.cs | 21 ++++++++ WeeXnes/Core/Global.cs | 2 +- WeeXnes/Core/WXFile.cs | 2 + WeeXnes/MainWindow.xaml.cs | 12 ----- WeeXnes/WeeXnes.csproj | 2 +- 9 files changed, 103 insertions(+), 130 deletions(-) delete mode 100644 Update/Program.cs diff --git a/Update/Program.cs b/Update/Program.cs deleted file mode 100644 index 384f586..0000000 --- a/Update/Program.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.IO.Compression; - -namespace Update -{ - internal class Program - { - public static bool keepWindowOpen = false; - public static void Main(string[] args) - { - Console.WriteLine("Path: " + args[0]); - Console.WriteLine("FileName: " + args[1]); - Console.WriteLine("PID: " + args[2]); - Console.WriteLine("New File: " + args[3]); - Process p = Process.GetProcessById(Convert.ToInt32(args[2])); - p.Kill(); - p.WaitForExit(); - try - { - ZipArchiveHelper.ExtractToDirectory(args[3], args[0], true); - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - ZipArchiveHelper.ExtractToDirectory(args[3], args[0], true); - } - Process.Start(args[0] + "\\" + args[1]); - if (File.Exists(args[3])) - { - File.Delete(args[3]); - } - - if (keepWindowOpen) - { - Console.WriteLine("Window kept open to see error message, press enter to continue"); - Console.ReadLine(); - } - - } - } - public static class ZipArchiveHelper - { - public static void ExtractToDirectory(string archiveFileName, string destinationDirectoryName, bool overwrite) - { - if (!overwrite) - { - ZipFile.ExtractToDirectory(archiveFileName, destinationDirectoryName); - } - else - { - using (var archive = ZipFile.OpenRead(archiveFileName)) - { - - foreach (var file in archive.Entries) - { - try - { - var completeFileName = Path.Combine(destinationDirectoryName, file.FullName); - var directory = Path.GetDirectoryName(completeFileName); - - if (!Directory.Exists(directory) && !string.IsNullOrEmpty(directory)) - Directory.CreateDirectory(directory); - - if (file.Name != "") - file.ExtractToFile(completeFileName, true); - } - catch (IOException ex) - { - if (file.FullName == "Update.exe") - { - - } - else - { - Console.WriteLine(ex.ToString()); - Console.WriteLine(file.FullName + " couldnt be overwritten, an error has occured"); - Program.keepWindowOpen = true; - } - } - } - - } - } - } - } -} \ No newline at end of file diff --git a/Update/Properties/AssemblyInfo.cs b/Update/Properties/AssemblyInfo.cs index ee59963..ef4f138 100644 --- a/Update/Properties/AssemblyInfo.cs +++ b/Update/Properties/AssemblyInfo.cs @@ -1,7 +1,10 @@ using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Windows; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Update")] @@ -13,22 +16,39 @@ using System.Runtime.InteropServices; [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("6F2F689B-F4E3-4204-BA72-624BE46020AD")] +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Build and Revision Numbers +// You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] diff --git a/Update/Update.csproj b/Update/Update.csproj index 6886dde..7900e0c 100644 --- a/Update/Update.csproj +++ b/Update/Update.csproj @@ -1,16 +1,17 @@  - + Debug AnyCPU - {6F2F689B-F4E3-4204-BA72-624BE46020AD} - Exe - Properties + {133FF515-D605-4856-BA2E-5841BF47EC2F} + WinExe Update Update - v4.8 + v4.8.1 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 true @@ -39,18 +40,47 @@ + + 4.0 + + + + - - + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + - - - + \ No newline at end of file diff --git a/WeeXnes.sln b/WeeXnes.sln index 6e2fc20..ab20f29 100644 --- a/WeeXnes.sln +++ b/WeeXnes.sln @@ -8,7 +8,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeeXnes_UAC", "WeeXnes_UAC\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Release_Tool", "Release_Tool\Release_Tool.csproj", "{4C09AD12-B48E-40ED-B418-CF868889E317}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Update", "Update\Update.csproj", "{6F2F689B-F4E3-4204-BA72-624BE46020AD}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Update", "Update\Update.csproj", "{133FF515-D605-4856-BA2E-5841BF47EC2F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -32,9 +32,9 @@ Global {4C09AD12-B48E-40ED-B418-CF868889E317}.Debug|Any CPU.Build.0 = Debug|Any CPU {4C09AD12-B48E-40ED-B418-CF868889E317}.Release|Any CPU.ActiveCfg = Release|Any CPU {4C09AD12-B48E-40ED-B418-CF868889E317}.Release|Any CPU.Build.0 = Release|Any CPU - {6F2F689B-F4E3-4204-BA72-624BE46020AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6F2F689B-F4E3-4204-BA72-624BE46020AD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6F2F689B-F4E3-4204-BA72-624BE46020AD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6F2F689B-F4E3-4204-BA72-624BE46020AD}.Release|Any CPU.Build.0 = Release|Any CPU + {133FF515-D605-4856-BA2E-5841BF47EC2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {133FF515-D605-4856-BA2E-5841BF47EC2F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {133FF515-D605-4856-BA2E-5841BF47EC2F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {133FF515-D605-4856-BA2E-5841BF47EC2F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/WeeXnes/App.xaml.cs b/WeeXnes/App.xaml.cs index 383dc18..c858279 100644 --- a/WeeXnes/App.xaml.cs +++ b/WeeXnes/App.xaml.cs @@ -21,6 +21,7 @@ namespace WeeXnes { Environment.CurrentDirectory = Application.StartupPath; CheckForDebugMode(); + CheckUpdatedFiles(); CheckForFolder(); LoadSettings(); SaveSettingsHandler.SetupSaveEvents(); @@ -28,6 +29,26 @@ namespace WeeXnes CheckStartupArgs(e.Args); } + private void CheckUpdatedFiles() + { + string[] files = System.IO.Directory.GetFiles(Environment.CurrentDirectory, "*.new"); + foreach (string file in files) + { + try + { + string originalFile = file.Substring(0, file + .Length - 4); + if (File.Exists(originalFile)) + File.Delete(originalFile); + System.IO.File.Move(file, originalFile); + } + catch (Exception ex) + { + Console.WriteLine(ex); + } + } + } + private void LoadSettings() { if(!File.Exists(Path.Combine(Global.AppDataPath, Global.SettingsFile))) diff --git a/WeeXnes/Core/Global.cs b/WeeXnes/Core/Global.cs index 072c18f..68c11c7 100644 --- a/WeeXnes/Core/Global.cs +++ b/WeeXnes/Core/Global.cs @@ -6,7 +6,7 @@ namespace WeeXnes.Core { public class Information { - public const string Version = "4.0.4"; + public const string Version = "4.0.5"; public const string EncryptionHash = "8zf5#RdyQ]$4x4_"; public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest"; } diff --git a/WeeXnes/Core/WXFile.cs b/WeeXnes/Core/WXFile.cs index 5f22ad3..cfa16cf 100644 --- a/WeeXnes/Core/WXFile.cs +++ b/WeeXnes/Core/WXFile.cs @@ -29,6 +29,7 @@ namespace WeeXnes.Core } catch (Exception e) { + Console.WriteLine(e); returnval = null; } } @@ -47,6 +48,7 @@ namespace WeeXnes.Core returnval = rawcontent[2]; }catch (Exception e) { + Console.WriteLine(e); returnval = null; } } diff --git a/WeeXnes/MainWindow.xaml.cs b/WeeXnes/MainWindow.xaml.cs index 5105404..48cdf55 100644 --- a/WeeXnes/MainWindow.xaml.cs +++ b/WeeXnes/MainWindow.xaml.cs @@ -1,19 +1,7 @@ using System; using System.Windows; -using System.Windows.Controls; -using System.ComponentModel; -using System.IO; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Forms; -using System.Windows.Input; -using System.Windows.Media; using WeeXnes.Core; -using WeeXnes.Views.DiscordRPC; -using Wpf.Ui.Mvvm.Services; -using Button = System.Windows.Controls.Button; using ButtonBase = System.Windows.Controls.Primitives.ButtonBase; -using MessageBox = System.Windows.MessageBox; using NotifyIcon = Wpf.Ui.Controls.NotifyIcon; namespace WeeXnes diff --git a/WeeXnes/WeeXnes.csproj b/WeeXnes/WeeXnes.csproj index 6db1329..4bc040b 100644 --- a/WeeXnes/WeeXnes.csproj +++ b/WeeXnes/WeeXnes.csproj @@ -4,7 +4,7 @@ Debug AnyCPU - 4.0.4 + 4.0.5 {4B33CEE7-C74D-43B9-B99A-8B273D5195BC} WinExe WeeXnes