September 2, Microsoft released the ASP. NET 5 Beta7 (see announcing Availability of ASP. 5 Beta7). The biggest highlight is that DNX can already be run entirely on coreclr, that is, running DNX on Mac/linux without the need for mono, before you have to install mono to run the Dnu restore installation NuGet package.
Our ASP. NET 5 cross-platform sample site About.cnblogs.com was previously run on ASP. NET 5 Beta5 (see the new features of ASP. NET 5 Beta5 for displaying CLR and operating system information). 2 months running down, the biggest feeling is kestrel too unstable, almost every day will hang off.
Today we decided to upgrade the sample site from ASP. NET 5 Beta5 to Beta7, which is the main share of the upgrade steps and the issues encountered.
This time we switched the server OS from CentOS to Ubuntu.
The first installation is DNVM, the installation steps are as follows:
The next step is to install DNX:
installation command:
# DNVM Upgrade-r coreclr
Installation Result:
Determining latest Versionlatest version is 1.0.0-beta7 downloading dnx-coreclr-linux-x64.1.0.0-beta7 from https:// www.nuget.org/api/v2Download:https://www.nuget.org/api/v2/package/dnx-coreclr-linux-x64/1.0.0-beta7########### ############################################################# 100.0%installing to/root/.dnx/runtimes/ Dnx-coreclr-linux-x64.1.0.0-beta7
The next step is to install the Linux libraries required to run the DNU Restore command.
- apt-get Install Libunwind8
- apt-get Install Libcurl3-dev
Next, start using the new version of DNX to run the ASP. NET 5 project where the sample site resides.
First install the NuGet package with Dnu restore, and the results are as follows:
# Dnu Restoremicrosoft. NET development Utility coreclr-x64-1.0.0-beta7-15532 GET https://api.nuget.org/v3/ Index.json OK https://api.nuget.org/v3/index.json 5354msRestoring Packages For/data/aboutus/project.json ... Installed: Package (s) to/root/.dnx/packages
The next step is to use the DNX command to run the site, starting from beta 7 in the current directory run does not need to enter the point number, just the following command:
Dnx Kestrel
Run the site first encountered error:
System.MissingMethodException:Method not found: ' Microsoft.Framework.Configuration.IConfiguration Microsoft.Framework.Configuration.IConfigurationBuilder.Build () '. At Microsoft.AspNet.Hosting.Program.Main (string[] args)
This is because the Kestrel package changed its name, changed from Kestrel to Microsoft.AspNet.Server.Kestrel, so to change in the Project.json.
{ "Webroot":"wwwroot", "Exclude": ["wwwroot"], "commands":{ "Kestrel":"Microsoft.AspNet.Hosting--server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:8001 " }, "Dependencies":{ "Microsoft.AspNet.Server.Kestrel":"1.0.0-*", "MICROSOFT.ASPNET.MVC":"6.0.0-*", "Microsoft.AspNet.StaticFiles":"1.0.0-*", "Microsoft.AspNet.Diagnostics":"1.0.0-*", "System.Runtime.Serialization.Primitives":"4.0.10-*" }}
To continue running Dnx Kestrel, a new error has occurred:
/data/aboutus/extensions/htmlhelperextensions.cs (21,24): dnxcore,version=v5.0 error Cs0266:cannot implicitly Convert type ' Microsoft.AspNet.Html.Abstractions.IHtmlContent ' to ' Microsoft.AspNet.Mvc.Rendering.HtmlString '. An explicit conversion exists (is you missing a cast?)
This is because the type of the Ihtmlhelper.raw return value in the new version of ASP. NET MVC is changed from htmlstring to Ihtmlcontent, so change the return value type of the extension method mentioned in the error.
Public Static class htmlhelperextensions{ publicstaticihtmlcontent tablink ( this ihtmlhelper HtmlHelper, string string string viewName) { //...
And to add a namespace--using Microsoft.AspNet.Html.Abstractions;
Continue running, continue error:
Unable to load LIBUV. Make sure LIBUV are installed and available as libuv.so.1 at Microsoft.AspNet.Server.Kestrel.Networking.Libuv.Load ( String dlltoload)
This is because Kestrel requires LIBUV to run, and then you run the following command to install LIBUV:
Apt-get install make Automake libtoolcurl-ssl https://github.com/libuv/libuv/archive/v1.4.2.tar.gz | sudo tar zxfv--c/usr/local/srccd/usr/local/src/libuv-1.4.2sh autogen.sh./configuremakemake installrm-rf/usr/local/ src/libuv-1.4.2 && CD ~/ldconfig
After the installation of LIBUV, finally successfully run the site!
# DNX Kestrelapplication started. Press CTRL + C to shut down.
However, the following error occurred while accessing the site with a browser:
The type or namespace name ' Runtime ' does not exist in the namespace ' microsoft.framework ' (is you missing an assembly re Ference?) Public Microsoft.Framework.Runtime.IRuntimeEnvironment env {get; private set;}
This is an error in the MVC view, and it's the name of the change, Iruntimeenvironment all namespaces are changed from the original Microsoft.Framework.Runtime to Microsoft.Dnx.Runtime, so the view is changed to the following code:
@inject Microsoft.Dnx.Runtime.IRuntimeEnvironment Env
After solving this problem, the site about.cnblogs.com can access the normal, the upgrade will be completed successfully!
Hope that the new kestrel can stabilize some.
. NET Cross-platform tour: Upgrade the sample site from ASP. Beta5 to Beta7