NuGet / Home

Repo for NuGet Client issues
Other
1.49k stars 250 forks source link

After using Package Refs, retargeting project produces a NuGet Error #6907

Open rido-min opened 6 years ago

rido-min commented 6 years ago

using d15.7

Repro Steps

  1. Create Console App Targeting .NET 4.6.1
  2. Add NewtonSoft using PR
  3. Remove NewtonSoft
  4. Retarget to .NET 4.6.2
  5. Build

Expected. Build succeeds.

Observed. Build fails with

Microsoft.NuGet.targets(186,5): error : Your project is not referencing the ".NETFramework,Version=v4.6.2" framework. 
Add a reference to ".NETFramework,Version=v4.6.2" 
in the "frameworks" section of your project.json, and then re-run NuGet restore.

weird error message since the project is not using any packages, and project.json was never used.

anangaur commented 6 years ago

Looks like we are not cleaning up properly upon uninstall of the last and only packageref. The error does not seem to get fixed with the proposed workaround. Is it due to the choice of package format being persisted somewhere in the obj dir? Where is the choice about the package format persisted?

nkolev92 commented 3 years ago

Step 3 creates an assets file, which is the tell for this is PR, but then when the retargeting happens, there are no PackageReference and not RestoreProjectStyle so it just breaks.

I'd say we should add a RestoreProjectStyle property to legacy projects when installing the first PackageReference.

Low priority given the lack of additional input.