Пример #1
0
        internal static SourceUnit FromDirectory(string name, string root)
        {
            DirectoryInfo di = new DirectoryInfo(root);

            FileInfo[] sources = DepresolveConsoleCommand.FindSources(di);
            string[]   files   = new string[sources.Length];
            for (int i = 0; i < sources.Length; i++)
            {
                files[i] = Utils.GetRelativePath(sources[i].FullName, root);
            }
            files.OrderByDescending(p => p);
            var su = new SourceUnit
            {
                Name         = name,
                Dir          = root,
                Files        = files,
                Dependencies = new DependencyInfo[0],
            };

            return(su);
        }
        public static void Register(CommandLineApplication cmdApp, Microsoft.Extensions.PlatformAbstractions.IApplicationEnvironment appEnvironment)
        {
            cmdApp.Command("scan", c => {
                c.Description = "Scan a directory tree and produce a JSON array of source units";

                c.HelpOption("-?|-h|--help");

                c.OnExecute(async() => {
                    var dir = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "."));

                    DirectoryInfo di  = new DirectoryInfo(Directory.GetCurrentDirectory());
                    FileInfo[] fis    = FindVSProjects(di);
                    string[] projects = new string[fis.Length];
                    for (int i = 0; i < fis.Length; i++)
                    {
                        projects[i] = fis[i].FullName;
                        ConvertCsproj(projects[i]);
                    }


                    var sourceUnits = new List <SourceUnit>();
                    foreach (var proj in Scan(dir))
                    {
                        sourceUnits.Add(SourceUnit.FromProject(proj, dir));
                    }

                    if (sourceUnits.Count == 0)
                    {
                        //not a DNX project and not a VS project
                        sourceUnits.Add(SourceUnit.FromDirectory("name", dir));
                    }

                    Console.WriteLine(JsonConvert.SerializeObject(sourceUnits, Formatting.Indented));

                    await DepresolveConsoleCommand.RunResolve(dir);

                    return(0);
                });
            });
        }
Пример #3
0
        public int Main(string[] args)
        {
            var app = new CommandLineApplication(throwOnUnexpectedArg: true);

            app.Name     = "srclib-csharp";
            app.FullName = "Scrlib C# toolchain";

            app.HelpOption("-?|-h|--help");

            // Show help information if no subcommand/option was specified
            app.OnExecute(() =>
            {
                app.ShowHelp();
                return(2);
            });

            ScanConsoleCommand.Register(app, _env);
            GraphConsoleCommand.Register(app, _env, _loadContextAccessor, _runtimeEnv);
            DepresolveConsoleCommand.Register(app, _env, _runtimeEnv);

            return(app.Execute(args));
        }
Пример #4
0
        public static void Register(CommandLineApplication cmdApp, Microsoft.Extensions.PlatformAbstractions.IApplicationEnvironment appEnvironment)
        {
            cmdApp.Command("scan", c => {
                c.Description = "Scan a directory tree and produce a JSON array of source units";

                c.HelpOption("-?|-h|--help");

                c.OnExecute(async() => {
                    string url = getGitUrl();
                    if (url.EndsWith("github.com/dotnet/coreclr"))
                    {
                        Console.Error.WriteLine("special case coreclr");
                        DepresolveConsoleCommand.RunForResult("/bin/bash", "-c \"rm `find -name project.json`\"");
                        DepresolveConsoleCommand.RunForResult("/bin/bash", "-c \"rm `find -name '*.csproj'`\"");
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./src/mscorlib/project.json"), "{\n  \"frameworks\": {\n    \"dnx451\": {\n      \"dependencies\": {\n      }\n    }\n  }\n}");
                    }
                    else if (url.EndsWith("github.com/Microsoft/referencesource"))
                    {
                        Console.Error.WriteLine("special case referencesource");
                        string json = "{\n  \"frameworks\": {\n    \"dnx451\": {\n      \"dependencies\": {\n      }\n    }\n  }\n}";

                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./mscorlib/project.json"), json);

                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Activities/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Xml.Linq/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Numerics/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Web.Services/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.IdentityModel/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./Microsoft.Bcl/System.IO.v2.5/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./Microsoft.Bcl/System.Runtime.v1.5/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./Microsoft.Bcl/System.IO.v1.5/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./Microsoft.Bcl/System.Threading.Tasks.v2.5/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./Microsoft.Bcl/System.Threading.Tasks.v1.5/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./Microsoft.Bcl/System.Runtime.v2.5/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Activities.Presentation/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.ServiceModel.Activities/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Web.ApplicationServices/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.ServiceModel/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./XamlBuildTask/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.IdentityModel.Selectors/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Workflow.Runtime/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Web.Extensions/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Web.Mobile/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.ServiceModel.Activation/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Net/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Xml/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.ServiceModel.Channels/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Data.SqlXml/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Data.DataSetExtensions/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.ServiceModel.Discovery/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Activities.DurableInstancing/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.ServiceModel.Routing/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Core/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Workflow.ComponentModel/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Web.Entity.Design/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Data.Entity.Design/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.ComponentModel.DataAnnotations/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Runtime.DurableInstancing/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Web.DynamicData/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Web/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.ServiceModel.Internals/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Data/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./SMDiagnostics/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.WorkflowServices/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Workflow.Activities/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.ServiceModel.WasHosting/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Web.Entity/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Data.Entity/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Configuration/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Web.Routing/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Runtime.Serialization/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Runtime.Caching/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Xaml.Hosting/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.ServiceModel.Web/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Activities.Core.Presentation/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./System.Data.Linq/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./Microsoft.Bcl.Async/Microsoft.Threading.Tasks.Extensions.Desktop/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./Microsoft.Bcl.Async/Microsoft.Threading.Tasks.Extensions.Phone/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./Microsoft.Bcl.Async/Microsoft.Threading.Tasks.Extensions/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./Microsoft.Bcl.Async/Microsoft.Threading.Tasks/project.json"), json);
                        File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "./Microsoft.Bcl.Async/Microsoft.Threading.Tasks.Extensions.Silverlight/project.json"), json);
                    }
                    else if (url.EndsWith("github.com/AutoMapper/AutoMapper"))
                    {
                        DepresolveConsoleCommand.RunForResult("/bin/bash", @"-c ""sed 's/..\\\\/..\//g' -i `find -name project.json`""");
                    }


                    var dir = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "."));

                    DirectoryInfo di  = new DirectoryInfo(Directory.GetCurrentDirectory());
                    FileInfo[] fis    = FindVSProjects(di);
                    string[] projects = new string[fis.Length];
                    for (int i = 0; i < fis.Length; i++)
                    {
                        projects[i] = fis[i].FullName;
                        ConvertCsproj(projects[i]);
                    }


                    var sourceUnits = new List <SourceUnit>();
                    foreach (var proj in Scan(dir))
                    {
                        sourceUnits.Add(SourceUnit.FromProject(proj, dir));
                    }

                    if (sourceUnits.Count == 0)
                    {
                        //not a DNX project and not a VS project
                        sourceUnits.Add(SourceUnit.FromDirectory("name", dir));
                    }

                    Console.WriteLine(JsonConvert.SerializeObject(sourceUnits, Formatting.Indented));

                    await DepresolveConsoleCommand.RunResolve(dir);

                    return(0);
                });
            });
        }