private static void UpdateXapFiles(string websiteTargetPath, string sevenZip, string configBackupPath) { Display.Header("Updating Xap files"); FileManagement.RenameFile(websiteTargetPath + "\\ClientBin\\*.xap", websiteTargetPath + "\\ClientBin\\*.zip"); Display.Output("Xaps renamed to zip"); string[] xapFiles = Directory.GetFiles(websiteTargetPath + "\\ClientBin", "*.zip", SearchOption.TopDirectoryOnly); foreach (string xapFile in xapFiles) { Execute.Command(sevenZip, "a -y " + xapFile + " " + configBackupPath + "\\Client\\ServiceReferences.ClientConfig"); } Display.Output("Configs inserted"); FileManagement.RenameFile(websiteTargetPath + "\\ClientBin\\*.zip", websiteTargetPath + "\\ClientBin\\*.xap"); Display.Output("Zips renamed to xap"); }
public static void Backup(List <string> configs) { string websiteTargetPath = ListParser.Get("WEBSITE-TARGET-PATH=", configs); string serviceTargetPath = ListParser.Get("SERVICE-TARGET-PATH=", configs); string crmServiceTargetPath = ListParser.Get("CRM-SERVICE-TARGET-PATH=", configs); string configBackupPath = ListParser.Get("CONFIG-BACKUP-PATH=", configs); string sevenZip = ListParser.Get("ZIP=", configs); Display.Header("Backing up configs"); CreateConfigBackupFolders(configBackupPath); if (File.Exists(websiteTargetPath + "\\ClientBin\\OrderDetails.xap")) { Display.Output("Extract ServiceReferences.ClientConfig"); FileManagement.RenameFile(websiteTargetPath + "\\ClientBin\\OrderDetails.xap", websiteTargetPath + "\\ClientBin\\OrderDetails.zip"); File.Delete(websiteTargetPath + "\\ClientBin\\ServiceReferences.ClientConfig"); Execute.Command(sevenZip, "e -y " + websiteTargetPath + "\\ClientBin\\OrderDetails.zip ServiceReferences.ClientConfig"); Display.Output("Copy ServiceReferences.ClientConfig"); Directory.CreateDirectory(configBackupPath); FileManagement.CopyFile("ServiceReferences.ClientConfig", configBackupPath + "\\Client\\ServiceReferences.ClientConfig", true); File.Delete("ServiceReferences.ClientConfig"); } else { Display.Error("ERROR ServiceReferences.ClientConfig was NOT backed up.", false); Display.Error("You will have to check that the xap files have the correct configs.", false); Display.Error("If you are installing to empty folders (no previous install) this is normal", false); Display.Error("and you will probably need to create the correct configs manually."); } if (File.Exists(websiteTargetPath + "\\web.config")) { Display.Output("Copy Client\\web.config"); FileManagement.CopyFile(websiteTargetPath + "\\web.config", configBackupPath + "\\Client\\web.config", true); } else { Display.Error(websiteTargetPath + "\\web.config may need to be manually installed.", false); } if (File.Exists(serviceTargetPath + "\\web.config")) { Display.Output("Copy Service\\web.config"); FileManagement.CopyFile(serviceTargetPath + "\\web.config", configBackupPath + "\\Service\\web.config", true); } else { Display.Error(serviceTargetPath + "\\web.config may need to be manually installed.", false); } if (File.Exists(crmServiceTargetPath + "\\web.config")) { Display.Output("Copy SMART_CRM_Webservice\\web.config"); FileManagement.CopyFile(crmServiceTargetPath + "\\web.config", configBackupPath + "\\SMART_CRM_Webservice\\web.config", true); } else { Display.Error(crmServiceTargetPath + "\\web.config may need to be manually installed.", false); } if (File.Exists(websiteTargetPath + "\\App_Data\\authorizationManager.xml")) { Display.Output("Copy authorizationManager.xml"); FileManagement.CopyFile(websiteTargetPath + "\\App_Data\\authorizationManager.xml", configBackupPath + "\\authorizationManager.xml", true); } else { Display.Error(websiteTargetPath + "\\App_Data\\authorizationManager.xml may need to be manually installed.", false); } }