private void btnGo_Click(object sender, RoutedEventArgs e) { try { txtProgressLog.Text = "starting...\n"; CabLib.Extract extractor = new CabLib.Extract(); CabLib.Compress compressor = new CabLib.Compress(); CabLib.Extract.kHeaderInfo cInfo = null; if (extractor.IsFileCabinet(txtFilePath.Text, out cInfo)) { Log("file is a valid cabinet"); //extract WSP to temp folder Guid jobGuid = Guid.NewGuid(); string jobid = jobGuid.ToString("N"); Log("current job id is " + jobid); var fi = new FileInfo(txtFilePath.Text); var jobFolder = Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\" + jobid); Log("job temp directory created"); extractor.ExtractFile(txtFilePath.Text, jobFolder.FullName); Log("cabinet exatracted to job temp directory"); //Load manifest, change solution ID, remove assemblies, etc XDocument xDoc = XDocument.Load(jobFolder.FullName + "\\manifest.xml"); Log("manifest loaded"); if (chkSetNewSolutionId.IsChecked.Value) { xDoc.Root.Attribute("SolutionId").Value = jobGuid.ToString("D"); Log("solution id set to " + jobGuid.ToString("D")); } if (chkRemoveAllDlls.IsChecked.Value) { var xAssemblies = xDoc.Root.Descendants(xDoc.Root.GetDefaultNamespace() + "Assemblies"); xAssemblies.Remove(); Log("assemblies element removed from manifest"); jobFolder.EnumerateFiles("*.dll").ToList().ForEach(dll => { File.SetAttributes(dll.FullName, FileAttributes.Normal); File.Delete(dll.FullName); }); Log("all dll files deleted"); } xDoc.Save(jobFolder.FullName + "\\manifest.xml"); Log("updated manifest file saved"); //repackage as a new WSP or overwrite source file string wspFileName = txtNewFileName.Text.Replace("{filename}", fi.Name.Remove(fi.Name.Length - 4)) + ".wsp"; Log("new wsp file name is " + wspFileName); //Build Dictionary<string,string> for all cab files DDFBuilder.Build(jobFolder.FullName, wspFileName); Log("ddf file built"); compressor.SwitchCompression(CabLib.Compress.eCompress.MSZIP); compressor.CompressFolder(jobFolder.FullName, fi.Directory.FullName + "\\" + wspFileName, null, true, true, int.MaxValue); Log("cabinet file craeted"); jobFolder.EnumerateFiles("*.*", SearchOption.AllDirectories).ToList().ForEach(dll => { File.SetAttributes(dll.FullName, FileAttributes.Normal); }); System.IO.Directory.Delete(jobFolder.FullName, true); Log("temp job folder deleted"); Log("i'm done. what's next?"); } } catch (Exception ex) { Log("oops! something went wrong, " + ex.ToString()); } }