DNX overview, Project Overview
1. What is the. NET execution environment?
. NET Execution Environment (DNX) is an SDK and runtime Environment that contains all the components you need to create and run. net applications. It provides a host process, CLR host logic, and management entry point. DNX is created to run cross-platform asp.net Web applications. However, it can also execute other types of. net applications, such as console applications.
2. Why create DNX?
DNX provides an environment for development and execution on different platforms. You can use DNX for development on one platform and deploy it on another platform.
DNX simplifies the development of cross-platform applications. It is responsible for the CLR host, processing dependencies, and starting your applications. You can use a lightweight json configuration file to define your application, build your tool, and publish it.
The management of packages completely changes the current application development. DNX makes it easy to create and apply packages. DNX provides tools to install, create, and manage NuGet packages. The DNX project simplifies the use of cross-compilation to generate different NuGet packages for different architectures. You can directly reference the NuGet package and have dependencies. You can also create security development tools.
DNX makes it easy to work with open-source projects. With DNX, you can easily replace an existing dependency with the source code. Let DNX compile at runtime, and then you can Debug the source code and modify it.
3. Engineering
A dnx project is a directory containing project. json files. The directory name of the folder is the name of the project. You can use the DNX project to create an NuGet package. The project. json file defines the metadata of your package, the dependent files of your tool, and the frameworks you need to use:
{
"Version": "1.0.0 -*",
"Description": "ClassLibrary1 Class Library ",
"Authors": ["daroth"],
"Tags": [""],
"ProjectUrl ":"",
"LicenseUrl ":"",
"Frameworks ":{
"Net451 ":{},
"Dotnet5.4 ":{
"Dependencies ":{
"Microsoft. CSharp": "4.0.1-beta-23516 ",
"System. Collections": "4.0.11-beta-23516 ",
"System. Linq": "4.0.1-beta-23516 ",
"System. Runtime": "4.0.21-beta-23516 ",
}
}
}
}
}
Under the "frameworks" attribute, you can declare which architecture you need to build your application. DNX can cross-compile each framework to create the corresponding lib directory.
You can use. NET Development Utility (DNU) to create, package, and publish a DNX project and generate binary files. You can generate an NuGet package and upload it to the package feed. Publishing is to package all the relevant components into an independent file to publish the current application.
4. Dependency
Dependency in DNX consists of the name and version number. The version number should follow the semantic version (main version number-minor version number-patch). For typical dependencies, refer to the installed NuGet package or another DNX project. The reference of the Project is referenced in the current directory or at the solution level using global. json:
{
"Projects": ["src", "test"],
"Sdk ":{
"Version": "1.0.0-rc1-final"
}
}
The global. json file also defines the minimum DNX version to create the current project.
Dependencies can be passed. You can declare your dependencies only at the top level. DNX can download the NuGet package installed for the entire dependency graph. The dependency generation function allows you to flexibly deploy your DNX application using binary work or source files when generating a project at runtime.
5. Package and summary
To reference a package, you must first install your package. You can use DNU to install and download a new package to the present or restore all dependencies. The following command downloads and installs all the packages stated in project. json:
Dnu restore
Package reset uses the package file of the configuration. You can configure the summary of the package using NuGet. config
6. Commands
A command is a named. net Running entry. You can define commands in the project. json file:
"Commands ":{
"Web": "Microsoft. AspNet. Server. Kestrel ",
"Ef": "EntityFramework. Commands"
},
You can use DNX to execute your command as follows:
Dnx web
Commands can be created and released as NuGet packages. You can use DNU to install global commands:
Dnu commands install MyCommand
7. Application host
The DNX application host is the first management portal called by DNX. It is responsible for processing dependencies, interpreting project. json, providing other services and calling application portals.
In addition, you can use DNX to call your application portal. Using DNX instead of using the DNX application host is not very common.
The DNX application host provides a system of application dependencies (such as IServiceProvider, IApplicationEnvironment, and ILoggerFactory). The application host service can be injected into the constructor in your main portal.
8. Compilation Module
The compilation module is an extensible point that allows you to participate in the DNX compilation process. You can implement Your Own compilation module by implementing the ICompileModule interface, and then put it into compiler/preprocess or compiler/postprocess.
9. DNX Version Management
You can install different DNX versions on your machine. You can use. NET Version Manager (DNVM) to manage different DNX versions. DNVM allows you to list different DNX versions on your machine and install different versions to convert the currently activated versions.