. NET Core cross-platform development

Source: Internet
Author: User
Tags dotnet net command net command line

For. NET open source plan people who must be interested are already eager, but the real use of it for development is currently not much. After all,. NET Core was released to the 1.0RC2 version at the time of this article. The official version is expected to be there for some time. And most people are just waiting, even if development still uses the. NET Framework. The other thing I have to say is. NET open source progress is amazing but the community building still needs to be improved, a lot of supporting things are not complete. Java may lag behind in the language hierarchy. NET but Java's community power is far less than. Net.

First, install the SDK

. NET Core Release: Https://www.microsoft.com/net/core

. NET core provides the core of the running components, and the modules to be used are obtained through nuget. Development can be completely independent of the. NET Framework and platform. However, the functionality of. NET core is not as full as the. NET Framework. The WebForm of the web domain has been discarded. WinForm is no longer in the open source program. To use or to be cautious, after all, this is just the beginning.

1.windows Platform Installation SDK

Download and install it directly. https://go.microsoft.com/fwlink/?LinkID=798398

2.Linux Platform Installation SDK (test system: Ubuntu 14)

Official instruction manual: Https://www.microsoft.com/net/core#ubuntu

' echo "Deb [Arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet/trusty main" >/etc/apt/sources.list.d/ Dotnetdev.list'sudo apt-key adv--keyserver apt-mo.trafficmanager.net--recv-keys 417a0893sudo apt-get  updatesudo apt-get install dotnet-dev-1.0. 0-preview1-002702

There are several main points to note:

Ubuntu 16 was not successfully installed when testing with Apt-get. Currently only tested successfully in UBUNTU14.

Direct use: Apt-get install dotnet Get the version is not clear, look at the installation of the version number seems to be the latest, but the creation of the project is not up-to-date. As a result, the version number is specified at the time of installation by the official method.

3. The installation completes the environmental test

Instructions for use:

Dotnet--info

The test results are as follows:

C:\>dotnet-info.net Command line Tools (1.0.  0-preview1-002702) Product information:version:     1.0. 0-preview1-002702  Commit Sha:  6cde21225eruntime environment:os Name:     Windows OS Version:  10.0. 10586 OS platform:windows RID:         win10-x64
[Email protected]:~$ dotnet--info.net Command line Tools (1.0.  0-preview1-002702) Product information:version:     1.0. 0-preview1-002702  Commit Sha:  6cde21225eruntime environment:os Name:     ubuntu OS Version:  14.04  OS platform:linux RID:         ubuntu. 14.04-x64

Ii. Creation of Helloword program

1. Create a console project:

New

Use the dotnet new directive to quickly create a project.

dotnet new–t Console to create a console project. The current project type can only create console projects, there are no other optional types, and you may want to create more project templates later.

Dotnet New–l C # Creates a project using the C # language. Only C # and F # are currently supported.

Compile and run the project:

dotnet Restoredotnet Run

Use dotnet resotre to restore package references

Run the program using dotnet run

Compiling code using dotnet build

Publish a project using dotnet Publish

For detailed instruction parameters, please refer to the instruction's help description.

2. Create a Web project

Because creating a directive does not support creating a Web project, you cannot create it directly using the Create directive, but it is not advisable to create the project manually by using the Project.json. You can use tools and templates to quickly create projects.

Available Template cases: Https://github.com/aspnet/cli-samples

You can use GIT tools directly to copy to local use.

Another thing to be aware of:

DNX Start mode is currently not used in the new version, all changed to dotnet instructions. The Web project starts in the same way that the console project starts.

Linux works as follows:

Third, use the editor

Cite the official propaganda slogan:

It is very easy-to-get started with. NET Core on your platform of choice. You just need a shell, a text editor and ten minutes of your time.

The feeling is aptly described, but it is estimated that there will be a lot of people forced. VS, how do you develop it? The official said that just a text editor, so powerful vs don't use a text editor to develop, will developers accept it? As far as I am willing to change is only a few people. After all, most of them are developed on the Windows platform, or they are ultimately selected or developed with Windows+vs, and may be published on other platforms. This is very detrimental to the formation of other platform tool chains.

1. Installing Vscode

Download and install Vscode:https://www.visualstudio.com/en-us/products/code-vs.aspx

Installing the C # Development support plug-in

Open Vscode use Ctrl+p to bring up the instruction bar and enter the installation instructions:

Ext Install CSharp

Plugin website: https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp

When the installation is complete, you will be prompted to restart the Vscode, and you can start the development after rebooting.

2. Run the project using Vscode compilation

Use Vscode to open the created project folder. The default item does not have a. Vscode folder, which will be prompted at the top of the message bar after it is opened and automatically created after clicking OK. Vscode folder.

The folder contains the following:

Launch.json and Tasks.json two files, used to configure the debugger and debug commands.

Open the code file will find that the code will have a lot of exception information, generally referred to the package is not loaded, you can use the Restore command to revert or wait for the vscode load to complete, may prompt in the notification bar to restore the package.

Debug run using F5. The C # Debug plug-in provides several ways to start debugging, and using Web launch will automatically open the browser by default. Breakpoint Debug Single-step tracking the basic difference is not very large, daily development enough.

Run effect

Issues to be aware of:

(1) If you skip the step of adding a debugger, it is possible to compile the times wrong. You only need to Launch.json modify the corresponding parameters. Such as:

(2) Troubleshooting ' Error while installing. NET Core Debugger '

If you have the above tips, use dotnet--info to see if you can output normal information, and if not, reinstall the supported version of the. NET Core SDK. If you are prompted for restore failure, check your network connection.

(3) On the Windows platform, if you are prompted to find symbols, enable portable PDBs

If the buildoptions option is not found, the name in the old version is called: compilationoptions

Concluding remarks: this time. NET open source is not so much a kind of helplessness as Microsoft's kindness. In addition, Vscode in the text editing and multi-project management and many other aspects there is a lot of room for improvement. There are many gaps in the construction of the community to be replenished as soon as possible. Every time I look at the documentation, I see the future, hasn ' t been written yet and other words as a kind of inexplicable sense of loss.

. NET Core cross-platform development

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.