.NET self-contained publish "RID restore required" in CI
By Daniel Zoghalchali·Latchkey
A self-contained publish bundles the runtime, which requires a runtime identifier and a RID-aware restore. Without -r (or RuntimeIdentifier), publish either errors or produces a framework-dependent output, and missing RID assets surface as NETSDK1047.
What this error means
dotnet publish with --self-contained fails or warns that a RuntimeIdentifier is required, or the publish output is unexpectedly framework-dependent because no RID was supplied.
dotnet
error NETSDK1031: It is not supported to build or publish a self-contained
application without specifying a RuntimeIdentifier. Please either specify a
RuntimeIdentifier or set SelfContained to false.
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
Self-contained set without a RuntimeIdentifier
A self-contained app must target a specific platform; without a RID the SDK cannot bundle the right runtime.
Restore did not include the publish RID
Even with a RID on publish, a prior RID-less restore leaves no assets for it, producing NETSDK1047.
How to fix it
Publish self-contained with an explicit RID
Pass -r <rid> and --self-contained true together.
Ensure restore covers that RID (publish restores by default).
Always pair --self-contained with an explicit RID.
Let publish restore, or restore with the same RID.
Set RID and SelfContained in the project for reproducibility.
Frequently asked questions
What causes .NET self-contained publish "RID restore required" in CI?
There are 2 common causes: self-contained set without a runtimeidentifier and restore did not include the publish rid. A self-contained app must target a specific platform; without a RID the SDK cannot bundle the right runtime.
How do I fix .NET self-contained publish "RID restore required" in CI?
There are 2 fixes depending on which cause you have: publish self-contained with an explicit rid and set the rid and self-contained in the project. Work through them in order, since the first is the most common.
What does .NET self-contained publish "RID restore required" in CI actually mean?
dotnet publish with --self-contained fails or warns that a RuntimeIdentifier is required, or the publish output is unexpectedly framework-dependent because no RID was supplied.
How do I stop .NET self-contained publish "RID restore required" in CI happening again?
Always pair --self-contained with an explicit RID. The prevention section lists 3 changes that keep it from recurring.