将所有依赖项从.Net标准库复制到.Net Framework Console应用程序 [英] Copy all dependencies from .Net Standard libraries to .Net Framework Console application

查看:80
本文介绍了将所有依赖项从.Net标准库复制到.Net Framework Console应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.net framework(4.6)控制台应用程序中使用.net标准项目后,.net标准项目的依赖项不会复制到输出目录中。这会导致缺少dll的运行时错误。对于引用的项目,复制本地属性已经为true。一种可能的解决方案是在控制台应用程序中再次添加所有依赖项,但这不是一个好主意。

After consuming .net standard projects in a .net framework(4.6) console application, the dependencies of the .net standard projects are not copied into the output directory. This results in run time error of missing dlls. The "copy local" property is already true for the referenced projects. One possible solution is to add all the dependencies again in the console application, but is not a good idea. Is there a better solution to this?

推荐答案

经过文章,下面的解决方案就像一个魅力。

After going through an article by Scott Hanselman, below solution worked like a charm.

在下面的行中添加.net框架控制台应用程序的 .csproj文件的第一个 PropertyGroup标签

Add below line in the first "PropertyGroup" tag of the .net framework console application's ".csproj" file

<RestoreProjectStyle>PackageReference</RestoreProjectStyle>

无需在控制台应用程序中再次添加.net标准项目的nuget依赖项

There will not be any need to add again the .net standard projects' nuget dependencies in the console application.

这篇关于将所有依赖项从.Net标准库复制到.Net Framework Console应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆