Beispiel #1
0
 public SourceDirectoryVM()
 {
     Model            = new SourceDirectory();
     Model.Alias      = "Foo";
     Model.SrcPath    = @"C:\dev\something\";
     Model.Stream     = "**Stream**";
     Model.IsExpanded = true;
     Configurations.Add(new ConfigurationVM());
 }
Beispiel #2
0
        public SourceDirectoryVM(MainVM parent, SourceDirectory model)
        {
            Parent = parent;
            Model  = model;
            WireupCommands();

            if (model.Configurations != null)
            {
                foreach (var conf in model.Configurations)
                {
                    Configurations.Add(new ConfigurationVM(this, conf));
                }
            }

            System.Windows.Data.BindingOperations.EnableCollectionSynchronization(Configurations, Configurations);
        }
Beispiel #3
0
        private static SourceDirectory IdentifyEnvironment(DirectoryInfo buildStrategyDirectory)
        {
            DirectoryInfo srcDir = buildStrategyDirectory.Parent;

            log.InfoFormat("Checking src directory {0} for possible build environment...", buildStrategyDirectory.FullName);

            string hgrcPath = Path.Combine(buildStrategyDirectory.FullName, ".hg\\hgrc");

            if (!File.Exists(hgrcPath))
            {
                log.InfoFormat("Not considering build environment because {0} does not exist.", hgrcPath);
                return(null);
            }

            var hgrcContent = File.ReadAllText(hgrcPath);
            var match       = Regex.Match(hgrcContent, @"^(?:.*)http://(?<stream>[-_\w]*)\.(?:devteams|hgbranches)(?:\.bentley\.com)(?:.*)$", RegexOptions.Multiline | RegexOptions.IgnoreCase);

            if (!match.Success)
            {
                log.InfoFormat("Not considering build environment because {0} does not contain valid stream.", hgrcPath);
                return(null);
            }

            var stream = match.Groups["stream"].Value;

            if (string.IsNullOrEmpty(stream))
            {
                log.InfoFormat("Not considering build environment as stream name could not be obtained from {0}.", hgrcPath);
                return(null);
            }

            var result = new SourceDirectory()
            {
                SrcPath = PathHelper.EnsureTrailingDirectorySeparator(srcDir.FullName), Stream = stream
            };

            log.InfoFormat("Found new environment in {0}!", srcDir.FullName);
            UpdateEnvironment(result);
            return(result);
        }
Beispiel #4
0
        private static void UpdateEnvironment(SourceDirectory result)
        {
            var srcPath = new DirectoryInfo(result.SrcPath);
            var candidateSetupEnvScripts = srcPath.Parent.EnumerateFiles("*.bat", SearchOption.TopDirectoryOnly);

            var batchFiles = candidateSetupEnvScripts.Select(s => ReadBatchFile(s)).ToList();

            foreach (var batchFile in batchFiles)
            {
                string outPath, buildStrat;
                if (!batchFile.EnvVariables.TryGetValue(ENV_VAR_BSIOUT, out outPath) || !batchFile.EnvVariables.TryGetValue(ENV_VAR_BUILDSTRATEGY, out buildStrat))
                {
                    continue;
                }

                if (string.IsNullOrEmpty(outPath) || string.IsNullOrEmpty(buildStrat))
                {
                    continue;
                }

                Configuration c = new Configuration();
                c.OutPath       = PathHelper.EnsureTrailingDirectorySeparator(outPath);
                c.BuildStrategy = buildStrat;

                if (!string.IsNullOrEmpty(batchFile.Title))
                {
                    c.Alias = batchFile.Title;
                }

                string debug;
                if (batchFile.EnvVariables.TryGetValue("DEBUG", out debug))
                {
                    c.Release = debug != "1";
                }

                result.Configurations.Add(c);
            }
        }