public async Task<bool> ZipFilesAsync(string[] files, string outputFile, Manifest manifest) { var manifestJson = JsonConvert.SerializeObject(manifest); var tempManifestFile = $"{Path.GetTempPath()}{Manifest.ManifestFileName}"; if (File.Exists(tempManifestFile)) { File.Delete(tempManifestFile); } File.WriteAllText(tempManifestFile, manifestJson); var tcs = new TaskCompletionSource<bool>(); await Task.Run(() => { try { using (var zipFile = new ZipFile()) { zipFile.AddFile(tempManifestFile, ""); zipFile.AddFiles(files, false, ""); zipFile.Save(outputFile); } File.Delete(tempManifestFile); tcs.SetResult(true); } catch { tcs.SetResult(false); } }); return await tcs.Task; }
public ManifestViewModel(Manifest manifest) { _manifest = manifest; Name = _manifest.Name; Author = _manifest.Author; ProjectUrl = _manifest.ProjectUrl; TermsUrl = _manifest.TermsUrl; Version = _manifest.Version; TargetWriterVersion = _manifest.TargetWriterVersion; PluginFileName = _manifest.PluginFileName; Messenger.Default.Register<NotificationMessage>(this, m => { if (m.Notification.Equals(AppHelper.SetPluginFileMsg)) { var file = m.Sender as FileViewModel; _manifest.PluginFileName = file?.Name; _manifest.PluginPath = file?.Path; } }); }