0

I created a .core console application and without adding any nuget packages or even one line of code, I did a build on it and got two errors (Visual Studio 19 16.8)

Error NETSDK1060 Error reading assets file: Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified. ABC C:\Program Files\dotnet\sdk\5.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets

the lines in question in the Microsoft.PackageDependencyResolution.targets:

  ProjectAssetsFile="$(ProjectAssetsFile)"

After fighting this for hours, I went ahead and uninstalled Visual Studio 2019 and even used InstallCleanup.exe in hopes of scrubbing any settings I may have messed up.

After reinstalling Visual Studio clean, I created a .Core console application and built it -- same error.

What is going on? With this line I am assumming that its in my projects project.assets.json file ... but I have nothing about Newtonsoft.Json, Version=9.0.0.0 '''$(MSBuildProjectExtensionsPath)/project.assets.json'''

It is obviously loading some deeply rooted and hidden project.assets.json file but how do I find where this is? I have been on this issue for over 9 hours.

Any help would be appreciated.

Thank you.

EDITS: This is only happening with a . Core console application. a standard .Net framework console application has no problems.

Also, if I add a random nuget package, the top level package under dependecies has a yellow asterick, although the .dll under that is pointing at a valid DLL

RDB1970
  • 31
  • 2
  • try right-click on your solution in `Solution Explorer` -> `Restore NuGet Packages` – vasily.sib Feb 09 '21 at 04:14
  • It's a fresh project with no Nuget packages. Thats why I am confused as to why its talking about Newtonsoft.Json That said, I did that and got "All packages are already installed and there is nothing to restore." – RDB1970 Feb 09 '21 at 04:26
  • then next step is to check if you have [.NET Core SDK](https://dotnet.microsoft.com/download) installed – vasily.sib Feb 09 '21 at 05:08
  • Yes, 5.0.102 is installed. I am not sure how that would relate to an empty project trying to load newtonsoft.json when there are zero nuget packages in the project configured however. Is there a global version of projects.assets.json since newtonsoft.json is not in my project obj/projects.assets.json ? – RDB1970 Feb 09 '21 at 05:24
  • @RDB1970, I have two questions about your question. First, please right click your project-> Properties->check if your Targert-Framework has .NET core 3.1 or .NET 5.0. Second, Please refer to [the answer](https://stackoverflow.com/a/53370764/11507778) to set your visual studio. – Jack J Jun Feb 10 '21 at 02:44

0 Answers0