# .NET self-contained publish "RID restore required" in CI

> Fix self-contained dotnet publish failures in CI where a runtime identifier is required - publishing self-contained needs an explicit RID and a restore that includes it.

Source: https://latchkey.dev/learn/dotnet/dotnet-publish-self-contained-rid-restore-required-in-ci  
Updated: 2026-06-30

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.

## 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
```

> Pin the SDK with `global.json` and install exactly that version with `actions/setup-dotnet`. A floating SDK turns a runner image update into a build break on unchanged code.

## FAQ

### 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.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
