5 solutions to Assets file project.assets.json not found. Run NuGet restore

Total
0
Shares

Assets file project.assets.json not found. Run a NuGet package restore” error occurs because the dotnet cli does not create all of the required files initially. Doing dotnet restore adds the required files.

Solution 1: Dotnet Restore

To fix this error, Open package manager console from –

Tools > NuGet Package Manager > Package Manager Console

and run:

dotnet restore

Solution 2: Spaces in GIT repository

If there are spaces in the name of GIT repository then you may face this error. To solve this, you need to clone your repository in a different name –

git clone "http://github.com/repository/my project name" myprojectname

Solution 3: Third party package source

In case when ‘dotnet restore’ not works, following steps may help:

  1. Visual Studio >> Tools >> Options >> Nuget Manager >> Package Sources
  2. Unchecked any third party package sources.
  3. Rebuild solution.

Solution 4: Azure DevOps / VSTS environment

If you encounter this error –

C:\Program Files\dotnet\sdk\2.2.104\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(208,5): Error NETSDK1004: Assets file '...\obj\project.assets.json' not found. Run a NuGet package restore to generate this file

Add /t:Restore to your MSBuild Arguments in Build Solution.

Solution 5: Clear Nuget Cache

Clear all nuget cache –

Tool -> NuGet Package Maneger -> Package Manager settings -> click on "Clear all NuGet Cache(s)"

then restore –

dotnet restore

Conclusion

In this article we saw 5 different solutions to the error Assets file project.assets.json not found. Run a NuGet package restore.

Source: StackOverflow.com

Leave a Reply

Your email address will not be published. Required fields are marked *