What do dotnet cross-platform "dotnet Restore" and "dotnet run" do?
Preface:
About dotnet cross-platform related content. Can participate: cross-platform. NET core--Microsoft Open Source Direction
The. NET core base library called Corefx:https://github.com/dotnet/corefx,.net core execution is called CORECLR:HTTPS://GITHUB.COM/DOTNET/CORECLR. ASP. NET Core Components library: Https://github.com/aspnet.
when using cross-platform dotnet, we most often use "dotnet restore" and "dotnet run". So what did "dotnet Restore" and "dotnet run" do?
First Look at dotnet restore .
Source code: Https://github.com/dotnet/cli/tree/rel/1.0.0/src/dotnet/commands/dotnet-restore
Entrance is here: Https://github.com/dotnet/cli/blob/rel/1.0.0/src/dotnet/commands/dotnet-restore/Program.cs
The main thing is to look for the project file (Project.json) under the current folder, then use the NuGet Library to restore the entire project's dependent library, then traverse each folder, build the project file, and continue to restore the dependencies in the project file:
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 pro Ject.json "};//Parse--quiet, because we have to handle the specially since NuGet3 has a different//"--verbosity "switch That goes before the commandvar 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);
look at the dotnet run again .
Source code: Https://github.com/dotnet/cli/tree/rel/1.0.0/src/dotnet/commands/dotnet-run
Entrance is here: Https://github.com/dotnet/cli/blob/rel/1.0.0/src/dotnet/commands/dotnet-run/Program.cs
The main parameter is the processing of parameters. The real reality now: Https://github.com/dotnet/cli/blob/rel/1.0.0/src/dotnet/commands/dotnet-run/RunCommand.cs, assuming that the interaction is directly executed, Otherwise compiled and then executed.
----------------------------------------------------------RunCommand.cs-------------------------------------------------- --------
public int Start () { if (isinteractive ()) { return runinteractive (Project); } else { return runexecutable (); } }
What do the dotnet cross-platform "dotnet restore" and "dotnet run" do?