Visual Studio 2019 not adding referenced projects to deps.json

Viewed 818

I've got an existing WPF application built in Visual Studio 2019 (16.4.5), with much of its backend common code in a .NET Standard class library. I'm attempting to start a new frontend, built on Avalonia MVVM, which will be cross-platform. I've successfully created & run the "Hello World" Avalonia app. However, whenever I add any references to a class library (even if I create a new NET standard class library that's nothing more than the stub template created by VS), I get a runtime error:

System.IO.FileNotFoundException: 'Could not load file or assembly 'xxx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.'

Eventually, I realized that Visual Studio is not adding the appropriate entries to deps.json. Any project references I add to my application, those references do not appear in deps.json. If I build, I can then manually add them - i.e.

  },
  "ClassLibrary1/1.0.0": {
    "runtime": {
      "ClassLibrary1.dll": {}
    }

...And then it launches just fine. But if I rebuild, VS will of course regenerate deps.json, and those project references will again be missing.

Why would VS not be properly adding referenced projects to the deps.json it generates?

1 Answers

The solution was to clear nuget's cache (for some reason)...

  1. Tools -> NuGet Package Manager -> Package Manager Console, type dotnet nuget locals all --clear
  2. Clean solution
  3. Delete obj folders from all projects
  4. Rebuild

...And then VS began to generate proper, working deps.json.

Related