What do the dotnet cross-platform "dotnet restore" and "dotnet run" do?

Source: Internet
Author: User
Tags dotnet

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.