Create and run an ASP. NET 5 Web site on Mac OS?
Tips
This article links: http://cnblogs.com/qin-nz/p/5035619.html or http://blog.qin.nz/aspnet5/aspnet5-first-app-on-mac-os.html
I believe that using MAC as the main model of the people will not play the ASP, so I really doubt this article will anyone read it?
Install the. NET version Manager (DNVM)?
First, we need to install the. NET version manager, which is actually a script file to help download and manage what is installed on OS x. NET run-time version.
Open Terminal, enter
Curl-ssl https://raw.githubusercontent.com/aspnet/home/dev/dnvminstall.sh| Dnx_branch =Dev sh && source ~/.dnx/dnvm/dnvm.sh
After the installation is complete, you can run the command with the dnvm
Help file displayed without any parameters.
Install the. NET Runtime Environment (DNX)?
First of all, you need to choose the installation mono
or coreclr
, starting from Beta7 CoreCLR is ready to use, but as of now, the default installation is Mono version. If you want to install mono version of the DNX, you must first install mono, more trouble, the details can refer to install mono on Mac OS X
Annotations
It is said that the use of the mono version of the restore package may also be problematic.
This article selects the CORECLR version of the runtime, with the following command to get the latest version of CORECLR, the default is x64.
DNVM Upgrade-r CORECLR
Currently the latest version is 1.0.0-rc1-update1
that after the installation is complete, you can use dnvm list
the view existing. NET Runtime Environment (DNX).
Well, so far, you've done all the installation, and you can start creating code from scratch using your favorite text editor. I recommend using Visual Studio Code
Install the initial code generator?
However, are you really going to start from scratch? If not, start with the template you already have. The Yeoman described below is to help us build an initial project.
If you want to install Yeoman, then you should install NPM first. I remember when I installed XCode, I had NPM.
Installing Yeoman and Bower?
NPM install-g Yo Bower grunt-cli Gulp
Install Omnisharp ASP. Generators?
Omnisharp ASP. NET generators, this is the thing used to generate the template, it needs to run with Yeoman, but this step is simple, just run
NPM install-g generator-aspnet
Create a project by template?
Using yo aspnet
the command, select the type you want to create. If it is a Web site, it is recommended to choose the application, you can choose the full version or the basic version. The full version contains the user authentication and login management, a lot of references, if you are learning purposes, or first select the basic of the more appropriate.
After selecting, enter the project name to complete the build.
Warning
There is a small bug, after creating the file, the program seems unable to exit directly.
Switch to the generated project files directory, run dnu restore
and bower install
restore the server-side and browser-side package references separately.
Annotations
For dnu restore
The bower install
differences, refer to dependency Management in ASP. NET 5
Run the code?
Next, you can theoretically use dnu build
(optional) and you dnx web
should be able to run the program up. But in fact, we need to find the project.json
file and delete the line in the running frame to compile on the dotnet451
Mac.
{ "Version": "1.0.0-*", "Compilationoptions": { "Emitentrypoint": true }, "Tooling": { "DefaultNamespace": "Basic" }, "Dependencies": { "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final", "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final", "MICROSOFT.ASPNET.MVC": "6.0.0-rc1-final", "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final", "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final", "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final", "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final", "Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final", "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final", "Microsoft.Extensions.Logging": "1.0.0-rc1-final", "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final", "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final" }, "Commands": { "Web": "Microsoft.AspNet.Server.Kestrel" }, "Frameworks": { "dnx451": {}, "Dnxcore50": {} }, "Exclude": [ "Wwwroot", "Node_modules", "Bower_components" ], "Publishexclude": [ "Node_modules", "Bower_components", "**.xproj", "**.user", "**.VSPSCC" ], "Scripts": { "Prepublish": [ "NPM Install", "Bower Install", "Gulp Clean", "Gulp min" ] }}
Now use dnu restore
, dnu buili
(optional) and run the dnx web
program, open the browser, visit http://localhost:5000 to see the site.
Little Tricks
The Web server running ASP. NET 5 is Kestrel and can be configured by Project.json for Kestrel.
OK, now you can successfully run a simple ASP. NET 5 website.
Next steps?
Get started with ASP. NET 5-Learn about an empty project
Application Startup Introduction
Create and run an ASP. NET 5 Web site on Mac OS