Ejemplo n.º 1
0
        /// <summary>
        /// Get the root app directory using the Squirrel manager.
        /// </summary>
        /// <returns></returns>
        private static string GetRootAppDirectory()
        {
            var appName        = SquirrelHelper.GetAppName();
            var updateLocation = SquirrelHelper.GetUpdateLocation();

            using (var mgr = new UpdateManager(updateLocation, appName, FrameworkVersion.Net45))
            {
                return(mgr.RootAppDirectory);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This code has to exist in order for Squirrel to work its magic.
        /// What it does, is hook methods to the install/uninstall events.
        /// Basic functionality includes: Create and remove shortcut upon install/uninstall,
        /// as well as when updating.
        /// </summary>
        public static void CustomSquirrelSetup()
        {
            var appName        = SquirrelHelper.GetAppName();
            var updateLocation = SquirrelHelper.GetUpdateLocation();

            using (var mgr = new UpdateManager(updateLocation, appName, FrameworkVersion.Net45))
            {
                SquirrelAwareApp.HandleEvents(
                    onInitialInstall: v =>
                {
                    _log.Warn(Utilities.GetCallerName() + ": Installation in progress.");

                    CreateOrUpdateCustomRegistryEntries(mgr.RootAppDirectory);
                    RegisterShellExtension(mgr.RootAppDirectory);
                    mgr.CreateShortcutForThisExe();
                },
                    onAppUpdate: v =>
                {
                    _log.Warn(Utilities.GetCallerName() + ": Update in progress.");

                    mgr.CreateShortcutForThisExe();
                    CreateOrUpdateCustomRegistryEntries(mgr.RootAppDirectory, v.ToString());
                    RegisterShellExtension(mgr.RootAppDirectory);
                },
                    onAppUninstall: v =>
                {
                    _log.Warn(Utilities.GetCallerName() + ": Uninstall in progress.");

                    UnregisterShellExtension(mgr.RootAppDirectory);
                    RemoveCustomRegistryEntries(mgr.RootAppDirectory);
                    mgr.RemoveShortcutForThisExe();
                    StopBigStashOnUninstall();
                    CallBatchDelete(mgr.RootAppDirectory);
                });
            }
        }