dotnet "NETSDK1004: Assets file project.assets.json not found" in CI
By Daniel Zoghalchali·Latchkey
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.
Diagnose it: SDK version and restore first
Most .NET CI failures are an SDK mismatch or a restore that did not happen. global.json pins the SDK, and if the runner does not have that exact version the failure message is about the project rather than the SDK.
Terminal
dotnet --info
cat global.json 2>/dev/null
# restore explicitly so a restore failure is not reported as a build failure
dotnet restore --verbosity normal
dotnet build --no-restore -warnaserror
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.
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 dotnet "NETSDK1004: assets file project.assets.json not found" in CI?
There are 2 common causes: built with --no-restore before restoring and obj directory cleaned or not cached. 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 dotnet "NETSDK1004: assets file project.assets.json not found" in CI?
There are 2 fixes depending on which cause you have: restore before building and or drop --no-restore. Work through them in order, since the first is the most common.
What does dotnet "NETSDK1004: assets file project.assets.json not found" in CI actually mean?
Build fails with NETSDK1004 saying the assets file was not found and to "Run a NuGet package restore".
How do I stop dotnet "NETSDK1004: assets file project.assets.json not found" in CI happening again?
Always run dotnet restore before a --no-restore build/test. The prevention section lists 3 changes that keep it from recurring.