error NETSDK1004: Assets file '...\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. means the build was told to skip restore, and the project has never been restored or its obj folder has been wiped since. Run dotnet restore once, or drop --no-restore, and the build goes through.

Nothing is wrong with your project or its packages. The file the build wants is written by restore, and --no-restore skips exactly that step.

The error

C:\Program Files\dotnet\sdk\10.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1004: Assets file 'C:\...\n4a\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. [C:\...\n4a\n4a.csproj]

Build FAILED.

Only the project folder paths were shortened.

Why it happens

Restore reads the project's target framework and package references, resolves them, and writes the result to obj\project.assets.json, next to a few .nuget.g.props and .nuget.g.targets files. The target named in the error, Microsoft.PackageDependencyResolution.targets, reads that file during the build. Even a project with no packages needs it: this console app has no PackageReference at all and still failed. Before restore, dir obj answered File Not Found; after it, the folder held project.assets.json.

dotnet build normally restores first. --no-restore turns that off to save time, which is safe only when a restore has already run for this project into this obj folder. Two ways of breaking that promise both gave the error: creating the project with dotnet new console --no-restore, and building a restored project after its obj folder had been moved away, which is what a fresh clone or a git clean -xdf leaves you with. In a pipeline with a separate restore step, the same error means that step did not restore the project the build step is building.

The fix

dotnet restore
dotnet build --no-restore
  Determining projects to restore...
  Restored C:\...\n4a\n4a.csproj (in 64 ms).
  n4a -> C:\...\n4a\bin\Debug\net10.0\n4a.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

After one restore, builds with --no-restore work until the obj folder goes away again. The simpler alternative is to leave the flag off: a plain dotnet build on a second, never-restored copy printed Restored ... and Build succeeded. in one step. Keep --no-restore for build steps that run right after a restore of the same project in the same working folder, which is what it is for.

How it was reproduced

dotnet new console -o n4a --no-restore, then dotnet build --no-restore in the new folder, with .NET SDK 10.0.401 on Windows 11, target net10.0 and no packages. A second project, created normally and built once, failed the same way after its obj folder was moved out of the project folder, and built again with a plain dotnet build. All commands ran with output redirected to a file, as in a CI log, so the build printed its classic console output.

Frequently asked

What does NETSDK1004 mean?
The build could not find obj/project.assets.json, the file that NuGet restore writes. It means the build ran with --no-restore before any restore had run for that project, or after its obj folder was deleted.
How do I fix Assets file project.assets.json not found?
Run dotnet restore in the project or solution folder and build again, or run dotnet build without --no-restore so it restores first. Either one creates the assets file.
Do I need dotnet restore if my project has no NuGet packages?
Yes. A console project with no PackageReference still failed with NETSDK1004 when restore was skipped, because the build reads the assets file whether or not any packages are listed in it.

More decoded errors in the Fixes category.