I used the tool in VS2022 to convert a .NetFramework project to use PackageReference instead of packages.config.
The upgrade worked fine but I can't get VS2022 to automatically restore the packages.
Every time I do a clean build, i.e. delete the asset file in the obj/ folder, I need to manually run nuget restore
or the project will not compile.
Once the asset file "project.asset.json" is present the project compiles and works fine.
Is there a way to troubleshoot this?
What msbuild task is supposed to create the asset file? In the detailed log I only see references to it in:
Target "ResolveNuGetPackageAssets" skipped, due to false condition; ('$(ResolveNuGetPackages)' == 'true' and exists('$(ProjectLockFile)')) was evaluated as ('true' == 'true' and exists('obj\project.assets.json')).
Found the problem in some confusing documentation.
There are two settings in NuGet.Config
The documentation says
I interpreted that as enabled=true would automatically do a nuget restore but that is not how it works. Both settings must be true for .NetFramework projects. SDK projects work fine with automatic=false. Maybe
dotnet restore
ignores this nuget setting.(I have no idea what "enable" actually does or what "missing packages" mean in this context)
My guess is I probably set automatic to false myself at one point when I was offline and assumed it would not try online sources