Esempio n. 1
0
        /// <summary>
        /// Manipulates the files.
        /// </summary>
        /// <returns>The path to the project file</returns>
        private string GetNewProjectFile()
        {
            string tempPath = string.Empty;
            // string k2DeployFolder = string.Empty;
            FileHelper fileHelper = new FileHelper();

            //Get the project folder
            string projectFolder = fileHelper.GetFolderFromPath(ProjectFilePath);
            LogHelper.LogMessage("      Project Folder: " + projectFolder);

            // Get the Project File Path
            string projectFile = fileHelper.GetFileNameFromPath(ProjectFilePath);
            LogHelper.LogMessage("      Project File: " + projectFile);

            LogHelper.LogMessage("   -- Getting path to a temporary folder for the K2 project files");
            tempPath = fileHelper.GetTempDirectory();

            TempDeployFolderPath = tempPath + @"\K2Deploy";

            LogHelper.LogMessage("      Temp Folder: " + TempDeployFolderPath);
            LogHelper.LogMessage("   -- Cleaning up files from any previous builds");
            fileHelper.DeleteDirectory(TempDeployFolderPath);

            LogHelper.LogMessage("   -- Copying files to the temp folder");
            fileHelper.CopyFolder(projectFolder, TempDeployFolderPath);
            LogHelper.LogMessage("      Files copied from '" + projectFolder + "' to '" + TempDeployFolderPath + "'");

            //Ensure we have access to all the files.
            LogHelper.LogMessage("   -- Setting ACL on folders and files in '" + TempDeployFolderPath + "'");
            bool success = fileHelper.SetAcl(TempDeployFolderPath, "F", true);
            if (!success) throw new Exception("Failed to set ACLs on folder " + TempDeployFolderPath);

            //Ensure the files are all writable
            LogHelper.LogMessage("   -- Setting writable permissions for folder: " + TempDeployFolderPath);
            fileHelper.SetWritable(TempDeployFolderPath);

            LogHelper.LogMessage("   -- Getting the Project File Path in Temp Folder");
            string newProjectFilePath = TempDeployFolderPath + @"\" + ProjectFilePath.Substring(1 + ProjectFilePath.LastIndexOf('\\'));
            LogHelper.LogMessage("      New Project File: " + newProjectFilePath);

            return newProjectFilePath;
        }
Esempio n. 2
0
        private bool BuildCompileAndSaveProject(string projectFilePath,string outputPath,EnvironmentSettingsManager environmentManager, int stepNumber)
        {
            Project project;
            DeploymentPackage package;
            bool result = false;

            #region 4. Build

            LogHelper.LogMessage(String.Format("\n{0}.1 Beginning Build",stepNumber));
            LogHelper.LogMessage("   -- Loading project file: " + projectFilePath);
            project = new Project();
            project.Load(projectFilePath);

            LogHelper.LogMessage("   -- Building Project");
            result = K2Helper.CompileK2Project(project);

            if (!result)
                throw new Exception("The Project did not Compile successfully.\n");

            #endregion

            #region 5. Deployment Package Creation

            LogHelper.LogMessage(String.Format("\n{0}.2 Creating the Deployment Package",stepNumber));
            package = K2Helper.CreateDeploymentPackage(
                project, environmentManager, DeployLabel, DeployDescription, testOnly);

            #endregion

            #region 6. Save Deployment Package

            LogHelper.LogMessage(String.Format("\n{0}.3. Saving Deployment Package to '" + OutputPath + "'",stepNumber));
            FileHelper fileHelper = new FileHelper();
            fileHelper.DeleteDirectory(outputPath);

            package.Save(outputPath, "K2DeploymentPackage");
            LogHelper.LogMessage("   -- Package Saved");

            #endregion

            return result;
        }