project.json 中的“dependencies"和“frameworkAssemblies"有什么区别?

编程入门 行业动态 更新时间:2024-10-17 15:30:24
本文介绍了project.json 中的“dependencies"和“frameworkAssemblies"有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

为 ASP.NET 5 应用程序使用 project.json 的文档 包含一个示例项目.json 文件(下面的缩写版本).

The documentation for using project.json for ASP.NET 5 applications includes a sample project.json file (abbreviated version below).

frameworkAssemblies 和 dependencies 有什么区别?

为什么 dnx451 使用一个而 dnxcore50 使用另一个?

And why does dnx451 use one and dnxcore50 use the other?

{ "version": "0.1-alpha-*", ... "frameworks": { "dnx451": { "frameworkAssemblies": { ... } }, "dnxcore50": { "dependencies": { ... } } }

推荐答案

frameworkAssemblies 指的是 GAC(全局程序集缓存)中存在的程序集.

frameworkAssemblies refers to assemblies present in GAC (global assembly cache).

考虑以下示例:我想使用 ADO.NET apis(SqlConnection, SqlCommand) 来处理 SQL Server 数据库.我知道这些 api 是 System.Data.dll 的一部分,所以想引用它.现在,安装完整版 .NET Framework 后,它会在 GAC 中安装一些程序集(也有此 System.Data.dll),因此您会看到对 frameworkassemblies 的引用代码> 在下面的例子中.来到 CoreClr,我需要找出这些类型存在于哪个包中.为此,您可以使用名为 PackageSearch(由 ASP.NET 团队成员构建)的网站,您可以在其中搜索类型并找到包名称.基于此,您会发现 System.Data.SqlClient 是包.由于此包是为 CoreClr 构建的,因此它是 dnxcore50 部分中的 dependencies 部分的一部分.

Consider the following example: I want to use ADO.NET apis(SqlConnection, SqlCommand) to work with a SQL Server database. I know that these apis are part of System.Data.dll and so want to reference it. Now when the full version of .NET Framework is installed, it installs some assemblies in the GAC (which has this System.Data.dll too) and hence you see a reference to frameworkassemblies in the below example. Coming to CoreClr, I need to find out in which package these types exist. For this you could use the website called PackageSearch(built by an ASP.NET team member) where you can search for a type and find the package name. Based on this you will find System.Data.SqlClient to be the package. Since this package is built for CoreClr, it is part of dependencies section within the dnxcore50 section.

{ "version": "1.0.0-*", "description": "Test App", "dependencies": { }, "frameworks": { "dnx451": { "frameworkAssemblies": { "System.Data": "4.0.0.0" } }, "dnxcore50": { "dependencies": { "System.Data.SqlClient": "4.0.0-beta-*" } } } }

现在假设您甚至想要在您的应用程序中添加对 json 序列化和反序列化的支持,并且想要引用 Json.Net nuget 包.Json.Net nuget 包同时支持桌面和核心 clr,因此您可以将其放在两个框架共有的 dependencies 部分.

Now let's say you want to even add support for json serialization and deserialization in your app and want to reference Json.Net nuget package. Json.Net nuget package supports both the desktop and core clr and hence you would put it in the dependencies section common to both frameworks.

{ "version": "1.0.0-*", "description": "Test App", "dependencies": { "Newtonsoft.Json": "6.0.6" }, "frameworks": { "dnx451": { "frameworkAssemblies": { "System.Data": "4.0.0.0" } }, "dnxcore50": { "dependencies": { "System.Data.SqlClient": "4.0.0-beta-*" } } } }

更多推荐

project.json 中的“dependencies"和“frameworkAssemblies"有什么区别?

本文发布于:2023-11-15 23:32:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1598943.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有什么区别   json   project   dependencies   frameworkAssemblies

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!