问题
I can get my .net standard 2.0 package working in a .net framework 4.7.2 dll if I do the following steps
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
I choose PackageReference in project file
I answer yes to accept licensing
Then I can see the following
And I can get my project working.
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.
Instead the references look like
and I can not get my project working.
[Update]
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
The program worked!
回答1:
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.
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.
(But you can easily migrate packages.config to PackageReference, see this).
来源:https://stackoverflow.com/questions/60199981/reference-hell-accessing-netstandard-with-framework-vs2019-preview