Exemple #1
0
        static void Main()
        {
            //var msbuildPath = @"D:\src\msbuild.fork\artifacts\bin\bootstrap\net472\MSBuild\Current\Bin";
            //var msbuildPath = @"D:\src\msbuild\artifacts\Debug\bootstrap\net472\MSBuild\15.0\Bin";
            //var msbuildPath = @"D:\src\DomTest\SGEC\src\rps\MSBuild\artifacts\bin\bootstrap\net472\MSBuild\Current\Bin";
            //MSBuildLocator.RegisterMSBuildPath(msbuildPath);

            MSBuildLocatorUtils.RegisterMSBuild();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
        private static int Run(CommandLineArguments args)
        {
            try
            {
                var outFile = Path.GetFullPath(args.OutputFile);

                var directory = Path.GetDirectoryName(outFile);
                var filename  = Path.GetFileNameWithoutExtension(outFile);
                var extension = Path.GetExtension(outFile);

                var projectFile = args.InputFile;

                if (string.IsNullOrEmpty(args.MSBuildBinDirectory))
                {
                    MSBuildLocatorUtils.RegisterMSBuild();
                }
                else
                {
                    MSBuildLocator.RegisterMSBuildPath(args.MSBuildBinDirectory);
                }

                var dotNotations = new Program().GetDotNotations(new FileInfo(projectFile), string.IsNullOrEmpty(args.EndNodes) ? null : args.EndNodes.Split(';'));

                var renderingFunction = extension.EndsWith(".txt")
                    ? (Action <string, string>)((path, dotNotation) => File.WriteAllText(path, dotNotation))
                    : (Action <string, string>)((path, dotNotation) => GraphVis.Save(dotNotation, path));

                foreach (var dotNotation in dotNotations)
                {
                    var outputFile = Path.Combine(directory, $"{filename}{dotNotation.pathPostfix}{extension}");
                    renderingFunction(outputFile, dotNotation.contents);
                }

                return(0);
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine(e);
                Console.ResetColor();
                return(1);
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            try
            {
                var outFile = args.Length > 1 ? args[1] : "out.png";

                // GraphGen.exe <proj-file> ?<out.png> ?<msbuild-path>
                if (args.Length == 0)
                {
                    Console.WriteLine("GraphGen.exe <proj-file> ?<out.png> ?<msbuild-path>");
                    Environment.Exit(1);
                }

                var projectFile = args[0];

                if (args.Length < 3)
                {
                    MSBuildLocatorUtils.RegisterMSBuild();
                }
                else
                {
                    MSBuildLocator.RegisterMSBuildPath(args[2]);
                }

                var graphText = new Program().LoadGraph(new FileInfo(projectFile));

                GraphVis.Save(graphText, outFile);
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine(e);
                Console.ResetColor();
                Environment.Exit(1);
            }
        }
Exemple #4
0
        private static int Run(CommandLineArguments args)
        {
            try
            {
                var outFile = Path.GetFullPath(args.OutputFile);

                var directory = Path.GetDirectoryName(outFile);
                var filename  = Path.GetFileNameWithoutExtension(outFile);
                var extension = Path.GetExtension(outFile);

                var projectFile = args.InputFile;

                if (string.IsNullOrEmpty(args.MSBuildBinDirectory))
                {
                    MSBuildLocatorUtils.RegisterMSBuild();
                }
                else
                {
                    MSBuildLocator.RegisterMSBuildPath(args.MSBuildBinDirectory);
                }

                var globalProperties = string.IsNullOrEmpty(args.GlobalProperties)
                    ? ImmutableDictionary <string, string> .Empty
                    : args.GlobalProperties.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(
                    propertyPair =>
                {
                    var kvp = propertyPair.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries);

                    Trace.Assert(kvp.Length == 2, $"Expected <key>=<value> format in {propertyPair}");

                    return(kvp[0], kvp[1]);
                }).ToImmutableDictionary(kvp => kvp.Item1, kvp => kvp.Item2);

                var targets = string.IsNullOrEmpty(args.Targets)
                    ? null
                    : args.Targets.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                var endNodes = string.IsNullOrEmpty(args.EndNodes)
                    ? null
                    : args.EndNodes.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                var dotNotations = new Program().GetDotNotations(new FileInfo(projectFile), globalProperties, targets, endNodes);

                var renderingFunction = extension.EndsWith(".txt")
                    ? (path, dotNotation) => File.WriteAllText(path, dotNotation)
                    : (Action <string, string>)((path, dotNotation) => GraphVis.Save(dotNotation, path));

                foreach (var dotNotation in dotNotations)
                {
                    var outputFile = Path.Combine(directory, $"{filename}{dotNotation.pathPostfix}{extension}");
                    renderingFunction(outputFile, dotNotation.contents);
                }

                return(0);
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine(e);
                Console.ResetColor();
                return(1);
            }
        }