What is DNX in Visual Studio 2015 & how do I use it?
I see DNX is Dot Net eXecution environment. What I would like to know is what exactly is it and how is it used?
DNX is an SDK of .Net similar but not at all identical to the .Net Framework. The differences are quite dramatically including topics like
-
API size: The API is identical where it is shared, but it is a subset of the .Net Framework. The framework libraries are called CoreFx and come from the line of the Windows Store and Silverlight API packages. The CoreFx library packages are either directly implemented (dnxcore50) or are type forwarders to the .Net Framework (dnx46). Be aware 80% of the .Net Framework are app models like WPF and WinForms or Windows libraries like WMI, ... In most cases, these libraries are not used.
-
runtime support: The SDK runs either on top of the .Net Framework runtime (Windows), or the CoreCLR (Windows, Mac, Linux, FreeBSD) or Mono (Windows, Mac, Linux, ...).
-
deployment pattern: The libraries including the runtime are deployed to the folder of the application. This prevents bugs due to Framework updates and also allows Microsoft to evolve the .Net ecosystem in a more "risky" way.
-
compilation patterns: DNX has a integrated compilation pipeline (Roslyn based) which compiles source code on the fly, therefore you can run the software directly from source code compiled within memory without files (blur the difference between runtime and design time). Especially good for ASP.Net scenarios. Pre Compilation is supported.
-
platform integration: DNX is not platform integrated (means: you have to invoke it like you do with mono or java).
-
NuGet Everything & new project system: The clr, the libraries (1st, 2nd and 3rd) and the app model are all NuGet packages. Projects can output NuGet packages by default. Source Code projects, NuGet packages and DLL are of same priority in the new project system.
-
open source: CoreCLR, CoreFx, Roslyn, DNX, ASP.Net are all open source under MIT or Apache 2 license.
The DNX SDK evolved from the ASP.Net team and is supported by the CoreCLR and CoreFx projects of the .Net Framework team. The CoreFx/CoreCLR/Roslyn modules (which are not identical to DNX) are also used by other SDKs like the Universal Windows Platform (UWP) which targets other features (like native compilation and the WinRT app model).
And now the ugly but good news:
- DNX like UWP are essentially a big cleanup of the .Net offered by Microsoft with the classic .Net Framework going to maintenance (which is nothing bad). Our .Net Framework knowledge is still useful but we have to relearn our platform.
- UWP is for desktop application. It is the preferred model by the Windows team. WPF and WinForms are NOT the preferred way and are essentially deprecated. Let it go.
- DNX is for web development and server applications (which are essentially the same).
- Windows is no longer the only platform for Microsoft. They embrace the other platforms like Linux (cloud) and Mac (developers). They support Xamarin for their Android and iOS product lineup.
- It is a library and third party hell. Welcome to 2015. IMO nothing good here.
And this is really good and keeps .Net relevant (vs. e.g. Node.js).
In Visual Studio 2015 you can utilize it, using the ASP.Net 5 project templates.
ps: Wrote to much again and read your comment too late. Hope it helps!
pps: be aware... DNX is history. The CLI takes over.. Which covers most of its characteristics but not all.
ppps: this comment is not reflecting .NET Core (in which DNX ultimatively evolved) anymore. .NET Core and later ".NET 5" are very different beasts.