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

                var repoName = c.Option("--repo <REPOSITORY_URL>", "The URI of the repository that contains the directory tree being scanned", CommandOptionType.SingleValue);
                var subdir   = c.Option("--subdir <SUBDIR_PATH>", "The path of the current directory (in which the scanner is run), relative to the root directory of the repository being scanned", CommandOptionType.SingleValue);

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

                c.OnExecute(() => {
                    var repository = repoName.Value();
                    var dir        = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), subdir.Value()));

                    //Console.WriteLine($"Repository: {repository}");
                    //Console.WriteLine($"Directory: {dir}");

                    var sourceUnits = new List <SourceUnit>();
                    foreach (var proj in Scan(dir))
                    {
                        //Console.WriteLine($"Found project: {proj.Name} ({proj.Version}, {proj.CompilerServices})");
                        sourceUnits.Add(SourceUnit.FromProject(proj, dir));
                    }

                    //Console.Error.Write($"Current dir: {Environment.CurrentDirectory}\n");
                    Console.WriteLine(JsonConvert.SerializeObject(sourceUnits, Formatting.Indented));

                    return(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() => {
                    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 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);
                });
            });
        }