コード例 #1
0
        public async Task Handle(InstallOptions options)
        {
            foreach (var fullName in options.PackageFullNames)
            {
                var path    = fullName;
                var appInfo = AppInfo.FromPath(path);

                CheckExistingInstallation(appInfo);

                Log.Information("Installing application {FullAppName}.", appInfo.ToString());
                await _nugetPackageInstaller.Install(appInfo);

                Log.Information("Application {FullAppName} successfully installed.", appInfo.ToString());

                var binPath = _appsManager.GetExecutablePath(appInfo);

                _systemServiceManager.Create(appInfo, binPath);
            }
        }
コード例 #2
0
        public Task Handle(UninstallOptions options)
        {
            foreach (var fullName in options.PackageFullNames)
            {
                var appInfo = AppInfo.FromPath(fullName);

                var installDirectoryPath = Path.GetFullPath(_appSettings.InstallDirectoryPath);

                var appDirectoryPath = Path.Combine(installDirectoryPath, fullName);

                try
                {
                    Log.Information("Deleting application {PackageId} {Version}", appInfo.PackageId, appInfo.Version);

                    try
                    {
                        _systemServiceManager.Stop(appInfo);
                    }
                    catch (Exception)
                    {
                        // ignored
                    }


                    if (Directory.Exists(appDirectoryPath))
                    {
                        Directory.Delete(appDirectoryPath, true);
                    }

                    _systemServiceManager.Delete(appInfo);
                }
                catch (Exception e)
                {
                    Log.Logger.Error(e, "Uninstall command executed with error.");
                }
            }

            return(Task.CompletedTask);
        }