dotnet Command Combat

Source: Internet
Author: User
Tags dotnet

The following uses the example string dotnet Common command, takes you to play the dotnet command.

1. Create (dotnet New)

First we create a project, where we create the console program, as shown in the command.

dotnet New

dotnet new more parameters reference Help dotnet new-h.

2. Restore (dotnet Restore and dotnet pack)

Next, create a class lib, which is the classes library, as shown in the command.

dotnet New Classlib

Once created, write some of your own code and then package it.

Two methods are written here, now to pack.

dotnet Restore

Dotnet Pack

How does the. NET core Add an offline reference package? Now the answer.

Once packaged, add Applib to the app's app.csproj.

Add the following in App.csproj:

<ItemGroup>

<packagereference include= "Applib" version= "1.0.0"/>

</ItemGroup>

Add it later to switch to the app directory and then restore it.

The command used by the restore is: dotnet restore-s E:\dotnet\applib\bin\Debug\, which is the path to the dotnet restore-s package.

This allows you to invoke the Applib method directly in the project.

Write the corresponding call in the code, and then execute the program. You can see the result of the class Lib being output correctly.

3. Run (dotnet build and dotnet Run)

Take the app as an example.

dotnet build compiles the code, and then dotnet run executes the program:

Dotnet App.dll is also the execution program:

4. Test (dotnet Test)

Create a new folder and project here.

New test project: Dotnet new Xunit.

After you create a new project, you can add a test method to it, and run the test directly.

dotnet Restore

dotnet Test

5. Release (dotnet publish)

Publish the project so that it can run across platforms.

Dotnet Publish is released by default.

After publishing, navigate to the Publish directory and use dotnet App.dll to execute the app.

Below to publish across platforms.

Open app.csproj add <RuntimeIdentifiers>win10-x64;ubuntu.14.04-x64</RuntimeIdentifiers> in PropertyGroup node

First we need to dotnet restore. Restore time may be a bit long, you need to wait patiently.

dotnet Publish-r win10-x64

Once published here, you can navigate directly to the Publish publish directory and execute app.exe.

dotnet Publish-r ubuntu.14.04-x64

Upload the Publish folder to the Linux system, set the app's permissions to executable, and then./app can run.

dotnet Publish–r: Specifies the system ID in the Runtimeidentifiers node.

Learn more about the dotnet command from the new to the release Combat dotnet command.

This article is an update to the 2.9 dotnet command in the "ASP. NET core cross-platform development from the beginning to the actual combat", and also to the previous blog post, "The dotnet Command encyclopedia."

The time is really fast, the last article is actually a year ago article,. NET Core Update caused some of the content is not applicable, I hope the new content can help you.

If you think this article is helpful to you, please click " recommend ", thank you.

dotnet Command Combat

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.