private void StopApp(AppInfo appInfo)
        {
            var appPath = Path.Combine(_appSettings.InstallDirectoryPath, appInfo.ToString());

            if (Directory.Exists(appPath) && Directory.EnumerateFileSystemEntries(appPath).Any())
            {
                _systemServiceManager.Stop(appInfo);
            }
            else
            {
                Log.Information("Directory {AppPath} is empty.", appPath);
            }
        }
        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);
        }