Can I update to .Net 5 NuGet packages even if I'm using .Net Core 3.1?

僤鯓⒐⒋嵵緔 提交于 2020-11-29 07:52:11

问题


I was looking for some NuGet updates about my project libraries. I see that there are a lot of Microsoft libraries update to v5.0.0.

Based on my knowledge I think these are new dependencies released with .Net 5.0 and I'm not sure that I can update these libraries to latest version using .Net Core 3.1 project.

Can I update to v5.0.0 libraries even if I'm using/building a .Net Core 3.1 project?


回答1:


Unfortunately, you cannot update many of these newest Nuget packages to 5.0. The reason being is that the newest Nuget package versions are written primarily for .NET 5, and often times Nuget Package Manager will even prevent you from installing them since there are differences in the APIs. With that said, there may be a few spots where it will allow the installation, but I wouldn't recommend it if you plan to keep the application on .NET Core 3.1. Most likely it could cause some inconsistencies that would be hard to debug. Proceed with caution, or upgrade your projects to .NET 5.




回答2:


I just finished the same. I had 3.1 core application with a lot of 3.1 and NET Standard2.0 libraries projects and just updated all these libraries to the version 5. All libraries were working ok, I could compile them. But I couldn't compile my main Web application. It started to give some strange errors that some staff needs .net5. Maybe it could be fixed but I didn't see much sense to waste my time since in any case I was planning to move to net5 in a couple of days. So I just decided to move to net5 immediately. I had installed net 5.0 SDK and change target framework of my application to net5.0. Now everything is working fine and I am happy with my net5.0 application. I have some Net 4.8 projects that use the same common libraries that I am using for Net Core. So these common libraries are targeted to netstandard2.0. and can't change them to Net5. Now all these Standard2.0 projects still work with my net5.0 web application without any problem. Since I didn't have any problems with my previous version 3.1.9 I DON'T RECOMEND to update libraries to 5.0 if YOU DON'T PLAN to move your application to Net5.0. You can get more problems after this then you can gain from this update.




回答3:


You should report such (VS for Mac and VS for Windows) as product defects to Microsoft, as many of the new 5.0 packages are targeting net5 solely, and not applicable to netcoreapp3.1.

Try to use outdated tool to check package updates, which is much more reliable,

https://github.com/dotnet-outdated/dotnet-outdated



来源:https://stackoverflow.com/questions/64792261/can-i-update-to-net-5-nuget-packages-even-if-im-using-net-core-3-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!