public bool Extract( SolutionPackager_PackageType packageType, string mappingFile, bool?allowWrite, bool?allowDelete, bool clobber, string sourceLoc, bool localize, bool treatWarningsAsErrors) { return(Execute( SolutionPackager_Action.Extract, packageType, allowWrite, allowDelete, clobber, SolutionPackager_ErrorLevel.Verbose, mappingFile, true, Log, sourceLoc, localize, treatWarningsAsErrors )); }
public bool ExtractSolution( string solutionPackager, string solutionFile, string folder, SolutionPackager_PackageType packageType, string mappingFile, string sourceLoc, bool localize, bool treatWarningsAsErrors, string logsDirectory ) { Logger.LogVerbose("Unpacking Solution: {0}", solutionFile); SolutionXml solutionXml = new SolutionXml(Logger); XrmSolutionInfo info = solutionXml.GetSolutionInfoFromZip(solutionFile); if (info == null) { throw new Exception("Invalid solution file"); } Logger.LogInformation("Unpacking Solution Name: {0} - Version {1}", info.UniqueName, info.Version); SolutionNameGenerator generator = new SolutionNameGenerator(); string zipFile = new FileInfo(solutionFile).Name; string log = string.Empty; if (!string.IsNullOrEmpty(logsDirectory)) { log = $"{logsDirectory}\\PackagerLog_{zipFile.Replace(".zip", "")}_{DateTime.Now.ToString("yyyy_MM_dd__HH_mm")}.txt"; } Logger.LogVerbose("log: {0}", log); SolutionPackager packager = new SolutionPackager( Logger, solutionPackager, solutionFile, folder, log ); bool result = packager.Extract( packageType, mappingFile, true, true, false, sourceLoc, localize, treatWarningsAsErrors); return(result); }
public bool Pack( SolutionPackager_PackageType packageType, string mappingFile, bool treatWarningsAsErrors) { return(Execute( SolutionPackager_Action.Pack, packageType, null, null, false, SolutionPackager_ErrorLevel.Verbose, mappingFile, true, Log, string.Empty, false, treatWarningsAsErrors)); }
protected bool Execute( SolutionPackager_Action action, SolutionPackager_PackageType packageType, bool?allowWrite, bool?allowDelete, bool clobber, SolutionPackager_ErrorLevel?errorlevel, string map, bool nologo, string log, string sourceLoc, bool localize, bool treatWarningsAsErrors ) { StringBuilder arguments = new StringBuilder(); Logger.LogVerbose("Generating Solution Packager Arguments"); arguments.Append($" /action:{action.ToString()}"); arguments.Append($" /zipFile:\"{ZipFile}\""); arguments.Append($" /folder:\"{Folder}\""); arguments.Append($" /packageType:{packageType.ToString()}"); if (allowWrite.HasValue) { if (allowWrite.Value) { arguments.Append($" /allowWrite:Yes"); } else { arguments.Append($" /allowWrite:No"); } } if (allowDelete.HasValue) { if (allowDelete.Value) { arguments.Append($" /allowDelete:Yes"); } else { arguments.Append($" /allowDelete:No"); } } if (clobber) { arguments.Append($" /clobber"); } if (errorlevel.HasValue) { arguments.Append($" /errorlevel:{errorlevel.Value.ToString()}"); } if (!string.IsNullOrEmpty(map)) { arguments.Append($" /map:\"{map}\""); } if (nologo) { arguments.Append($" /nologo"); } if (!string.IsNullOrEmpty(log)) { arguments.Append($" /log:\"{log}\""); } if (!string.IsNullOrEmpty(sourceLoc)) { arguments.Append($" /sourceLoc:\"{sourceLoc}\""); } if (localize) { arguments.Append($" /localize"); } Logger.LogInformation("Solution Packager Version: {0}", FileUtilities.GetFileVersion(Packager)); Logger.LogInformation("Solution Packager Arguments: {0}", arguments.ToString()); ProcessStartInfo packagerInfo = new ProcessStartInfo() { FileName = Packager, Arguments = arguments.ToString(), CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden, RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false, }; int exitCode = -1; using (Process packagerProcess = new Process()) { packagerProcess.StartInfo = packagerInfo; packagerProcess.OutputDataReceived += PackagerProcess_OutputDataReceived; packagerProcess.ErrorDataReceived += PackagerProcess_ErrorDataReceived; Logger.LogVerbose("Invoking SolutionPackager: {0}", Packager); bool start = packagerProcess.Start(); packagerProcess.BeginOutputReadLine(); packagerProcess.BeginErrorReadLine(); packagerProcess.WaitForExit(1000 * 60 * 15); //15 minutes //Add sleep to allow time for output streams to flush Thread.Sleep(5 * 1000); exitCode = packagerProcess.ExitCode; Logger.LogInformation("SolutionPackager exit code: {0}", exitCode); packagerProcess.Close(); } if (warnings) { Logger.LogWarning("Solution Packager encountered warnings. Check logs for more information."); } if (errors) { Logger.LogError("Solution Packager encountered errors. Check logs for more information."); } if (exitCode != 0) { return(false); } else { if (treatWarningsAsErrors) { if (warnings) { return(false); } else { return(true); } } else { return(true); } } }
public bool PackSolution( string solutionPackager, string outputFolder, string folder, SolutionPackager_PackageType packageType, bool includeVersionInName, string mappingFile, bool treatWarningsAsErrors, bool incrementReleaseVersion, string version, string logsDirectory ) { Logger.LogVerbose("Packing Solution from: {0}", folder); SolutionXml solutionXml = new SolutionXml(Logger); XrmSolutionInfo info = solutionXml.GetXrmSolutionInfoFromFolder(folder); if (info == null) { throw new Exception("Invalid solution file"); } Logger.LogInformation("Packing Solution Name: {0} - Version {1}", info.UniqueName, info.Version); string newVersion; if (incrementReleaseVersion) { Logger.LogVerbose("Incrementing release version"); int release = Int32.Parse(info.Version.Substring(info.Version.LastIndexOf(".") + 1)); newVersion = $"{info.Version.Substring(0, info.Version.LastIndexOf(".") + 1)}{release + 1}"; solutionXml.UpdateSolutionVersion(folder, newVersion); } else if (!string.IsNullOrEmpty(version)) { Logger.LogInformation("Updating solution version to {0}", version); solutionXml.UpdateSolutionVersion(folder, version); newVersion = version; } else { newVersion = info.Version; } SolutionNameGenerator generator = new SolutionNameGenerator(); string zipFile; bool managed = packageType == SolutionPackager_PackageType.Managed; if (includeVersionInName) { zipFile = generator.GetZipName( info.UniqueName, newVersion, managed); } else { zipFile = generator.GetZipName( info.UniqueName, string.Empty, managed); } string zipFilePath = $"{outputFolder}\\{zipFile}"; Logger.LogVerbose("zipFile: {0}", zipFilePath); string log = string.Empty; if (!string.IsNullOrEmpty(logsDirectory)) { log = $"{logsDirectory}\\PackagerLog_{zipFile.Replace(".zip", "")}_{DateTime.Now.ToString("yyyy_MM_dd__HH_mm")}.txt"; } Logger.LogVerbose("log: {0}", log); SolutionPackager packager = new SolutionPackager( Logger, solutionPackager, zipFilePath, folder, log ); return(packager.Pack( packageType, mappingFile, treatWarningsAsErrors)); }