Error Knowledge Base .NET NETSDK1004

NETSDK1004: Assets file not found

The build cannot find project.assets.json from the restore step, so package resolution data is missing for the current project.

Fix it fast

Most likely: Restore did not run, failed earlier, or its obj/project.assets.json output was cleaned before build.

1. Confirm this is your error
error NETSDK1004: Assets file 'obj/project.assets.json' not found. Run a NuGet package restore to generate this file.
2. Check the cause
ls obj/project.assets.json
dotnet restore -v minimal
dotnet build --no-restore
3. Apply the safe fix
# Restore first and fix any NUxxxx errors that appear.
dotnet restore
dotnet build

# If the workspace is stale, clean and regenerate restore outputs.
dotnet clean
dotnet restore
dotnet build
4. Verify it works
ls obj/project.assets.json
dotnet build
Don't use unsafe shortcuts
  • Do not run dotnet build --no-restore before a successful restore in the same workspace.
  • Do not pass obj/ between CI stages as your restore strategy.
  • Do not treat NETSDK1004 as the root cause until restore logs are clean.

What Broke in the Dependency Graph

The build cannot find project.assets.json from the restore step, so package resolution data is missing for the current project.

Repair the dependency graph

Run dotnet restore and fix any NUxxxx errors first, avoid splitting restore and build across ephemeral workspaces, or remove --no-restore, and clean then retry with dotnet clean, then dotnet restore, then dotnet build.

Validation

Re-run the failing command and confirm the original code/message is gone, and confirm expected artifacts or outputs exist (packages restored, build/publish succeeds).

Why Resolution Broke

Usually this comes down to the restore step is missing or failed earlier, often due to a NUxxxx error, CI stages don’t share obj/ between restore and build, or --no-restore was used before dependencies were restored.

Prove the Graph Is Clean Again

obj/project.assets.json exists after restore.

dotnet build succeeds without NETSDK1004.

Mechanism

This is the part worth understanding if the quick fix did not hold. It explains what .NET is trying to do at the moment the error appears.

dotnet build consumes obj/project.assets.json generated by restore.

If restore didn’t run, failed, or its outputs were cleaned, NETSDK1004 is emitted.

Keep the Dependency Graph Healthy

To prevent this, fail CI on restore failure instead of continuing to build, and cache NuGet global packages, not obj/ directories, across CI legs.

Docs and source code

NETSDK1004 message template

User-facing message template. - GitHub

  <data name="AssetsFileNotFound" xml:space="preserve">
    <value>NETSDK1004: Assets file '{0}' not found. Run a NuGet package restore to generate this file.</value>
    <comment>{StrBegins="NETSDK1004: "}</comment>
  </data>

Need help or found a mistake? Contact RepoFlow support for questions.

Join our mailing list