예제 #1
0
파일: RevertAll.cs 프로젝트: JIADev/build
        private static IEnumerable <string> GetHgStatFiles(string hgExe, DirectoryInfo directory, string tempIgnoreFile)
        {
            string output;

            try
            {
                output = BuildSystem.RunProcess(hgExe, "status", directory.FullName, timeoutSeconds: 45, displayStdOut: false);
            }
            catch (TimeoutException)
            {
                Thread.Sleep(10 * 1000);
                output = BuildSystem.RunProcess(hgExe, "status", directory.FullName);
            }

            var currentAssembly = System.Reflection.Assembly.GetExecutingAssembly().Location;
            var files           = output.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries)
                                  .Select(s => s.TrimStart(new[] { ' ', '?' }).Trim())
                                  .Select(s =>
            {
                try
                {
                    var file = Path.Combine(directory.FullName, s);
                    return(file);
                }
                catch
                {
                    return(null);
                }
            })
                                  .Where(f => !string.IsNullOrWhiteSpace(f) && !f.Equals(tempIgnoreFile, StringComparison.InvariantCultureIgnoreCase) && !f.Equals(currentAssembly, StringComparison.InvariantCultureIgnoreCase)).ToArray();

            return(files);
        }
예제 #2
0
        public string RunHg(string args)
        {
            var arguments = args;

            if (!string.IsNullOrWhiteSpace(AdditionalHgArgs))
            {
                arguments = string.Format("{0} {1}", arguments, AdditionalHgArgs);
            }
            var result = BuildSystem.RunProcess(HgExe, arguments, RepoDirectory, displayStdErr: false, displayStdOut: false);

            return(result);
        }
예제 #3
0
파일: RevertAll.cs 프로젝트: JIADev/build
        private void ExecuteRevertAll(string hgExe, DirectoryInfo directory)
        {
            if (Verbose)
            {
                Console.WriteLine("Reverting all files under " + directory.FullName);
            }
            const string command = "revert --all --no-backup";

            try
            {
                BuildSystem.RunProcess(hgExe, command, directory.FullName, timeoutSeconds: 90);
            }
            catch (TimeoutException)
            {
                Thread.Sleep(10 * 1000);
                BuildSystem.RunProcess(hgExe, command, directory.FullName);
            }
        }
예제 #4
0
        public override bool Execute()
        {
            InputFiles = InputFiles ?? string.Empty;
            var fileList = InputFiles.Split(new [] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToArray();

            if (fileList.Length == 0)
            {
                fileList = GetCsProjFiles().ToArray();
            }

            var filesModified = fileList.Sum(f => RemoveDuplicateEntries(f, OutputFile));

            Console.WriteLine(string.Format("Modified {0} project files", filesModified));

            if (File.Exists(FeatureExe))
            {
                BuildSystem.RunProcess(FeatureExe, "cleanpatches", Environment.CurrentDirectory);
            }
            return(true);
        }
예제 #5
0
        private static void GenerateXml(string hgExe, string outputFile, string[] changesets)
        {
            var docList = new List <XDocument>();

            if (changesets.Any())
            {
                var args = CreateArgs(changesets);

                foreach (var arg in args)
                {
                    var xmlInput = BuildSystem.RunProcess(hgExe, arg, Environment.CurrentDirectory);
                    if (String.IsNullOrEmpty(xmlInput))
                    {
                        xmlInput = "<log />";
                    }
                    var xDoc   = XDocument.Parse(xmlInput);
                    var remove = xDoc.XPathSelectElements("/log/logentry").ToArray()
                                 .Select(le =>
                                         new
                    {
                        logEntry   = le,
                        msgElement = le == null
                                                                                                      ? null
                                                                                                      : le.XPathSelectElement("msg")
                    })
                                 .Select(e => new
                    {
                        e.logEntry,
                        msg = e.msgElement == null
                                                                                       ? String.Empty
                                                                                       : e.msgElement.Value
                    })
                                 .Where(m => m.msg.Contains("@build")).Select(e => e.logEntry);
                    foreach (var entry in remove)
                    {
                        entry.Remove();
                    }
                    docList.Add(xDoc);
                }
            }
            if (docList.Count < 1)
            {
                return;
            }

            var firstDoc = docList[0];

            if (docList.Count == 1)
            {
                firstDoc.Save(outputFile);
                return;
            }

            for (var i = 1; i < docList.Count; i++)
            {
                var currentDoc  = docList[i];
                var docElements = currentDoc.XPathSelectElements("/log/logentry");
                firstDoc.XPathSelectElement("/log").Add(docElements);
            }
            firstDoc.Save(outputFile);
        }
예제 #6
0
파일: Protect.cs 프로젝트: JIADev/build
        public static void ProtectAll(string driverFeature, DirectoryInfo baseDir, int maxRetries = 1)
        {
            var root = baseDir.Root;

            var tempDir = Path.Combine(root.FullName, "temp", Guid.NewGuid().ToString().Split(new[] { '-' }, StringSplitOptions.RemoveEmptyEntries).First());

            try
            {
                if (Directory.Exists(tempDir))
                {
                    Console.WriteLine(String.Format("Deleting: {0}", tempDir));
                    Directory.Delete(tempDir, true);
                }

                Directory.CreateDirectory(tempDir);

                Console.WriteLine(String.Format("Reading: {0}", baseDir.FullName));
                var zipFiles         = ExtractZips(baseDir, tempDir);
                var assembliesToVeil = GetAssembliesToVeil(driverFeature, baseDir);
                var distinctFiles    = GetDistinctFiles(assembliesToVeil, tempDir);
                var targets          = String.Join(";", distinctFiles.Keys.ToArray());
                var args             = "/Secure /Target:" + targets;
                try
                {
                    BuildSystem.RunProcess("AgileDotNet.Console.exe", args, baseDir.FullName, null, 120);
                }
                catch (TimeoutException)
                {
                    if (maxRetries == 0)
                    {
                        throw;
                    }

                    ProtectAll(driverFeature, baseDir, maxRetries - 1);
                    return;
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine("ERROR: " + ex);
                    throw;
                }
                foreach (var veiledFile in distinctFiles)
                {
                    foreach (var targetFile in veiledFile.Value.Select(f => f.FullName).ToArray())
                    {
                        Console.WriteLine(String.Format("Overwriting {0}", targetFile));
                        File.Copy(veiledFile.Key, targetFile, true);
                    }
                }
                RecreateZips(zipFiles);
            }
            catch (Exception ex1)
            {
                Console.WriteLine("ERROR: " + ex1);
                throw;
            }
            finally
            {
                if (Directory.Exists(tempDir))
                {
                    Console.WriteLine(String.Format("Deleting: {0}", tempDir));
                    Directory.Delete(tempDir, true);
                }
            }
        }