ASP. NET 5 (vNext) Linux deployment, asp. netvnext

Source: Internet
Author: User
Tags asp net oracle vm virtualbox vm virtualbox

ASP. NET 5 (vNext) Linux deployment, asp. netvnext
Introduction

First, we need to clarify the following basic concepts.

LinuxRelated

Ubuntu

Ubuntu is a free and open-source desktop PC operating system based on linux. It is very compatible with Intel's ultraboo positioning. It supports x86, 64-bit, and ppc architectures and supports Web browser WPS. Ubuntu is based on the Debian release and GNOME desktop environments. Starting from version 11.04, the Ubuntu release gave up the Gnome desktop environment and changed it to Unity, different from Debian, Debian releases a new version every six months. The goal of Ubuntu is to provide a general user with the latest and stable operating system built mainly from free software.

Sudo

Sudo is a linux system management command. It is a tool that allows common users to execute some or all of the root commands, such as halt, reboot, and su. This not only reduces the logon and management time of the root user, but also improves security. Sudo is not a substitute for shell. It is intended for every command.

Apt

Advanced Packaging Tool (apt) is an installation package management Tool in Linux. APT consists of several programs whose names start with "apt. Apt-get, apt-cache, and apt-cdrom are command line tools used to process software packages.

Libuv

The cross-platform asynchronous IO library is a required component of the Kestrel Server and must be installed before the final operation.

VirtualBox

VirtualBox is an open-source Virtual Machine Software. VirtualBox is a software developed by Innotek, Germany and developed by Sun Microsystems. It is written using Qt and officially renamed Oracle VM VirtualBox after Sun is acquired by Oracle. Innotek releases VirtualBox with GNU General Public License (GPL) and provides code for binary and OSE versions. Users can install and execute Solaris, Windows, DOS, Linux, OS/2 Warp, BSD, and other systems on VirtualBox as client operating systems

Curl

CURL curl-O output result original author Daniel Stenberg initial version 1997 stable version 7.40.0 (January 8, 2015, 27 days ago) active development status
Programming Language C operating system cross-platform FTP/HTTP license protocol Free Software: MIT/X derivate license website curl. haxx. se cURL is a File Transfer tool that uses the URL syntax to work under the command line. It was first released in 1997. It supports file upload and download, so it is a comprehensive transmission tool, but traditionally, cURL is called a download tool. It is widely used in Unix and multiple Linux distributions, and has DOS, Win32, and Win64 versions.

Linux knowledge is not the main content of this article. For more information, see related documents.

. NETRelated

Mono

Mono is an open-source project launched by Novell (initiated by Ximian and led by Miguel de lcaza) to create. NET on Linux. It contains a C # Language compiler, a clr runtime, and a group of class libraries, and implements ado net and asp net. Enables developers to use C # To develop programs in Linux .)

DNVM

(. NET Version Manager): to achieve cross-platform purposes, Microsoft provides the DNVM function, which is ASP. NET, which is a group of Powershell scripts used to start a specified version of ASP.. NET runtime environment, and you can use the Nuget tool to manage various versions of ASP.. NET Runtime Environment (DNX), and upgrade accordingly.

DNX

(. NET Execution Environment): DNX is the runtime Environment of ASP. NET programs. It is used to start and run ASP. NET programs. The running environment includes the compiling system, SDK tool set, and Native CLR host environment. You can use DNVM to manage various versions of DNX. For example, the dnvm list command can list all available DNX environments, dnvm install 0.1-alpha-build-0446 can install the specified version of DNX. dnx folder, you can go to % USERPROFILE % \. in the dnx \ runtimes directory, find all installed versions of DNX. Different operating systems have different DNX versions.

Dnu command

(DNX Utility): It is a command line Package Manager, which is included in DNX. Therefore, if DNX is installed, you can use the dnu command, it can be used to restore the program package, install the program package, and deploy the program package. the custom assembly in json is automatically downloaded for use.

Dnx command

Dnx.exe is a command line tool used to start the Self-Host environment (Self-Hosting). When you use the command line code to start a program in the Self-Host environment, dnx searches for and calls the CLR Native Host, the dnx command is the entry point of the entire running environment. You can use dnx run to start the program.

Kestrel

ASP. NET 5 is a Web Server implementation based on the libuv component.

NuGet

Nuget is an open-source project under the. NET platform. It is an extension of Visual Studio. When using Visual Studio to develop applications based on. NET Framework, Nuget can add, remove, and update references in projects more quickly and conveniently.

 

About ASP. NETCore technologies,For more information, see Uncle Tom's blog:

Interpretation of ASP. NET 5 & MVC6 series (4): Core Technology and Environment Configuration

Install Ubuntu

Taking Ubuntu as an example, my configuration environment is:

L HOST: Win8.1 and VS2015 RC

L Virtual Machine: VirtualBox-4.3.28-100309-Win

L Linux: ubuntu-15.04-desktop-amd64

The installation process of these software is more user-friendly.

After the installation is complete and enters the system, clean up the shortcut on the left side and drag out common terminal commands. We will go to the following interface to go to the next installation step.

Install MONO

Run the following command line to install MONO-the download may take a long time.

Sudo apt-key adv -- keyserver keyserver.ubuntu.com -- recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF

Echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee/etc/apt/sources. list. d/mono-xamarin.list

Echo "deb http://download.mono-project.com/repo/debian wheezy-apache24-compat main" | sudo tee-a/etc/apt/sources. list. d/mono-xamarin.list

Sudo apt-get update

Sudo apt-get install mono-devel

 

We recommend that you run the problematic command in sequence and run the problematic command again. The following result indicates that the Mono installation is complete:

 

If the installation is not completed successfully, refer to the MONO Project website to find the latest installation method.

Http://www.mono-project.com/docs/getting-started/install/linux/

 

Install DNVM

First install the curl Program

Sudo apt-get install curl

Then use curl to install DNVM

Curl-sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH = dev sh & source ~ /. Dnx/dnvm. sh

After the installation is complete, use the dnvm upgrade command to obtain the latest running environment

Dnvm upgrade

If the update fails, you can add the-f parameter to forcibly overwrite the update.

Finally, run the following command to confirm the current running environment

Dnvm list

 

Because the dnx version of VS2015 RC is 1.0.0-beta4, make sure that the current active version is 1.0.0-beta4, in fact, it is okay if there are no 11855 or)

In addition, you can find that the dnx and dnu commands (you can run these two commands on the console and see the help information) have been deployed, and the dnvm installation is complete.

Configure ASP. NET code

In the Window host, VS 2015 is used to create a WebApi program of vNext version.

 

Name this project WebApi2015. after the project is created, package the program directory and send it to the Ubuntu virtual machine.

Decompress the package in any directory of the VM.

In addition, we can use Visual Studio Code for Code editing in non-Windows environments. This tool is very easy to install. For specific installation methods, refer to the official website:

Https://code.visualstudio.com/Docs/setup

Although this tool is not as convenient as VS, it is much more advanced than Text Editor:

Below we will make some adjustments to the project file:

 

L add references to the Kestrel component. This is a required Web Server in Linux.

L add the command line of Kestrel and set the startup URL to http: // localhost: 5000. This step is required. Otherwise, subsequent dnx commands cannot be executed.

L move project_readme.html to wwwroot as a static page that can be displayed.

Of course, these adjustments can also be adjusted in Windows first, and then copied.

Deployment and Operation

Open a terminal and set the current path to src/WebApi2015 in our project, that is, the directory where project. json is located.

First, use the dnu command to restore all relevant components:

Dnu restore

Note that this operation is often interrupted due to network problems. You can execute this command repeatedly. (Do not forcibly interrupt this command, it will cause a bad package), until a large amount of installing information appears and complete the project. lock. for json files, the restoration process ends successfully, for example:

 

Then run the following command to execute the ASP. NET 5 program.

Dnx. kestrel

However, an error may still be reported at this time because the libuv component is not installed on the newly installed system. In the end, we need to use the following command to install the libuv component.

Sudo apt-get install automake libtool

Curl-sSL https://github.com/libuv/libuv/archive/v1.4.2.tar.gz | sudo tar zxfv--C/usr/local/src

Cd/usr/local/src/libuv-1.4.2

Sudo sh autogen. sh

Sudo./configure

Sudo make

Sudo make install

Sudo rm-rf/usr/local/src/libuv-1.4.2 & cd ~ /

Sudo ldconfig

 

After installation, runDnx. kestrel , Run through

 

Access through a browserHttp ://Vm ip: 5000/Project_Readme.htmlOrHttp ://Virtual Machine IP Address: 5000/api/valuesThe page and default WebApi returned content are displayed. if you are interested, you can add other pages to wwwroot or add other webapis to Controller to try-or even add the Controller, View, and Model files to display MVC content.

Conclusion

Of course, at present, the program we run is just a very simple version, and it does not include complex components such as EF, SignalR, and Identity. However, throughout the deployment process, we can feel that the gap is very small. first, run and deploy the environment DNVM and dnu. The dnx command is consistent with the environment of VS 2015, and the component packages are obtained from Nuget, this is not much different from the standard Windows development environment, so it is foreseeable that even more complex ASP.. NET 5 applications can still be fully deployed to the Linux environment. In addition, EF technology will provide better support for MSSQL and other cross-platform databases in the future ,. NET developers can launch their own Linux-Kestrel/Jexus-MySQL-ASP in the future.. NET cross-platform solution.

Related Article

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.