【dotnet跨平台】"dotnet restore"和"dotnet run"都做了些什么?

web开发作者:dayu日期:5天前点击:1
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); }


再来看下dotnet run


源代码在:https://github.com/dotnet/cli/tree/rel/1.0.0/src/dotnet/commands/dotnet-run

入口在这里:https://github.com/dotnet/cli/blob/rel/1.0.0/src/dotnet/commands/dotnet-run/Program.cs

主要是參数处理。真正的实如今:https://github.com/dotnet/cli/blob/rel/1.0.0/src/dotnet/commands/dotnet-run/RunCommand.cs, 假设是交互的就直接执行,否则编译然后执行。

----------------------------------------------------------RunCommand.cs----------------------------------------------------------

 public int Start()
        {
            if (IsInteractive())
            {
                return RunInteractive(Project);
            }
            else
            {
                return RunExecutable();
            }
        }



【dotnet跨平台】"dotnet restore"和"dotnet run"都做了些什么?

原文地址:http://www.cnblogs.com/jhcelue/p/7201925.html


下一篇       上一篇