Skip to content
LatchkeyLatchkey home

.NET "error NETSDK1047: Assets file does not have a target for RID" in CI

You are publishing for a runtime identifier (RID) that restore did not produce assets for. NETSDK1047 means project.assets.json has no target for the framework/RID pair, so you must restore with that RID first.

What this error means

dotnet publish fails with "error NETSDK1047: Assets file ".../project.assets.json" doesn't have a target for 'net8.0/linux-x64'. Ensure that restore has run and that you have included ... in the RuntimeIdentifiers."

dotnet
error NETSDK1047: Assets file '/app/obj/project.assets.json' doesn't have a target for
'net8.0/linux-x64'. Ensure that restore has run and that you have included 'net8.0'
in the TargetFrameworks for your project. You may also need to include 'linux-x64'
in your project's RuntimeIdentifiers.

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

Publish for a RID that restore did not cover

A framework-dependent restore produced no RID-specific assets, but publish requests -r linux-x64, so the assets file lacks that target.

A cached restore from a prior, RID-less run

A split pipeline restored without the RID and publish reuses that obj, so the needed target is missing.

How to fix it

Restore for the runtime identifier

  1. Restore with the same RID you publish for, or let publish restore.
  2. Avoid --no-restore on a RID publish unless restore already included that RID.
  3. Re-run publish.
Terminal
dotnet restore -r linux-x64
dotnet publish -c Release -r linux-x64

Declare RuntimeIdentifiers in the project

List the RIDs you publish so restore always generates their targets.

Project.csproj
<PropertyGroup>
  <RuntimeIdentifiers>linux-x64;win-x64</RuntimeIdentifiers>
</PropertyGroup>

How to prevent it

  • Restore with the same RID you publish for.
  • Declare RuntimeIdentifiers for self-contained publishes.
  • Do not reuse a RID-less restore for a RID publish.

Frequently asked questions

What causes .NET "error NETSDK1047: assets file does not have a target for RID" in CI?
There are 2 common causes: publish for a rid that restore did not cover and a cached restore from a prior, rid-less run. A framework-dependent restore produced no RID-specific assets, but publish requests -r linux-x64, so the assets file lacks that target.
How do I fix .NET "error NETSDK1047: assets file does not have a target for RID" in CI?
There are 2 fixes depending on which cause you have: restore for the runtime identifier and declare runtimeidentifiers in the project. Work through them in order, since the first is the most common.
What does .NET "error NETSDK1047: assets file does not have a target for RID" in CI actually mean?
dotnet publish fails with "error NETSDK1047: Assets file ".../project.assets.json" doesn't have a target for 'net8.0/linux-x64'.
How do I stop .NET "error NETSDK1047: assets file does not have a target for RID" in CI happening again?
Restore with the same RID you publish for. The prevention section lists 3 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card