Пример #1
0
        string installAppVersion(IAppSetup app, Version newCurrentVersion, IEnumerable <ShortcutCreationRequest> shortcutRequestsToIgnore, bool isFirstInstall)
        {
            try {
                if (isFirstInstall)
                {
                    log.Info("installAppVersion: Doing first install for {0}", app.Target);
                    app.OnAppInstall();
                }
                log.Info("installAppVersion: Doing install for version {0} {1}", newCurrentVersion, app.Target);
                app.OnVersionInstalled(newCurrentVersion);
            } catch (Exception ex) {
                log.ErrorException("App threw exception on install:  " + app.GetType().FullName, ex);
                throw;
            }

            var shortcutList = Enumerable.Empty <ShortcutCreationRequest>();

            try {
                shortcutList = app.GetAppShortcutList();
                shortcutList.ForEach(x =>
                                     log.Info("installAppVersion: we have a shortcut {0}", x.TargetPath));
            } catch (Exception ex) {
                log.ErrorException("App threw exception on shortcut uninstall:  " + app.GetType().FullName, ex);
                throw;
            }

            shortcutList
            .Where(x => !shortcutRequestsToIgnore.Contains(x))
            .ForEach(x => {
                var shortcut = x.GetLinkTarget(applicationName, true);

                var fi = fileSystem.GetFileInfo(shortcut);

                log.Info("installAppVersion: checking shortcut {0}", fi.FullName);

                if (fi.Exists)
                {
                    log.Info("installAppVersion: deleting existing file");
                    fi.Delete();
                }

                fileSystem.CreateDirectoryRecursive(fi.Directory.FullName);

                var sl = new ShellLink {
                    Target           = x.TargetPath,
                    IconPath         = x.IconLibrary,
                    IconIndex        = x.IconIndex,
                    Arguments        = x.Arguments,
                    WorkingDirectory = x.WorkingDirectory,
                    Description      = x.Description,
                };

                sl.Save(shortcut);
            });

            return(app.LaunchOnSetup ? app.Target : null);
        }
Пример #2
0
        void installAppVersion(IAppSetup app, Version newCurrentVersion, IEnumerable <ShortcutCreationRequest> shortcutRequestsToIgnore, bool isFirstInstall)
        {
            try {
                if (isFirstInstall)
                {
                    app.OnAppInstall();
                }
                app.OnVersionInstalled(newCurrentVersion);
            } catch (Exception ex) {
                this.Log().ErrorException("App threw exception on install:  " + app.GetType().FullName, ex);
                throw;
            }

            var shortcutList = Enumerable.Empty <ShortcutCreationRequest>();

            try {
                shortcutList = app.GetAppShortcutList();
            } catch (Exception ex) {
                this.Log().ErrorException("App threw exception on shortcut uninstall:  " + app.GetType().FullName, ex);
                throw;
            }

            shortcutList
            .Where(x => !shortcutRequestsToIgnore.Contains(x))
            .ForEach(x => {
                var shortcut = x.GetLinkTarget(applicationName, true);

                var fi = fileSystem.GetFileInfo(shortcut);
                if (fi.Exists)
                {
                    fi.Delete();
                }

                fileSystem.CreateDirectoryRecursive(fi.Directory.FullName);

                var sl = new ShellLink()
                {
                    Target           = x.TargetPath,
                    IconPath         = x.IconLibrary,
                    IconIndex        = x.IconIndex,
                    Arguments        = x.Arguments,
                    WorkingDirectory = x.WorkingDirectory,
                    Description      = x.Description
                };

                sl.Save(shortcut);
            });
        }