参考地狱用框架VS2019预览访问.netstandard [英] Reference hell accessing .netstandard with framework VS2019 preview

查看:21
本文介绍了参考地狱用框架VS2019预览访问.netstandard的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我执行以下步骤,我可以让我的 .net 标准 2.0 包在 .net 框架 4.7.2 dll 中工作

I can get my .net standard 2.0 package working in a .net framework 4.7.2 dll if I do the following steps

在我的标准项目 VS2019 61.4.4 中右键单击项目并选择 pack 以创建 .nupkg然后我为包设置了一个nuget包源在我的框架项目中,我安装了 nuget 包我得到以下对话框

In my standard project VS2019 61.4.4 right click the project and select pack to create the .nupkg Then I set up a nuget package source for the package In my framework project I install nuget package I get the following dialog

我在项目文件中选择PackageReference

I choose PackageReference in project file

我回答是接受许可

然后我可以看到以下内容

Then I can see the following

我可以让我的项目工作.

And I can get my project working.

但是在运行 VS2019 16.5.0 Preview 2.0 的另一台机器上,我没有收到要求我选择包管理器格式的对话框.

However on a different machine running VS2019 16.5.0 Preview 2.0, I do not get the dialog asking me to choose the package manager format.

相反,引用看起来像

而且我的项目无法运行.

and I can not get my project working.

[更新]

按照 Lance 的链接将 packages.config 迁移到 PackageReference 后项目看起来像

After following Lance's link to migrate packages.config to PackageReference The project looks like

我可以通过右键单击引用并选择删除未使用的引用

I was able to remove the unwanted packages by right clicking references and choosing Remove Unused References

程序成功了!

推荐答案

Go Tools=>Nuget Package Manager =>General =>包管理 您可以通过允许在第一次安装包时选择格式来控制行为.启用复选框并重新启动VS,此更改将生效.

Go Tools=>Nuget Package Manager =>General => Package Management You can control the behavior by Allow format selection on first package install. Enable the checkbox and restart VS, this change will take effect.

并注意该对话框仅在我们在当前项目中安装第一个包时出现.因此,如果您创建一个新项目并安装包,它就会出现.并且由于您曾经在该项目中安装了软件包,该对话框将不再出现在 WindowsFormApp2 中.

And note the dialog only appears when we install first package in current project. So if you create a new project and install package, it will appear. And since you once installed packages in that project, the dialog won't appear in WindowsFormApp2 any more.

(但您可以轻松地将 packages.config 迁移到 PackageReference,请参阅 this).

(But you can easily migrate packages.config to PackageReference, see this).

这篇关于参考地狱用框架VS2019预览访问.netstandard的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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