4

It's been a while since I've gotten into nuget hell but I'm back to this again...

I'm not exactly sure what caused this issue other than I did a visual studio 2019 update before I left on Friday. Now today, I've been fighting an issue where my library won't compile due to "Must Use PackageReference".

I've found a few articles out there on this but nothing that seems to specifically address this problem.

This issue could also be due to accidentally adding some .netcore librairies (entity framework .core) to the .netframework library. I had a hard time removing those libraries using nuget.

I also tried to reload the nuget library by:

nuget-package -reinstall Microsoft.Windows.SDK.Contracts

That reloads the package ok, but when I recompile the library the error "Must use PackageReference" comes back again.

In the output window I have this when compiling:

...\path...\packages\Microsoft.Windows.SDK.Contracts.10.0.19041.1\build\Microsoft.Windows.SDK.Contracts.targets(4,5): error : Must use PackageReference

I'm not even seeing this referenced in any of my source files so I'm not sure I even need it. However, I can't uninstall it as it seems to have octopus tentacles in numerous other libraries.

What am I running into here and how do I get this resolved?

Zonus
  • 2,313
  • 2
  • 26
  • 48
  • I just migrated that library to PackageReference and the error went away. Odd that I was receiving that error message when I was using the package.config file, not PackageReference. Not feeling good about "the fix" as it doesn't really explain what I was encountering. – Zonus Dec 14 '20 at 21:13
  • Did you find any solution for above peoblem. I am facing same issue – Arpit Sharma Jan 10 '21 at 05:18
  • See the answer below – Zonus Jan 11 '21 at 13:52
  • Does this answer your question? [How to solve the error "Must use PackageReference"?](https://stackoverflow.com/questions/58540212/how-to-solve-the-error-must-use-packagereference) – markshancock Mar 02 '22 at 16:56

1 Answers1

1

My fix was to convert the projects to PackageReference as seen here: https://learn.microsoft.com/en-us/nuget/consume-packages/migrate-packages-config-to-package-reference The problem went away after doing this and I haven't seen it since. Still a little uneasy on why this happened... But I don't have time to dwell on it.

Zonus
  • 2,313
  • 2
  • 26
  • 48