How to solve the error "Must use PackageReference"?

VS2017/VS2019 -> Solution Explorer -> right-click References -> "Migrate packages.config to PackageReference"

VS2019 -> Solution Explorer -> right-click packages.config -> "Migrate packages.config to PackageReference"


Solution that worked for me was to:

  1. Run a Clean on the project in question
  2. Close Visual Studio
  3. Navigate to the project folder on disk and delete the obj folder
  4. Reopen Visual Studio and Build