This was written for the RC1 version of ASP.Net Core, but the idea of using multiple frameworks is still a core concept of ASP.Net Core 1.0.
Also, Microsoft has recently stated that project.json will go away around the time the new version of Visual Studio is released. The idea is that settings will move back to the .csproj file to enable better integration with MSBuild in that time frame.
ASP.NET Core 1.0 can run on top of both ASP.NET 4.x and ASP.NET Core 1.0 frameworks.
This is REALY cool. It can also be very confusing. Why would you want to use both? Currently the Core 1.0 is limited and there are tools that we just dont have available to us yet. Also you may be porting over old code or referencing a old class library that depends on specific resources built around ASP.NET 4.x and you dont want to go through the hassle of upgrading and rewriting everything. Check out your project.json file to configure these options.
what is project.json?
New to ASP.Net Core 1.0! The project.json file defines your package metadata, your project dependencies and which frameworks you want to build for. (relatively similar to ASP.NET 4x’s package.config). You can remove or add a dependency from this file. When you do, you’re solution will automatically be updated to reflect those changes. You can also set what frameworks you want to app to compile across here!
what is DNX (.Net Execution Enviroment)
The DNX is a runtime environment that has everything you need to create a .Net application. Next time you create a new core 1.0 project, what your essentially creating is a DNX project, whether its a web app or api. From the ASP.Net Docs…
The RC1 release of .NET Core and ASP.NET Core 1.0 introduced DNX tooling. The RC2 release of .NET Core and ASP.NET Core 1.0 moved from DNX to the .NET Core CLI.
The majority of this post was written using .Net Core RC1. BIG changes were made between versions RC 1 and RC 2. Those are documented here. The details in the following example are obsolete but the idea of incorporating multiple frameworks still exists.
Here is how project.json would look in an app relying on multiple frameworks
So as you can see, this give you a lot of flexibility.
- Targeting older frameworks like dnx451 will be great porting over existing code and ensuring compatibility with other existing code or class libraries you may have build in the past.
- Targeting the new
dotnet5 or net core frameworks will let you take advantage of the new Core CLR. Thus setting you up with many new features as well as the ability to develop and run your apps on Windows, Linux, and OS/X!