NETSDK1004: Assets file project.assets.json not found
MSBuild is missing the NuGet dependency graph. The build skipped restore, obj was deleted or moved, or two projects share one intermediate path.

Introduction & Quick Summary
error NETSDK1004: Assets file 'D:\src\Billing\obj\project.assets.json' not found.
Run a NuGet package restore to generate this file.The build asked MSBuild for the dependency graph it uses to resolve references, and the file that holds that graph is missing. project.assets.json is generated by NuGet restore into the obj directory; it is not produced by the compiler and is not committed to source control.
The five reasons it goes missing:
- Restore was skipped.
dotnet build --no-restoreordotnet publish --no-restoreon a clean checkout. objwas deleted or never restored. Cleaning withrm -rfor a CI cache that only keepsbin.- The path was relocated.
BaseIntermediateOutputPathorMSBuildProjectExtensionsPathsends the file somewhere the build does not look. - Two projects share one
obj. Custom intermediate paths collide and one project's restore overwrites the other's. - Restore failed but the build continued. Failed feeds, credentials, or a missing TFM leave no assets file and a warning that scrolls past.
| Message detail | Meaning | Fix |
|---|---|---|
Path ends in obj/project.assets.json | Default intermediate output | Run restore |
| Path is outside the project | Custom intermediate path | Fix BaseIntermediateOutputPath |
| Same path for two projects | Shared intermediates | Give each project its own |
Run a NuGet package restore | No assets at all | dotnet restore |
Appears only with --no-restore | Flag removed implicit restore | Drop the flag |
Core Mechanics, Signatures & Reproducible Setup
Restore reads the project file, resolves PackageReference items against configured feeds, writes project.assets.json plus project.nuget.cache and *.nuget.g.props into the intermediate output directory. dotnet build runs an implicit restore unless --no-restore is passed; msbuild does not restore by default for SDK-style projects invoked directly, which is why IDE builds and command-line builds diverge.
Reproduce it deterministically:
dotnet new classlib -n AssetsDemo -o /tmp/assets-demo
cd /tmp/assets-demo
dotnet build --no-restore
# error NETSDK1004: Assets file '.../obj/project.assets.json' not found.Then restore and build:
dotnet restore
ls obj/
# AssetsDemo.csproj.nuget.dgspec.json project.assets.json project.nuget.cache
dotnet build --no-restoreInspect what the assets file claims, which is the fastest way to catch a wrong target framework:
python3 -c "
import json
d=json.load(open('obj/project.assets.json'))
print(d['targets'].keys())
print(d['project']['frameworks'].keys())
"If the printed target differs from the project's TargetFramework, restore evaluated a different configuration than the build.
A typical project file that restores reliably in CI:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
</Project>With a lock file, CI can restore in locked mode and fail fast when the graph changed:
dotnet restore --locked-modeKey Comparison Table
| Command | Restores | Writes assets | Use in CI |
|---|---|---|---|
dotnet restore | Yes | Yes | First step |
dotnet build | Yes, implicit | Yes | Normal build |
dotnet build --no-restore | No | No | After an explicit restore |
dotnet publish | Yes, implicit | Yes | Normal publish |
dotnet publish --no-restore | No | No | After publish-time restore |
dotnet test --no-restore | No | No | After restore |
msbuild /t:Build | No | No | Requires /t:Restore first |
| Cause | Detection | Durable fix |
|---|---|---|
| Missing restore | obj has no assets file | Remove --no-restore |
CI cache misses obj | Cache key only covers bin | Cache ~/.nuget/packages and restore |
| Custom intermediate path | Assets file in unusual directory | Set per-project path |
Shared obj | Two projects, one assets file | Unique BaseIntermediateOutputPath |
| Failed restore | Warning above the error | Fix feed credentials |
| Wrong SDK | global.json pins old SDK | Align SDK and TFM |
Practical Edge Cases, Error Fixes & Deep Dive Code Examples
Case 1: A fresh clone built with --no-restore
git clone https://example.com/billing.git && cd billing
dotnet build --no-restore
# error NETSDK1004The flag exists to save time in a pipeline that already restored. On a fresh machine it guarantees failure. Drop the flag, or add an explicit restore step before the build:
dotnet restore
dotnet build --no-restoreIf the reason for --no-restore was a slow feed, cache the NuGet package folder instead of skipping restore entirely.
Case 2: CI cache that restores bin but not obj
- uses: actions/cache@v4
with:
path: |
~/.nuget/packages
src/**/obj
key: nuget-${{ hashFiles('**/*.csproj', '**/packages.lock.json') }}Caching obj is an optimization, not a requirement; caching only bin produces binaries with no dependency graph and the next build fails. The safe minimum is the global packages folder plus a real restore step:
- run: dotnet restore --locked-mode
- run: dotnet build --no-restore -c ReleaseCase 3: Custom BaseIntermediateOutputPath collisions
<!-- Directory.Build.props -->
<PropertyGroup>
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)obj\</BaseIntermediateOutputPath>
</PropertyGroup>Every project under that directory now writes to the same obj, so restore for project B overwrites A's assets file. Make the path project-specific:
<PropertyGroup>
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
</PropertyGroup>BaseIntermediateOutputPath must be set before the SDK props are imported to take effect; a value placed after <Project Sdk="..."> is often ignored, which makes the build look at the default path while the file lands elsewhere.
Case 4: Multi-targeting where restore evaluated one framework
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>dotnet build -f net9.0 --no-restore
# NETSDK1004 if restore only ran for net8.0Restore evaluates all target frameworks listed at restore time; a property that changes the list conditionally per configuration breaks that:
<TargetFrameworks Condition="'$(Configuration)' == 'Release'">net9.0</TargetFrameworks>Remove the condition, or restore explicitly for the configuration you build:
dotnet restore -p:Configuration=Release
dotnet build -c Release --no-restoreCase 5: Restore "succeeded" while a feed was unreachable
warning NU1801: Unable to load the service index for source https://pkgs.example.com/v3/index.json
error NETSDK1004: Assets file ... not found.The warning explains the real failure. RestoreIgnoreFailedSources=true downgrades feed errors to warnings, so a pipeline reports a successful restore step and then fails at build with no assets. Remove the property in CI, or add a health check for the feed before restore:
curl -fsS -o /dev/null -w '%{http_code}\n' https://pkgs.example.com/v3/index.jsonPrivate feeds also need credentials in NuGet.config or a token environment variable; an unauthenticated 401 produces the same warning-then-NETSDK1004 pattern.
Case 6: Docker builds that copy the project but not the restore output
COPY . .
RUN dotnet publish src/Api/Api.csproj -c Release --no-restore -o /appThe image never ran restore, so the obj copied from the host may be stale or absent depending on .dockerignore. Restore inside the image with the project files first, then copy the rest:
COPY src/Api/Api.csproj src/Api/
RUN dotnet restore src/Api/Api.csproj
COPY . .
RUN dotnet publish src/Api/Api.csproj -c Release --no-restore -o /appIf .dockerignore excludes obj, the second stage has nothing to reuse and the flag must go, at the cost of restoring twice.
Common Compilation/Runtime Mistakes & Version Gotchas
--no-restorecopied into every command. It is valid only after a matching restore with the same configuration, target framework and properties. Any difference produces a missing or stale assets file.project.assets.jsoncommitted to git. It contains absolute paths in some fields and is machine-specific; committing it hides missing restores on the author's machine and breaks on CI.- SDK pinning through
global.json. ArollForwardoflatestPatchkeeps a project on an old SDK while the TFM targets a newer one, and restore writes assets for a framework the build cannot compile. objdeleted while the IDE is open. Visual Studio keeps an in-memory project system and reports NETSDK1004 until the project is reloaded, even after a successful command-line restore.- .NET 10 SDK default artifacts path. Newer SDKs can place
objunder anartifactsdirectory whenUseArtifactsOutputis enabled; scripts that look forbin/objin the project folder then miss the assets file entirely. - NuGet fallback folders.
RestoreAdditionalProjectFallbackFolderscan mask a missing package on one machine and fail on another where the folder does not exist, with NETSDK1004 as the visible symptom.
When comparing a working and a failing project file, paste both into the diff tool. The generated assets graph is JSON, so the JSON formatter makes target framework and package identity mismatches readable without scrolling a minified file.
Primary references: NETSDK1004 documents this error and the restore step that resolves it, and dotnet restore covers the options that control when assets are generated.
Official references
primary documentationThe C# documentation that defines the behaviour this guide explains.
Try matching browser tools
All toolsSmall utilities that fit C# work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related C# guides
All C# guidesC# CS0246: The type or namespace name could not be found
CS0246 is a compile-time resolution failure: a missing using, package, target framework, or an unrestored project. Trace it backward from the symbol.
C#: NullReferenceException: Object reference not set
The message never names the null. Read the stack trace, enable nullable reference types, and use null-conditional access instead of guessing.
C# CS7036: no argument given that corresponds to the required parameter
CS7036 means the chosen constructor or method expects an argument the caller skipped. Match the signature instead of casting or adding a null default.
C# CS0117: 'X' does not contain a definition for 'Y'
CS0117 means the compiled assembly has no such member, usually from an older target framework or package. Check the API surface before editing code.
More in C#
All C# guidesThe guides filed next to this one in C#, in library order.