From 0d309ee1aa8dea38b7c263808c66032aab7138a6 Mon Sep 17 00:00:00 2001 From: Matthias Lischka Date: Thu, 31 Aug 2017 22:23:25 +0200 Subject: [PATCH] Squirrel Installer --- StartLauncher.App/App.config | 20 +++-- StartLauncher.App/App.xaml | 4 +- StartLauncher.App/App.xaml.cs | 48 ++++++++++++ StartLauncher.App/Properties/AssemblyInfo.cs | 2 +- .../Properties/Resources.Designer.cs | 2 +- .../Properties/Settings.Designer.cs | 2 +- StartLauncher.App/StartLauncher.App.csproj | 74 ++++++++++++++++--- StartLauncher.App/StartLauncher.nuspec | 16 ++++ StartLauncher.App/packages.config | 12 ++- .../StartLauncher.Tests.csproj | 16 ++-- StartLauncher.Tests/app.config | 11 +++ StartLauncher.Tests/packages.config | 4 +- 12 files changed, 176 insertions(+), 35 deletions(-) create mode 100644 StartLauncher.App/StartLauncher.nuspec create mode 100644 StartLauncher.Tests/app.config diff --git a/StartLauncher.App/App.config b/StartLauncher.App/App.config index 5bdafc5..4f6f5d3 100644 --- a/StartLauncher.App/App.config +++ b/StartLauncher.App/App.config @@ -1,18 +1,26 @@ - + - -
+ +
- + - + - \ No newline at end of file + + + + + + + + + diff --git a/StartLauncher.App/App.xaml b/StartLauncher.App/App.xaml index 71e422d..4adae69 100644 --- a/StartLauncher.App/App.xaml +++ b/StartLauncher.App/App.xaml @@ -1,6 +1,8 @@  + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + DispatcherUnhandledException="Application_DispatcherUnhandledException" + Exit="App_OnExit"> diff --git a/StartLauncher.App/App.xaml.cs b/StartLauncher.App/App.xaml.cs index af32a9c..532d24c 100644 --- a/StartLauncher.App/App.xaml.cs +++ b/StartLauncher.App/App.xaml.cs @@ -1,8 +1,13 @@ using System; +using System.IO; +using System.Linq; +using System.Reflection; using System.Threading; +using System.Threading.Tasks; using System.Windows; using System.Windows.Threading; using Autofac; +using Squirrel; using StartLauncher.App.DataAccess; using StartLauncher.App.ViewModels; using StartLauncher.App.Views; @@ -11,6 +16,7 @@ namespace StartLauncher.App { public partial class App { + public static ManualResetEvent UpdateCheckResetEvent = new ManualResetEvent(false); private static readonly Mutex SingleInstanceApplicationMutex = new Mutex(true, "{333499E4-B949-48F2-8C7C-6DFBF11ED9E1}"); @@ -41,6 +47,9 @@ private void EnsureApplicationRunsJustOnce() [STAThread] public static void Main() { + EnsureAppUpToDate().ContinueWith(t => Console.Error.WriteLine(t.Exception), + TaskContinuationOptions.OnlyOnFaulted); + var appContainerBuilder = new AppContainerBuilder(); var appContainer = appContainerBuilder.Build(); var application = appContainer.Resolve(); @@ -62,6 +71,40 @@ protected override void OnStartup(StartupEventArgs e) _executablesAccessor.EnsureCommands(); } + private static async Task EnsureAppUpToDate() + { + var assembly = Assembly.GetEntryAssembly(); + var updateDotExe = Path.Combine(Path.GetDirectoryName(assembly.Location), "..", "Update.exe"); + var isInstalled = File.Exists(updateDotExe); + + //so you can run app from Dev Environment + if (!isInstalled) + return; + + var updated = false; + + using (var mgr = UpdateManager + .GitHubUpdateManager("https://github.com/matthiaslischka/StartLauncher").Result) + { + var updateInfo = await mgr.CheckForUpdate(); + if (updateInfo.ReleasesToApply.Any()) + { + System.Console.Out.WriteLine($"Found Update {updateInfo.FutureReleaseEntry.Version}."); + await mgr.UpdateApp(i => System.Console.Out.WriteLine($"Updating: {i}")); + System.Console.Out.WriteLine("Update Finished."); + updated = true; + } + } + + if (updated) + { + System.Console.Out.WriteLine("Restarting to launch new Version."); + UpdateManager.RestartApp(); + } + + UpdateCheckResetEvent.Set(); + } + private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { MessageBox.Show( @@ -71,5 +114,10 @@ private void Application_DispatcherUnhandledException(object sender, DispatcherU e.Handled = true; Current.Shutdown(); } + + private void App_OnExit(object sender, ExitEventArgs e) + { + UpdateCheckResetEvent.WaitOne(); + } } } \ No newline at end of file diff --git a/StartLauncher.App/Properties/AssemblyInfo.cs b/StartLauncher.App/Properties/AssemblyInfo.cs index b3e3a22..0f99b58 100644 --- a/StartLauncher.App/Properties/AssemblyInfo.cs +++ b/StartLauncher.App/Properties/AssemblyInfo.cs @@ -4,7 +4,7 @@ using System.Windows; [assembly: AssemblyTitle("Start Launcher")] -[assembly: AssemblyDescription("A very lightweight launcher that uses the Windows Start Menu for custom commands.")] +[assembly: AssemblyDescription("A very lightweight launcher that enhances the Windows Start Menu with custom commands")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Start Launcher")] diff --git a/StartLauncher.App/Properties/Resources.Designer.cs b/StartLauncher.App/Properties/Resources.Designer.cs index a0486e4..364a31c 100644 --- a/StartLauncher.App/Properties/Resources.Designer.cs +++ b/StartLauncher.App/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace StartLauncher.App.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Resources { diff --git a/StartLauncher.App/Properties/Settings.Designer.cs b/StartLauncher.App/Properties/Settings.Designer.cs index 07a5888..dd9d6ba 100644 --- a/StartLauncher.App/Properties/Settings.Designer.cs +++ b/StartLauncher.App/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace StartLauncher.App.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/StartLauncher.App/StartLauncher.App.csproj b/StartLauncher.App/StartLauncher.App.csproj index 2b23e8c..a15cc96 100644 --- a/StartLauncher.App/StartLauncher.App.csproj +++ b/StartLauncher.App/StartLauncher.App.csproj @@ -16,6 +16,7 @@ true + AnyCPU @@ -59,28 +60,58 @@ StartLauncher.App.App - - ..\packages\Autofac.4.2.1\lib\net45\Autofac.dll - True + + ..\packages\Autofac.4.6.1\lib\net45\Autofac.dll + + + ..\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.dll + + + ..\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.MsDelta.dll + + + ..\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.PatchApi.dll ..\packages\FluentOptionals.1.1.10.65\lib\net40\FluentOptionals.dll True - - ..\packages\MahApps.Metro.1.3.0\lib\net45\MahApps.Metro.dll - True + + ..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - True + + ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.dll + + + ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.Mdb.dll + + + ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.Pdb.dll + + + ..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.Rocks.dll + + + ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + + + ..\packages\squirrel.windows.1.7.8\lib\Net45\NuGet.Squirrel.dll + + + ..\packages\SharpCompress.0.18.1\lib\net45\SharpCompress.dll + + + ..\packages\Splat.2.0.0\lib\Net45\Splat.dll + + + ..\packages\squirrel.windows.1.7.8\lib\Net45\Squirrel.dll - ..\packages\MahApps.Metro.1.3.0\lib\net45\System.Windows.Interactivity.dll + ..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll True @@ -152,12 +183,15 @@ Designer Resources.Designer.cs - + + Designer + SettingsSingleFileGenerator Settings.Designer.cs + @@ -204,4 +238,22 @@ --> + + + False + + + False + + + + + + + + + + + + \ No newline at end of file diff --git a/StartLauncher.App/StartLauncher.nuspec b/StartLauncher.App/StartLauncher.nuspec new file mode 100644 index 0000000..0edb6eb --- /dev/null +++ b/StartLauncher.App/StartLauncher.nuspec @@ -0,0 +1,16 @@ + + + + StartLauncher + Start Launcher + + 0.0.0.0 + A very lightweight launcher that enhances the Windows Start Menu with custom commands + matthiaslischka + https://github.com/matthiaslischka/StartLauncher + + + + + + \ No newline at end of file diff --git a/StartLauncher.App/packages.config b/StartLauncher.App/packages.config index c239739..4f94c34 100644 --- a/StartLauncher.App/packages.config +++ b/StartLauncher.App/packages.config @@ -1,8 +1,14 @@  - + + - - + + + + + + + \ No newline at end of file diff --git a/StartLauncher.Tests/StartLauncher.Tests.csproj b/StartLauncher.Tests/StartLauncher.Tests.csproj index b64d5de..dd38b2d 100644 --- a/StartLauncher.Tests/StartLauncher.Tests.csproj +++ b/StartLauncher.Tests/StartLauncher.Tests.csproj @@ -35,17 +35,14 @@ 4 - - ..\packages\Autofac.4.2.1\lib\net45\Autofac.dll - True + + ..\packages\Autofac.4.6.1\lib\net45\Autofac.dll - - ..\packages\FluentAssertions.4.17.0\lib\net45\FluentAssertions.dll - True + + ..\packages\FluentAssertions.4.19.4\lib\net45\FluentAssertions.dll - - ..\packages\FluentAssertions.4.17.0\lib\net45\FluentAssertions.Core.dll - True + + ..\packages\FluentAssertions.4.19.4\lib\net45\FluentAssertions.Core.dll ..\packages\FluentOptionals.1.1.10.65\lib\net40\FluentOptionals.dll @@ -82,6 +79,7 @@ + diff --git a/StartLauncher.Tests/app.config b/StartLauncher.Tests/app.config new file mode 100644 index 0000000..6a83805 --- /dev/null +++ b/StartLauncher.Tests/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/StartLauncher.Tests/packages.config b/StartLauncher.Tests/packages.config index 4f11bf5..21db100 100644 --- a/StartLauncher.Tests/packages.config +++ b/StartLauncher.Tests/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file