/// <summary> /// When overridden in a derived class, executes the task. /// </summary> /// <returns> /// true if the task successfully executed; otherwise, false. /// </returns> public override bool Execute() { EnvironmentSettingsManager environmentManager; string newProjectFilePath = string.Empty; bool result = false; int currentStep=0; // below if block added to check for and purge old cache file if it exists if (BinFileToDelete != string.Empty) { if (System.IO.File.Exists(BinFileToDelete)) { try { System.IO.File.Delete(BinFileToDelete); } catch (System.IO.IOException e) { LogHelper.LogMessage("\n\n*****Environment Cache Could Not Be Deleted*******\n"); LogHelper.LogMessage(e.Message.ToString()); } } } LogHelper.LogMessage("\n\n***** BEGIN *******\n"); try { //check if file exists //delete file #region 1. Validation LogHelper.LogStep(++currentStep, "Validating"); ValidateK2Project(); #endregion #region 2. Gather Environment Information LogHelper.LogStep(++currentStep, "Preparing Environment"); LogHelper.LogMessage(" -- Getting K2 Environment Manager"); environmentManager = K2Helper.GetEnvironmentManager(ConnectionString, Environment, UseEnvironmentCache); #endregion #region 3. File Preparation LogHelper.LogStep(++currentStep,"Preparing Project files"); //Edgar Dictionary<string, string> dictFiles = null; //check if the user want to compile the project as a whole or artifacts individually if (CompileProjectArtifactsIndividually) { dictFiles = GetNewProjectFiles(ref newProjectFilePath); LogHelper.LogMessage("\n3.1 Project files created in Temporary folder"); //we next need to create backup of the original file FileHelper fileHelper = new FileHelper(); fileHelper.CopyFile(newProjectFilePath, newProjectFilePath + ".bak", true); LogHelper.LogMessage("File has been backed up = "+ newProjectFilePath); foreach (KeyValuePair<string, string> kvp in dictFiles) { // currentStep += 1; string artifactName = kvp.Key; string newOutputPath = outputPath + @"\" + artifactName; //we need to replace the original file w/ this one. fileHelper.ReplaceFile(newProjectFilePath, kvp.Value); //it will always compile the the project under the original name; result = BuildCompileAndSaveProject(newProjectFilePath, newOutputPath, environmentManager,currentStep); currentStep += 1; } fileHelper = null; } else { //default behavior as originally coded newProjectFilePath = GetNewProjectFile(); LogHelper.LogMessage("\n3.1 Project files created in Temporary folder"); BuildCompileAndSaveProject(newProjectFilePath, outputPath, environmentManager, currentStep); currentStep += 1; } //Edgar// #endregion /* #region 7. Execute Deployment Package // Execute the Deployment Package LogHelper.LogMessage("\nExecuting deployment package..."); results = package.Execute(); // Record success result result = results.Successful; LogHelper.LogMessage("\nSuccessful = " + result); #endregion */ result = true; } catch(Exception ex) { LogHelper.LogMessage(ex.ToString()); throw; } finally { LogHelper.LogMessage("\n***** END *******\n\n"); } return result; }