Exemple #1
0
        public static int Run(string[] args)
        {
            DebugHelper.HandleDebugSwitch(ref args);

            var app = new CommandLineApplication(false)
            {
                Name = "dotnet restore",
                FullName = ".NET project dependency restorer",
                Description = "Restores dependencies listed in project.json"
            };


            app.OnExecute(() =>
            {
                try
                {
                    return NuGet3.Restore(args);
                }
                catch (InvalidOperationException e)
                {
                    Console.WriteLine(e.Message);

                    return -1;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);

                    return -2;
                }
            });

            return app.Execute(args);
        }
Exemple #2
0
        public static int Run(string[] args)
        {
            DebugHelper.HandleDebugSwitch(ref args);

            var app = new CommandLineApplication(false)
            {
                Name        = "dotnet restore",
                FullName    = ".NET project dependency restorer",
                Description = "Restores dependencies listed in project.json"
            };

            // Parse --quiet, because we have to handle that specially since NuGet3 has a different
            // "--verbosity" switch that goes BEFORE the command
            var quiet = args.Any(s => s.Equals("--quiet", StringComparison.OrdinalIgnoreCase));

            args = args.Where(s => !s.Equals("--quiet", StringComparison.OrdinalIgnoreCase)).ToArray();

            // Until NuGet/Home#1941 is fixed, if no RIDs are specified, add our own.
            if (!args.Any(s => s.Equals("--runtime", StringComparison.OrdinalIgnoreCase)))
            {
                args = Enumerable.Concat(
                    args,
                    PlatformServices.Default.Runtime.GetOverrideRestoreRuntimeIdentifiers().SelectMany(r => new [] { "--runtime", r })
                    ).ToArray();
            }

            app.OnExecute(() =>
            {
                try
                {
                    var projectRestoreResult = NuGet3.Restore(args, quiet);

                    var restoreTasks = GetRestoreTasks(args);

                    foreach (var restoreTask in restoreTasks)
                    {
                        var project = ProjectReader.GetProject(restoreTask.ProjectPath);

                        RestoreTools(project, restoreTask, quiet);
                    }

                    return(projectRestoreResult);
                }
                catch (InvalidOperationException e)
                {
                    Console.WriteLine(e.Message);

                    return(-1);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);

                    return(-2);
                }
            });

            return(app.Execute(args));
        }
Exemple #3
0
        private static bool RestoreToolToPath(LibraryRange tooldep, IEnumerable <string> args, string tempPath, bool quiet)
        {
            Directory.CreateDirectory(tempPath);
            var projectPath = Path.Combine(tempPath, Project.FileName);

            Console.WriteLine($"Restoring Tool '{tooldep.Name}' for '{projectPath}' in '{tempPath}'");

            File.WriteAllText(projectPath, GenerateProjectJsonContents(new[] { "dnxcore50" }, tooldep));
            return(NuGet3.Restore(new [] { $"{projectPath}", "--runtime", $"{DefaultRid}" }.Concat(args), quiet) == 0);
        }
Exemple #4
0
        public static int Run(string[] args)
        {
            DebugHelper.HandleDebugSwitch(ref args);

            var app = new CommandLineApplication(false)
            {
                Name        = "dotnet restore",
                FullName    = ".NET project dependency restorer",
                Description = "Restores dependencies listed in project.json"
            };

            // Parse --quiet, because we have to handle that specially since NuGet3 has a different
            // "--verbosity" switch that goes BEFORE the command
            var quiet = args.Any(s => s.Equals("--quiet", StringComparison.OrdinalIgnoreCase));

            args = args.Where(s => !s.Equals("--quiet", StringComparison.OrdinalIgnoreCase)).ToArray();

            app.OnExecute(() =>
            {
                try
                {
                    var projectRestoreResult = NuGet3.Restore(args, quiet);

                    var restoreTasks = GetRestoreTasks(args);

                    foreach (var restoreTask in restoreTasks)
                    {
                        var project = ProjectReader.GetProject(restoreTask.ProjectPath);

                        RestoreTools(project, restoreTask, quiet);
                    }

                    return(projectRestoreResult);
                }
                catch (InvalidOperationException e)
                {
                    Console.WriteLine(e.Message);

                    return(-1);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);

                    return(-2);
                }
            });

            return(app.Execute(args));
        }
Exemple #5
0
        public static int Run(string[] args)
        {
            DebugHelper.HandleDebugSwitch(ref args);

            return(NuGet3.Restore(args));
        }