简体   繁体   中英

Is it necessary to update all nuget packages when upgrading a project?

I was given the task to update some of our projects target frameworks from .Net 4.5 to .Net 4.8. While updating the projects some references broke. Visual Studio also showed warnings about certain packages not targeting the correct framework.

I ended up running Update-Package <packagename> -reinstall -ProjectName <projectname> . So those packages had their target framework updated to say net48. The warnings went away and I was also able to fix some of the references that broke.

My questions are:

What about all the other packages in the packages.config that have a targetFramework="net45" ? Is it necessary to update them so they all target 4.8?

How does one determine when to update them?

I have read here: https://docs.microsoft.com/en-us/nuget/consume-packages/reinstalling-and-updating-packages under the When to Reinstall a Package section that you may want to reinstall during a project upgrade. However, only "if the package requires reinstallation due to the change in target framework" or Nuget shows build errors.

Which makes me think that if there are no build errors or a package requiring a reinstallation then it is fine to leave those other packages targeting net45.

Any comments or insight on how you determine if an update is necessary would be greatly appreciated. Thank you!

First of all you need to check if you can update this. What I mean by that is that not every package might support Net 4.8. Also have in mind that there might be some changes to the way the package works, so your code my not work. Do the research first on each package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM