📜 ⬆️ ⬇️

ASP.NET vNext application for Ubuntu

I want to tell you about my experience in deploying ASP.NET vNext under Ubuntu 14.04. I myself have been developing for a long time under Windows and have dealt with Unix systems, then in passing and imperceptibly for me and for Unix systems. But despite this, the news about the transfer of the .Net part to OpenSource with Unix support pleased me as an occasion for the further development and expansion of knowledge boundaries.

As a result of the brief torment and research of various forums and the issue of trackers, I managed something that previously seemed unthinkable. Code written in C #, which runs in an environment invented and developed in MS, which is an ASP.NET MVC application (!) Is working.

First you need to download and install the OS itself. I took the image from the official site.
')
http://www.ubuntu.com/download/desktop/contribute/?version=14.04.1&architecture=amd64 


Then I deployed this image on VirtualBox, because it was just an experiment.

To run an application on ASP.NET vNext under Ubuntu, we need two things: a project designed in the new ASP.NET vNext style and deployed and launched by KRuntime with the option of raising the Kestrel web server.

Create application


The first problem is solved simply. You can take a very simple example from a githaba:

 https://github.com/aspnet/Home/tree/master/samples/HelloWeb. 

If the git is not installed yet, install it:

 sudo apt-get install git 

Then we clone our repository with examples:

 git clone https://github.com/aspnet/Home.git 


Infrastructure


The second task is more difficult, but also solvable. The process consists of the following steps:

  1. Mono installation

     wget http://download.mono-project.com/repo/xamarin.gpg sudo apt-key add xamarin.gpg echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee --append /etc/apt/sources.list.d/mono-xamarin.list sudo apt-get update sudo apt-get install mono-complete 

  2. KRuntime installation

    Allow kvm to climb on their sites for their certificates.
     sudo certmgr -ssl -m https://go.microsoft.com sudo certmgr -ssl -m https://nugetgallery.blob.core.windows.net sudo certmgr -ssl -m https://nuget.org mozroots --import --sync 

    Download the kvm installation script and launch it, and then run the kvm upgrade. Now everything we need is already installed:

     curl https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.sh | sh && source ~/.kre/kvm/kvm.sh && kvm upgrade 

    We pull out all the dependencies of KRuntime:

     kpm restore 

  3. Install bower

    If NPM is not installed, install:

     sudo apt-get install npm 

  4. Start the web server

    Compile libuv, and (hard hack), copy the assembly to the KRuntime folders, because there are incompatible versions by default, because MS has not yet worked on supporting Linux.

    Currently KRuntime requires version 1.0.0-rc1 and KRuntime itself is in version 1.0.0-beta1. All this is changing very quickly, so it is always necessary to know which versions were last linking to each other. (The script was taken and slightly corrected from here ).

     wget http://dist.libuv.org/dist/v1.0.0-rc1/libuv-v1.0.0-rc1.tar.gz tar -xvf libuv-v1.0.0-rc1.tar.gz cd libuv-v1.0.0-rc1/ ./gyp_uv.py -f make -Duv_library=shared_library make -C out sudo cp out/Debug/lib.target/libuv.so /usr/lib/libuv.so.1.0.0-rc1 sudo cp out/Debug/lib.target/libuv.so ~/.kpm/packages/Microsoft.AspNet.Server.Kestrel/1.0.0-beta1/native/darwin/universal/libuv.dylib sudo ln -s libuv.so.1.0.0-rc1 /usr/lib/libuv.so.1 

    All work with KRuntime is done on the application, so we must be in the directory with the project where project.json is located. In our case we do:

     cd Home/samples/HelloWeb/ 


    We run our application on the kestrel server (all settings in the project.json file):

     k kestrel 

    Open the browser and go to:

     http://localhost:5004 

    Well, or another address specified in project.json next to kestrel:

The process is very unusual, much has changed, but the development itself is happy. It is also nice that restrictions are becoming less and the boundaries are blurred.

Source: https://habr.com/ru/post/243773/


All Articles