C
C#2y ago
Simon

❔ update packages for current .net

Is anyone aware of a quick way to update all packages that are tied to the current .net version? For example, my solution/projects are all using .net 6, however VS suggests I update a bunch of packages to the v7.0.0 version (ex: Microsoft.Extensions.Logging.Abstractions) or does this not matter and I should update to v7.0.0 even though I'm on .net 6?
6 Replies
JakenVeina
JakenVeina2y ago
there is no real need for you to update all those packages unless there's some specific security vulnerability, or if you just want to update your target framework to 7.0 but, yes, there is a very easy way to upgrade them all the Nuget Package Manager allows this
Simon
SimonOP2y ago
I'm happy sticking with 6.x.x, but VS suggests updating to the latest which is 7.x.x, so I'm wondering if there was any way to somewhat quickly/easily say: update these to latest 6.x.x
JakenVeina
JakenVeina2y ago
nah, if you want to do a partial upgrade, you'll have to go through those one-at-a-time
Simon
SimonOP2y ago
Ok thanks, that's what I have been doing and it's a pain... granted not a frequent task.
JakenVeina
JakenVeina2y ago
I mean, I think maybe technically, you could edit your csproj files directly to set wildcards in the version I THINK there's a syntax for that, but I could be wrong so, you could set it to 6.*.* or whatever, and it would always pull the latest me, I wouldn't recommend that, I despise systems where builds are not deterministic what you CAN do is just change the version numbers directly in the files maybe if you can pull all the latest version numbers thst you're looking for, manually, that might be faster than clicking through the Package Manager over and over but if your problem is going through and updating all of these across many projects, there's an even better solution you can setup a Directory.Build.targets file that sets the version numbers for all your packages, across the entire solution, in just one spot so, within each project, you have
<PackageReference Include"MyPackage" />
<PackageReference Include"MyPackage" />
without specifying the version, and you repeat this only in each project that needs "MyPackage" then in the targets file, you put
<PackageReference Update="MyPackage" Version="1.2.3" />
<PackageReference Update="MyPackage" Version="1.2.3" />
and it'll set the version to use on all the projects that included that package, without adding it to the ones that didn't
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server