static public ProductBuildDataSet GetProductBuildDataSetWithoutComplist( string profileName, string productName, string productVersion, string productPlatform, string branchOrTrunkName, string productDirectory, string libraryPath, string updateDate) { ProductBuildDataSet pbDataSet = new ProductBuildDataSet(); LibraryInfo libraryInfo = new LibraryInfo(productName, productVersion, productPlatform, branchOrTrunkName, productDirectory, libraryPath, updateDate); pbDataSet.Merge(GetProfileDataSet("default (Admin)"), false, MissingSchemaAction.Ignore); pbDataSet.Merge(GetProductSpecificDataSet(libraryInfo), false, MissingSchemaAction.Ignore); pbDataSet.Merge(GetProfileDataSet(profileName), false, MissingSchemaAction.Ignore); // Override P:\ProductBuilder environment variables in the default profile string PBPath = Environment.GetEnvironmentVariable("PBPath"); if (PBPath == null) { PBPath = "C:\\ASG\\VMS\\ProductBuilder"; // Default productbuilder client path } if (PBPath.Contains(" ")) { PBPath = "\"" + PBPath + "\""; } pbDataSet.SetBuildProperty("PBPath", PBPath, false); pbDataSet.SetBuildProperty("PBToolsPath", PBPath + "\\tools2", false); pbDataSet.SetBuildProperty("PBDataPath", PBPath + "\\Data2", false); pbDataSet.InitLibraryData(libraryInfo); pbDataSet.FinalizeProperties(); pbDataSet.Tables[on.Target].Clear(); pbDataSet.Tables[on.Component].Clear(); pbDataSet.AcceptChanges(); return(pbDataSet); }
static private ProductBuildDataSet GetProductSpecificDataSet(LibraryInfo libraryInfo) { ProductBuildDataSet productSpecificDataSet = new ProductBuildDataSet(); XmlTextReader xtr = null; try { string productPropertiesFilename = GetProductPropertiesFilename(libraryInfo); if (File.Exists(productPropertiesFilename)) { xtr = new XmlTextReader(GetProductPropertiesFilename(libraryInfo)); productSpecificDataSet.ReadXml(xtr); } string emailRecipients = ""; productSpecificDataSet.SetBuildProperty("EmailRecipients", emailRecipients, true); } finally { if (xtr != null) { xtr.Close(); } } return(productSpecificDataSet); }
static public ProductBuildDataSet ReadBuildConfigurationFile(string filename) { ProductBuildDataSet pbDataSet = new ProductBuildDataSet(); XmlTextReader xtr = null; try { if (File.Exists(filename)) { xtr = new XmlTextReader(filename); pbDataSet.ReadXml(xtr); } else { throw new Exception("The build configuration file, " + filename + ", does not exist."); } } finally { if (xtr != null) { xtr.Close(); } } return(pbDataSet); }
private void ValidateLibrary(NewMessage userMsg, bool isQuietMode) { string buildTimeEntry = DateTime.Now + " - Starting Validate."; buildTimes.Add(buildTimeEntry); Console.WriteLine(buildTimeEntry); string buildPath = pbDataSet.GetBuildProperty("BuildPath"); string sourcePath = pbDataSet.GetBuildProperty("SourcePath"); // save build configuration file string buildDefinitionFile = ProductBuildDataSet.GetBuildConfigurationFilename(buildPath); string tempFile = ProductBuildDataSet.GetBuildConfigurationFilename(Path.GetTempPath()); if (File.Exists(tempFile)) { File.SetAttributes(tempFile, FileAttributes.Normal); File.Delete(tempFile); } string tempBuildDefinitionDirectory = Path.Combine(Path.GetPathRoot(tempFile), Path.GetDirectoryName(tempFile)); if (!Directory.Exists(tempBuildDefinitionDirectory)) { Directory.CreateDirectory(tempBuildDefinitionDirectory); } File.Move(buildDefinitionFile, tempFile); // copy build definition file into buildpath string buildDefinitionDirectory = Path.Combine(Path.GetPathRoot(buildDefinitionFile), Path.GetDirectoryName(buildDefinitionFile)); if (Directory.Exists(buildDefinitionDirectory)) { Directory.Delete(buildDefinitionDirectory, true); } Directory.CreateDirectory(buildDefinitionDirectory); File.Move(tempFile, buildDefinitionFile); string errorMsg = null; if (false == CanBuildOnPath(sourcePath, buildPath, ref errorMsg)) { throw new Exception(errorMsg); } string buildLibName; string createDate; if (LibraryManifest.IsNetworkPath(sourcePath)) { buildLibName = "NETWORK_" + libraryManifest.GetBranchOrTrunkName() + "_BUILD"; createDate = new DateTime(DatabaseInterface.GetCurrentServerTime()).ToString(); } else { buildLibName = "LOCAL_" + libraryManifest.GetBranchOrTrunkName() + "_BUILD"; createDate = libraryManifest.GetDate(); } // Attempt to run LB three times. Try the first time in quiet mode. // Disable "quiet mode" on a retry, hoping to get information // useful to determine the source of problem. string quietModeArg = "/q"; int lbExitCode = 0; int attemptCount = 0; string validateBatchFilePath = buildPath + "\\validate.bat"; while (true) { string validateCmd = LibraryBuilderConfig.GetLbCommandLinePath() + " /c " + quietModeArg + " /nocopy /src:" + sourcePath + " /path:" + buildPath; validateCmd += " /name:" + buildLibName + " /date:\"" + createDate + "\""; //create bat file in buildPath and save StreamWriter cmdWriter = new StreamWriter(validateBatchFilePath, false); cmdWriter.WriteLine(validateCmd); cmdWriter.WriteLine("@set LB__EXIT__CODE=%ERRORLEVEL%"); cmdWriter.WriteLine("@echo Library validation: LB exited with code: %LB__EXIT__CODE%"); cmdWriter.WriteLine("@exit %LB__EXIT__CODE%"); cmdWriter.Close(); lbExitCode = RunBatchWithInternalOutputHandling(validateBatchFilePath, null, buildPath, isQuietMode, (1 * 60 * 60 * 1000), userMsg); Console.WriteLine("LB exited with code: " + lbExitCode); if (lbExitCode != 0 && ++attemptCount < 3) { Console.WriteLine("LB failed - retrying..."); quietModeArg = ""; continue; } break; } File.Delete(validateBatchFilePath); if (lbExitCode != 0) { Console.WriteLine("Unable to validate library, terminating build..."); throw new Exception("Unable to validate library. Please see build log for details."); } // refresh LibraryInfo file with current datetime LibraryManifest lif = new LibraryManifest( pbDataSet.GetBuildProperty("ProductName"), pbDataSet.GetBuildProperty("ProductVersion"), pbDataSet.GetBuildProperty("ProductPlatform"), pbDataSet.GetBuildProperty("BranchOrTrunkName"), pbDataSet.GetBuildProperty("ProductDirectory"), pbDataSet.GetBuildProperty("LibraryDate")); lif.SaveToPath(pbDataSet.GetBuildProperty("BuildPath")); buildTimeEntry = DateTime.Now + " - Validate Complete."; if (pbDataSet.IsPartialBuild()) { string binCopyCmd = Path.Combine(pbDataSet.GetBuildProperty("PBToolsPath"), "CopyBinaries.bat"); string copyArgs = " " + sourcePath + " " + buildPath; RunBatch(binCopyCmd, copyArgs, buildPath, isQuietMode, (1 * 60 * 60 * 1000), userMsg); } buildTimes.Add(buildTimeEntry); Console.WriteLine(buildTimeEntry); }
public static void SetBaseDataSet(ProductBuildDataSet pbDataSet) { ProductBuildDataSet.baseDataSet = (ProductBuildDataSet)pbDataSet.Copy(); }