Skip to content
Latchkey

dotnet "NETSDK1004: Assets file project.assets.json not found" in CI

The build looked for project.assets.json (restore’s output that lists resolved packages) and it was not there. A build ran before restore, or with --no-restore when nothing had restored yet.

What this error means

Build fails with NETSDK1004 saying the assets file was not found and to "Run a NuGet package restore". It is deterministic - the project simply has no restore output to compile against.

dotnet build output
error NETSDK1004: Assets file '/src/MyApp/obj/project.assets.json' not found.
Run a NuGet package restore to generate this file.

Common causes

Built with --no-restore before restoring

A dotnet build --no-restore (or dotnet test --no-restore) ran before any dotnet restore, so obj/project.assets.json was never generated.

obj directory cleaned or not cached

A clean step removed obj/, or a cache that was expected to carry the assets file did not restore it, leaving the build with no assets.

How to fix it

Restore before building

Run restore for the same target first, then build with --no-restore.

Terminal
dotnet restore MyApp.sln
dotnet build MyApp.sln -c Release --no-restore

Or drop --no-restore

Let build restore implicitly so the assets file always exists.

Terminal
dotnet build MyApp.sln -c Release

How to prevent it

  • Always run dotnet restore before a --no-restore build/test.
  • Restore and build the same solution so assets land where the build looks.
  • Do not cache obj/ without also guaranteeing a prior restore step.

Frequently asked questions

What causes ""NETSDK1004: ... project.assets.json not found""?
A dotnet build --no-restore (or dotnet test --no-restore) ran before any dotnet restore, so obj/project.assets.json was never generated.
How do I fix "NETSDK1004: ... project.assets.json not found"?
Run restore for the same target first, then build with --no-restore.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card