.NET Core (2.0) 中的参考

用户_1856538_

我尝试添加对我的 .NET Core 项目的新引用。奇怪的是,我还可以访问我的引用中涉及的项目。对于此示例,我应该能够从服务中看到 Repository 项目,但不应该能够访问实体项目。但是,我仍然可以从服务中访问实体对象。

怎么会 ?

在此处输入图片说明

马丁·乌尔里希

References in SDK-based projects are fully transitive so - similar to many other package managers like npm or maven - you all the transitive references are available in the project to make sure the app compiles and runs cleanly, e.g. there are no unresolved references when the dependency is referenced and all assemblies are part of the build output and ready to run. (there may even be conflict resolution applied to conflicting version of assemblies resulting in the generation of binding redirects.)

In previous versions, you would need to install NuGet packages or add additional project references to other projects as well to not get build errors or type load exceptions.

如果您希望您的项目能够正确运行和解决冲突但不将传递引用传递给编译器,那么目前没有完美的解决方法。

如果您只需要依赖项来构建项目,而不需要运行它,您可以将包或项目引用标记为PrivateAssets="All"(将作为属性添加到 .csproj 文件中的引用)。

如果您想强制使用 API - 例如对于分层 API,请考虑编写一个 roslyn 分析器,如果您从不想要的地方引用 API,它将发出警告。这可能适用于需要工具来维护所需架构的大型项目。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

ASP.Net Core RC2迁移CSPROJ参考错误

来自分类Dev

ASP.NET Core RC2项目参考“无法解决依赖项X”

来自分类Dev

.NET Core Azure 函数缺少参考

来自分类Dev

.Net Core WCF 客户端抛出 WinHttpException 错误 0x2f9a

来自分类Dev

服务结构中的.NET Core RC2

来自分类Dev

.NET Core RC2中的登录声明

来自分类Dev

ASP.NET Core rc2中的Cookie

来自分类Dev

无法在.Net Core RC2中添加视图

来自分类Dev

ASP.NET Core RC2中的网址重写

来自分类Dev

.NET Core RC2中的小写网址

来自分类Dev

在.NET Core中查找2个坐标之间的距离

来自分类Dev

ASP.NET Core RC2中的网址重写

来自分类Dev

服务结构中的.NET Core RC2

来自分类Dev

在 .Net Core 中寻找 RC2 加密

来自分类Dev

ASP.NET Core 2 razor 页面中的文件上传

来自分类Dev

.NET Core (v2) Azure 函数中的默认 HttpTriggerAttribute

来自分类Dev

Angular 2中的`this`参考

来自分类Dev

.NET Core中的SOAP?

来自分类Dev

.NET Core中的Ninject

来自分类Dev

.Net Core 2 FromSql 问题

来自分类Dev

xUnit.net v2在Visual Studio 2015中找不到.NET Core测试

来自分类Dev

EF Core 2,.NET CORE 2:如何使用IQueryable <T>在同一列中查询多个条件?

来自分类Dev

.NET Core 2.2:如何使用 WSDL 进行 WCF 参考

来自分类Dev

Visual Studio 2015中“参考”下的Asp.net 5和Asp.net core 5选项是什么意思?

来自分类Dev

在.Net Core中设置UserTokenProvider

来自分类Dev

.Net Core 3.0中的BrowserLink

来自分类Dev

.NET Core中的Computehash方法

来自分类Dev

.NET Core中的HttpClientHandler UseDefaultCredentials

来自分类Dev

.NET Core中的主键继承