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.
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.
dotnet restore MyApp.sln
dotnet build MyApp.sln -c Release --no-restoreOr drop --no-restore
Let build restore implicitly so the assets file always exists.
dotnet build MyApp.sln -c ReleaseHow to prevent it
- Always run
dotnet restorebefore a--no-restorebuild/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.