Initial attempt on OSX 5

Source: Internet
Author: User

Last year Microsoft's most exciting news for the open source dog World was the news that ASP was open and open source.

According to Microsoft's introduction, with some of my previous summaries, you can see the following changes to the ASP. NET platform and:

    • The code is open source using the Apache protocol and hosted on Github.
    • The new C # compiler Roslyn.
    • A new cross-platform CLR (the JVM that corresponds to the Java platform).
    • New Project organization and build tool KVM.
    • Base Library Corefx.

These concepts are a bit of a cloud of deep fog, a careful study will find that, in fact, the use of ASP. JS and the Ruby community concept and architecture. Corresponds to the following:

Kvm

Corresponds to the Ruby community's RVM, nvm/n with the node. JS community. You can manage your ASP. NET execution Environment (CLR), such as specifying whether to use CORECLR or mono, and the specific versions of them. It's very similar in use.

KPM

corresponding to the Ruby community Gen, npm with the node. JS community. You can manage your third-party package dependencies. But the actual implementation, or the reuse of the first NuGet, the package is NuGet package. But the difference is that the Project.json file format is used as a declaration of dependency and will automatically help you manage circular dependencies. This is simply a direct reference to NPM, the format is very similar.

CoreCLR

A new lite cross-platform CLR, (supposedly inherited from Silverlight?). ), implemented in C + +, and very thin (only a few M size), so you can directly in the Project.json to specify which version to use, the build time directly online download. Of course, we have been concerned about the mono also found here their role, you can also choose mono as the implementation environment (at this stage coreclr has not production Ready,mono is a better choice). Of course you can also use the traditional CLR as the runtime (now called the full. NET CLR).

Roslyn

The C # compiler, written in C #, is more open and modular, mainly to help you compile the code you write and the code that the third party relies on. And the visual will be in code completion and code refactoring, because Microsoft is not intended to use Virtual Studio for Linux and OSX users, C # This type of static language is still more dependent on code.

Corefx

CORECLR is just a basic function of string in clr,c# or written in C #, there are many other base libraries, this part of the code as COREFX exist, and most of the code is cross-platform. This includes an array of classes such as IO, threading, Linq, collections, and so on. This will ensure compatibility regardless of whether your code is running in CORECLR or mono environments.

Kestrel

Microsoft is also not planning to cross-platform IIS to Linux and OSX, so with Kestrel this HTTP Server, based on LIBUV. It is for the development environment, but it is estimated that the strength of the online service can be achieved.

Although the above concepts are many, the installation and use of the ASP. NET 5 is not complicated, just install the KVM tool as well.

KVM Project is https://github.com/aspnet/Home (the project name is really a bit confusing, directly called KVM or K), is actually a few shell scripts (Bash/powershell).

The following content is based on the KVM beta3

OSX directly with homebrew installation is good, Microsoft has done a brew tap, after the official release should be submitted to homebrew.

Brew Tap aspnet/k  install KVM  

Installation will have a Postinstall process, automatically help you execute, the ASP. NET kvm upgrade related files are Unix to help you in the ${home}/.k/directory, and automatically use mono as runtime:

Tree ~/. K/users/asaka/. K├──alias│└──default.alias└──runtimes└──kre-mono.1.0.0-Beta3├──bin│├──microsoft.codeanalysis.csharp.desktop.dll│├──microsoft.codeanalysis.csharp . Dll│├──microsoft.codeanalysis.desktop.dll│├──microsoft.codeanalysis.dll│├──microsoft. Framework.applicationhost.dll│├──microsoft.framework.runtime.loader.dll│├──microsoft.framework.run Time.        Roslyn.common.dll│├──microsoft.framework.runtime.roslyn.dll│├──microsoft.framework.runtime.dll │├──microsoft.net.http.client.dll│├──newtonsoft.json.dll│├──system.collections.immutable.d Ll│├──system.reflection.metadata.dll│├──k│├──klr│├──kpm│├──kre        . host.dll│├──kre.mono.managed.dll│└──lib│├──microsoft.framework.designtimehost       ││└──microsoft.framework.designtimehost.dll│├──microsoft.framework.packagemanager│ │└──microSoft. Framework.packagemanager.dll│└──microsoft.framework.project│└──microsoft.framework.pro Ject.dll├──kre-Mono.nuspec└──package└──services└──metadata└──core-PROPERTIES└──5D2FD91BEC5D411CA81C8C3DF4D03749.PSMDCP ADirectories, -Files

One thing that's not Unix is that KVM implements a shell function instead of an executable file, so you need it every time you use it source kvm.sh (looks like RVM too?). )。 This can be done in places such as. zshrc.

kvm installYou can then install other versions of the runtime, which are also loaded into the ${home}/.k/directory. kvm useYou can select a runtime as the current runtime. There are a series upgrade alias of orders, similar to RVM/NVM. Roslyn is also included in the KVM runtime, but there is no executable file to launch directly.

The KVM-installed runtime also contains KPM, KLR, and K three command-line tools. KLR is actually the current CLR, which is actually the start of mono. KPM is actually nuget,k similar to building tools that help you set up environment variables, compile code, and help you launch your code.

Just now KVM of that repo inside still have several sample, can clone down oneself run to play. But now in the default runtime, in addition to ConsoleApp I can not run here, it is estimated that a long time without maintenance, dependent on the problem or something.

When running a project, you need to use kpm restore installation dependencies. For a ConsoleApp class project, k run you can run your code directly, which is the long-running function that was compiled directly Main .

Web-class projects that need k web to be run using the built-in HTTP Server. But the few examples of sample are not running through. This is also used k kestrel to start the Kerstrel run.

A closer look will reveal that if you write a command-line tool, you can arbitrarily organize your code in your own way by writing Project.json to specify dependencies. But for an ASP, or something like that, there's no web. config, but it's tedious to knock out a project frame out of thin air. It's also tedious to add a Controller class to ASP, which is something that Virtual Studio can help us with.

So we need a scaffolding tool, and this is the perfect solution for rails, and rails itself can do it for us. Later, the node. js Community's yo project used this feature as a reference to generate a variety of front-end and node. JS projects, and Yo has not qualified himself only in the front-end and JS community, itself by writing new generator to support various types of projects.

So there's the Generator-aspnet project. This project belongs to the OMINISHARP organization, not the official Microsoft, but the promoter is indeed Microsoft official, so you know what I'm talking about.

With Yo and generator-aspnet, you can easily generate ASP. NET and use a variety of scaffolding functions.

Install -g yo  install -G generator-aspnet  

Try it:

Yo aspnet _-----_    |    | .--------------------------. |--(o)--|      | Welcome to the |   `---------´   | Marvellous ASP.5|(_´u ' _)|        generator!    | /___a___\'--------------------------'| ~  |   __'.___.'__ ´   `  |°´y '? What type of application DoWant to create?(use arrow keys)? Empty Application Console Application Web application Web API Application Nancy ASP application Class library

The types of projects that are now supported are also more complete, and even support Nancy, a lightweight. NET Web framework that resembles Sinatra and express.

After the project is created, you can go to the project root directory, and if it's a WEB application (that is, the previous MVC framework), it's best to run the project with NPM on Bower and Grunt-cli,yo, which is dependent on the two to build the front-end , the build process is performed during the restore process):

KPM Restore  kpm build  K Kestrel  

Of course I don't know why, I can't run around here k kestrel k web , or because of Beta. However, you can observe the project directory structure, found that the building front-end grunt and Bower have been configured, and by default enabled Razer to do the template engine, but also using the Entity framework as an ORM framework, very well.

In addition to the generator-aspnet documentation, there are scaffolding as follows:

Aspnet:mvccontroller  aspnet:mvcview  aspnet:webapicontoller  aspnet:class  aspnet:startupclass  Aspnet:bowerjson  aspnet:coffeescript  aspnet:config  aspnet:gulpfile  aspnet:htmlpage  Aspnet:javascript  aspnet:jscript  aspnet:json  aspnet:packagejson  aspnet:textfile  Aspnet:typescript  

Very good and very powerful.

You can read more about this in my blog: http://aisk.me/first-look-at-aspnet-5/

Initial attempt on OSX 5

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.