NET Core R2 Run Hello World

Source: Internet
Author: User
Tags dotnet

Install. NET Core R2 on CentOS 7 run Hello World

Objective

Last month, the latest version of the. NET Core was previewed, just experimenting on the window system. Originally wanted to release the official version of the time on the Linux system to try, it may take some time, just have a moment to toss.

Since the previously installed Ubuntu system is 16 and is not currently supported, it has not been tested on Ubuntu.

System Environment: CentOS 7 (1511) Minimal core version.

Installation

Tips:
Nodejs and Yeoman are used to automate the creation of ASP. NET projects, not mandatory items.
This article is an ASP. NET project created with Yeoman, so the installation of Nodejs and Yeoman is added.
Do not install if you feel you do not need it.

. NET core[must be]

1. Go to the official website to download. NET core:dotnet-dev-centos-x64.1.0.0-preview1-002702.tar.gz.

2. Move and unzip the downloaded installation file.

$ # CreateDotnet Folder $ mkdir ~/dotnet$ # copy dotnet install file to  Dotnet folder under $ cp dotnet-dev-centos-x64.1 .0.0-preview1-002702.tar.gz ~/< Span class= "Hljs-keyword" >dotnet$ # Unzip the installation file $ tar-xzf ~/dotnet/ Dotnet-dev-centos-x64.1.0.0- Preview1-002702.tar.gz$ # delete dotnet folder under the original file $ rm ~/dotnet/dotnet-dev-centos-x64.1.0.0-preview1-002702.tar.gz    

3. Add a soft connection that can be used globally.

-s ~/dotnet/dotnet /usr/local/bin

4. Test whether the installation was successful.

$ dotnet --version1.0.0-preview1-002702 #输出版本号
nodejs[Optional]

Do not use the system's own installation, the version is too low.

1. Go to the official website to download Nodejs installation files: Node-v4.4.5-linux-x64.tar.xz.

2. Copy and unzip.

# 创建nodejs文件夹$ mkdir /usr/local/nodejs$ # 复制node安装文件到nodejs文件夹下$ cp node-v4.4.5-linux-x64.tar.xz /usr/local/nodejs$ # 解压安装文件$ tar -zvxf /usr/local/nodejs/node-v4.4.5-linux-x64.tar.xz$ # 删除nodejs文件夹下的原文件$ rm /usr/local/nodejs/node-v4.4.5-linux-x64.tar.xz

3. Add a soft connection that can be used globally.

/usr/local/nodejs/node /usr/local/bin/node$ sudo ln -s /usr/local/nodejs/npm /usr/local/bin/npm$ sudo ln -s /usr/local/nodejs/node /usr/bin/node$ sudo ln -s /usr/local/nodejs/node /usr/lib/node$ sudo ln -s /usr/local/nodejs/npm /usr/bin/npm

4. Test whether the installation was successful.

$ node -vv4.4.5 #输出版本号$ npm -v3.9.5 #输出版本号
yeoman[Optional]

Yeoman is used to create an ASP, and requires the installation of the associated node plugin: Bower, Grunt, gulp.

1. Use NPM to perform installation commands

install -g yo bower grunt-cli gulp

Wait for the installation to complete.

2. Install the ASP.

install -g generator-aspnet

3. Adding system Variables

Add the Bin folder of node to the system variable, or you will be prompted that the plugin command installed by NPM does not exist.

Open the . BASHRC file in the user directory:

$ vi ~/.bashrc

Add the following at the tail:

export PATH="/usr/local/nodejs/bin":$PATH

Take effect with the source command:

source ~/.bashrc
vscode[Optional]

This can not be installed if you do not need to modify the code.

1. Go to the official website to download the installation package: vscode-x86_64.rpm

2. Perform the installation operation

$ rpm -ivh vscode-x86_64.rpm

3. Test whether the installation was successful.

$ code

If you can start vscode the installation is correct.

Note: If you are installing using a ZIP file, follow the. NET core step. Also need to install unzip

To install the C # Extension, in Vscode, press the shortcut key Ctrl + Shift + P and enter the following command:

install csharp
Creating a console Program

The steps are written directly in the code.

$ #创建文件夹$ mkdir ~/dotnetcore$ mkdir ~/dotnetcore/ConsoleApp$ cd ~/dotnetcore/ConsoleApp$ #新建控制台程序$ dotnet new$ #还原nuget包$ dotnet restore$ #编译$ dotnet build$ #运行$ dotnet run

Actual operation Diagram (example):

Creating an ASP Program

This document is created using Yeoman scaffolding.
If you do not create with Yeoman, it is recommended that you read the first chapter of the ASP.

1. Execute the command yo aspnet :

Select the third item, WEB application.

2. Select the UI framework, where Bootstrap is selected:

3. Enter the project name, which you can default:

4. Wait for the installation to complete

5. Follow the instructions above to execute

#还原nuget包$ dotnet restore$ #编译$ dotnet build$ #创建SQLite数据库$ dotnet ef database update$ #运行$ dotnet run

6. View Effects

Original: Install. NET Core R2 on CentOS 7 run Hello World

NET Core R2 Run Hello World

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.