ASP. NET Core Project.json file (5) _ Practical Tips

Source: Internet
Author: User
This article is mainly for everyone to introduce the ASP. NET Core Project.json file, with a certain reference value, interested in small partners can refer to

If your application is going to do any useful work, then you need libraries and frameworks to do the work, such as storing and retrieving data from a database or rendering complex HTML.

In this chapter, we will discuss the Project.json file. This file uses JavaScript object symbols to store configuration information, which is at the heart of a. NET application. Without this file, your project will not have an ASP. Here, we will discuss some of the most important features of this file. Let's double-click the Project.json file to open it.

Currently, the default implementation of the Project.json file code in the new project is as follows:

{"Dependencies": {"  Microsoft.NETCore.App": {"   version": "1.0.0",   "type": "Platform"  },  " Microsoft.AspNetCore.Diagnostics ":" 1.0.0 ",  " Microsoft.AspNetCore.Server.IISIntegration ":" 1.0.0 ",  " Microsoft.AspNetCore.Server.Kestrel ":" 1.0.0 ",  " Microsoft.Extensions.Logging.Console ":" 1.0.0 "}," Tools ": {  "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"}, "Frameworks": {  "netcoreapp1.0": {   "Imports": ["dotnet5.6", "Portable-net45+win8"]  }}, "Buildoptions": {  "Emitentrypoint": true,  "Preservecompilationcontext": true}, "Runtimeoptions": {  "configproperties": {   "System.GC.Server": True  }}, "Publishoptions": {  "include": ["Wwwroot", "web. config"]}, "scripts": {  "postpublish": ["Dotn ET publish-iis--publish-folder%publish:outputpath%   --framework%publish:fulltargetframework% "]}}

As we see, at the top we have the version information for this file. This is what you use when you compile your application and select the version.

The version is 1.0.0, but the most important part of this file is the dependency relationship.

If your application is doing any useful work, you need libraries and frameworks to do the work, such as storing and retrieving data from a database or rendering complex HTML.

This version of ASP. NET Core, dependencies are managed through the NuGet Package Manager.

NuGet has been in. NET for years, and now the primary way to manage all of your dependencies is to manage them by using the NuGet Package Manager.

Your application relies on all the top-level NuGet packages that need to be stored in this Project.json file.

"Microsoft.AspNetCore.Diagnostics": "1.0.0", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", " Microsoft.AspNetCore.Server.Kestrel ":" 1.0.0 "," Microsoft.Extensions.Logging.Console ":" 1.0.0

From this file you can see that our application has dependencies on other packages, and the exact dependencies may change the final release version of ASP. When you want to add a new dependency, such as the ASP. NET MVC framework, you can easily write to this Project.json file. When editing this JSON file, you will also get some smart hints, as follows:

You can use the user interface by right-clicking the reference in Solution Explorer, and then selecting Manage NuGet packages. You can now see the packages that are currently installed.

These packages are the same as the packages in the Project.json file, and you can also use the browser to add reference packages, such as the following:

If you now install this package by using the Install button, the package will also be stored in the Project.json file. The framework section is another important part of Project.json, and this tutorial will show you what the. NET framework can be used by ASP.

"Frameworks": {"  netcoreapp1.0": {"   imports": [    "dotnet5.6",    "Portable-net45+win8"   ]}  },

In this case, you will see that "netcoreapp1.0" is the framework used in the project and you can also add. NET Framework is referenced by the. NET Framework is the one you installed when you installed Visual Studio.

Related Article

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.