public void CreateCabFile() { // // Determine whether we're adding JetCanvas.xml to the jetproj file for the first time // If so, make the necessary call to AddItem() // if (false == this.jetCavasXmlExists) { this.AddItem("JetCanvas.xml", this.ProjectLocation, ProjectItemType.CanvasXml); this.jetCavasXmlExists = true; } // Always generate a fresh JetCanvas.xml when building cab this.canvas.GenerateXML(); // // Pack all ProjectItems into the CAB file // CabInfo cabInfo = new CabInfo(this.ProjectLocation + "\\" + "JetPak.cab"); List <string> filesToPack = new List <string>(); foreach (ProjectItem projectItem in this.listProjectItems) { filesToPack.Add(this.ProjectLocation + "\\" + projectItem.ItemName); } cabInfo.PackFiles(null, filesToPack, null); }
/// <summary> /// Create an AAPKG file from a source directory /// </summary> /// <param name="SourceDirectory"></param> /// <param name="AAPKGFilename"></param> public void CreateAAPKG(string SourceDirectory, string AAPKGFilename, Microsoft.Deployment.Compression.CompressionLevel CompressionLevel = Microsoft.Deployment.Compression.CompressionLevel.Normal) { string file1Path; try { log.Debug(""); file1Path = Path.GetTempPath() + "file1.cab"; // Create the File1.cab file from the directory containing all of the source files CabInfo ci = new CabInfo(file1Path); ci.Pack(SourceDirectory, true, CompressionLevel, null); //Now create a string list of just the File1.cab file and compress this to the final aapkg file List <String> SourceFiles = new List <String>(); SourceFiles.Add(file1Path); CabInfo ciAAPKG = new CabInfo(AAPKGFilename); ciAAPKG.PackFiles(null, SourceFiles, null, CompressionLevel, null); } catch { throw; } }
public static string GetKeyedWsp(string wspFile, string company, string servers, DateTime expiry) { Guid transGuid = new Guid(); //hax: config me string baseDir = @"D:\Hosting\5709750\html\sprockettools\d\"; string source = baseDir + @"original\" + transGuid.ToString() + @"\"; string dest = baseDir + @"modified\"; //load the cab and unpack it to the temporary directory used for this transaction CabInfo cab = new CabInfo(baseDir + wspFile); cab.Unpack(source); //get xml file string keyXmlFile = source + @"Layouts\SprocketValidator\key.xml"; XmlDocument xd = new XmlDocument(); xd.Load(keyXmlFile); //update XML file and write back to disk XmlNode n = xd.SelectSingleNode(@"/key"); n.InnerText = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(company + "|" + servers + "|" + DateTime.Today.AddDays(14).ToShortDateString())); using (XmlWriter xw = XmlWriter.Create(keyXmlFile)) { xd.WriteTo(xw); xw.Flush(); } //create a list with files and add them to a cab file string newFile = (dest + DateTime.Now.ToString("yyyyMMdd") + "_" + company + "_" + wspFile).Replace(" ", ""); CabInfo newCab = new CabInfo(newFile); List <string> paths = new List <string>(); //put files into list to be packed foreach (string compFile in Directory.GetFiles(source, "*", SearchOption.AllDirectories)) { paths.Add(compFile.Replace(source, "")); } newCab.PackFiles(source, paths, paths); //delete the transaction directory Directory.Delete(source, true); return(newFile); }