Пример #1
0
        public ProductBuild(LibraryManifest currManifest, string buildPath)
        {
            buildLogfile     = "";
            buildLogfileLock = new Object();
            buildTimes       = new StringCollection();
            libraryManifest  = currManifest;

            string buildDefinitionFile = ProductBuildDataSet.GetBuildConfigurationFilename(buildPath);

            pbDataSet = ProductBuildDataSet.ReadBuildConfigurationFile(buildDefinitionFile);
        }
Пример #2
0
        public static ArrayList GetFilteredComplist(string buildPath, string filterString)
        {
            string buildDefinitionFile           = ProductBuildDataSet.GetBuildConfigurationFilename(buildPath);
            ProductBuildDataSet pbDataSet        = ProductBuildDataSet.ReadBuildConfigurationFile(buildDefinitionFile);
            ArrayList           filteredComplist = new ArrayList();

            DataRow[] complistRows = pbDataSet.Tables[on.Component].Select(filterString);
            foreach (DataRow complistRow in complistRows)
            {
                filteredComplist.Add(complistRow[on.Component_Descriptor]);
            }
            return(filteredComplist);
        }
Пример #3
0
        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);
        }