0

I am trying to update a legacy ASP.NET 4.6 app to .NET 4.8. The app contains 2 class library projects as well.

I'm now using VS2022 for the updating instead of VS2017/2019 that I was using before.

For the library projects, I updated the project's target framework to 4.8 and then updated packages by running the following command successfully (no errors shown):

update-package -ProjectName abc -Reinstall -IgnoreDependencies

After running the command, VS2022 - clean and rebuild - packages.config targetframework changes to 4.8:

<package id="System.Memory" version="4.5.5" targetFramework="net48" />
  1. In package manager console window - why does it reinstall same version again?
  2. Inside project references for class library project some of the dll versions are still pointing to 4.5 folder, shouldn't it have a 4.8 folder name that it should be pointing to? e.g. C:\Users\Projects\abc\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll

2 Answers 2

1

You misunderstood how NuGet works, but understandable as it's not well documented.

<package id="System.Memory" version="4.5.5" targetFramework="net48" />

Indeed the migration ensures that your project consumes this package and tells NuGet engine to restore based on .NET Framework 4.8.

However, the author(s) of that package System.Memory version 4.5.5 only targeted a few (netcoreapp2.1, netstandard1.1, netstandard2.0 and net461). So the best resolution result is the net461 bit, and C:\Users\Projects\abc\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll is desired. You won't see net48 here unless the package has a .NET Framework 4.8 specific build (which is rare and not needed).

Sign up to request clarification or add additional context in comments.

2 Comments

How can I ensure apart from what this command does, that other dlls in question do not have a updated 4.8 version like System.ComponentModel.Annotations, System.Numerics.Vectors? Thanks for the answer Lex.
Either you trust NuGet engine, or you write your own script or program to verify. Anyway the metadata is available from NuGet.org, as well as the NuGet cache on disk.
-2

For first question- Nuget package has different builds for different framework such 4.8,6,7 etc.. so when we reinstall library even though version is same, reinstall tell Nuget to pick new target framework e.g lib/.netstandardlibray/mylibrary.dll

for second part - some library still point to older folder location instead of newer is may be due compatibility fall back. That is only version which is most compatible to newer framework.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.