. Net Core initial experience and summary (including command Daquan), core Command Daquan

Source: Internet
Author: User

. Net Core initial experience and summary (including command Daquan), core Command Daquan

Dotnet command directory:

Dotnet new-create

Dotnet restore-restore

Dotnet build-compile

Dotnet run-run

Dotnet test-test

Dotnet pack-Packaging

Dotnet publish-publish

 

Next we will use an instance to concatenate the above commands. (Thank you here)LineZero. Net Core Command Daquan Article address: http://www.cnblogs.com/linezero/p/dotnet.html)

1. Create (dotnet new)

First, create a console project.

Dotnet new

 

2. restore (dotnet restore), package (dotnet pack)

Next we will create a class library lib

Dotnet new-t lib

Compile the class library code

The red dotted line is because no reference is added (the reference can be automatically added after dotnet restore is called)

Dotnet restore

Dotnet pack

 

It can be seen that the package after packaging is "libs" version 1.0.0

The following is an offline reference package for. Net Core. We will add the packaged libs information toProject. jsonMedium

After being added, switch to the app directory for restoration.

The restore command is:Dotnet restore-f F: \ CoreDemo \ libs \ bin \ Debug \

Dotnet restore-f package path

Ignore an error in the middle... I forgot to add a space...

Next, we can directly call the method in the class library in the project.

If you useVs codeOrVs 2015 update3If the version is later than or later, you can run and debug it directly.

3. Compile (dotnet build) and run (dotnet run)

Dotnet build

Dotnet run

Chinese symbol encoding problem, please ignore...

Dotnet xx. dllYou can also directly execute the program

4. test (dotnet test)

Create a new folder here (do not write the test code directly in the project; otherwise, you cannot debug and release it. Do not ask me why I know it ....)

 Dotnet new-t xunittest

After creating a project, you can directly add the test code to the project. I will not add the test code here...

Dotnet restore

Dotnre test

5. publish (dotnet publish)

 Dotnet publishDefault release

Go to the publish directory after publishingDotnet xx. dllExecute Application

 

The point is: cross-platform Publishing.

Add the runtimes node to project. json and comment out "type": "platform"

First, we wantDotnet restoreClick

Because we have added five platform versions, this restoration is a little slow. Wait...

Dotnet publish-r win10-64

After the publish is published, you can directly locate the publish directory and executeApp.exeYou can.

Dotnet publish-r ubuntu.14.04-x64

Upload the publish folder to linux, set the app permission to executable, and then run the./app.

Dotnet publish-r Platform System and version(It must be configured in the runtimes node in project. json)

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.