21

For some reason in my console app, couple of the reference that I installed thru nuget shows the blue nuget icon. I can build my project locally, but not after I deploy my project to cloud. The error msg is complaining about not able to find these 2 references. Seems like I can't delete them either by right click(no delete option avaialble). Any idea?

enter image description here

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
checai
  • 836
  • 4
  • 11
  • 17

2 Answers2

22

nuget package reference blue icon in visual studio 2017

That because you are using the packagereference on the project types that are not .NET Core.

You can edit the .csproj file and check if it contains following ItemGroup:

  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
  </ItemGroup>

To resolve this issue, you can delete this PackageReference from your project file, then add those package with nuget package.

Besides, you should check if you have set the Default package management format to PackageReference. If yes, change it to packages.config, then add those two packages with nuget:

enter image description here

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • I removed the package reference and installed with nuget, it still shows the icon in blue. The format is selected as package.config as well. – Shashwat Sep 04 '20 at 04:52
  • I have the same problem. Did you manage to resolve it? – Nikhil Nov 04 '20 at 10:10
  • 10
    I fixed the yellow triangle/blue reference by deleting the obj-folder in the project. This was a project that was at one point converted _to_ PackageReference, and then later I changed the branch to one where the project wasn't converted (that is, using packages.config). The obj folder contained a project.assets.json that confused Visual Studio. Make sure to turn on "Show all files and folders" in the solution explorer. – Larsbj Nov 17 '20 at 18:00
  • thanks @Larsbj thats exactly what I did, I experimented with using PackageReferences, then reverted the csproj. Did not realize that the that json file was messing with VS – Kobold_Warlord Aug 20 '21 at 15:35
  • I found in my case that it was easiest to just delete and replace the .csproj file, re-adding files and references manually. This got rid of some old bad references that I hadn't been able to track down just by editing my existing .csproj. The PackageReference/Packages.config error had been the root of it all, but in my case I needed a bigger hammer to get rid of it. (I did delete the obj folder as well.) – Eric Hirst May 02 '22 at 23:28
0

Happened to me in VS 2022.

Solved by deleting the bin and obj folders, which removed the reference with the blue icon. And after that reinstalled the NuGet packages, which added the references to the csproj file.

update-package -reinstall -project MyProjectName

SzilardD
  • 1,611
  • 2
  • 22
  • 40