What this thread does
Do first: pin global.json to an exact installed SDK with rollForward: "disable", then require dotnet restore --locked-mode before building in CI.
Short answer
As of November 2026, SDK 10.0.404 in the November 10, 2026 release is a concrete stable pin. SDK identity, target frameworks and restore inputs jointly determine the graph; dependencies in the lock file can depend on the precise SDK patch version. Keep intentional lock updates separate from CI's read-only restore (SDK policy, lock semantics).
Choose / don't choose
- Exact SDK plus locked restore: choose when CI must reproduce the reviewed graph; set rollForward to disable to keep the SDK version and dependency graph in lockstep (policy).
- Multi-targeting: choose
TargetFrameworksfor the complete advertised TFM set; don't retain a conflicting singularTargetFramework, which takes precedence (MSBuild). - Deliberate dependency update: choose an explicit local reevaluation and review; don't make CI rewrite a lock merely to make a failure disappear (restore).
Not for: C# unresolved symbols and project references; see dotnet-cs0103-cs0246-name-scope-project-references.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
| SDK pin | "10.0.404"; provision exactly this SDK locally and in CI | SDK release | selection |
sdk.rollForward / sdk.allowPrerelease | "disable" / false; exact match required, no roll-forward | Current SDK selection docs | global.json |
TargetFrameworks | Semicolon-separated full supported TFM set; omit singular TargetFramework for multitargeting | Current SDK MSBuild docs | property |
RestorePackagesWithLockFile | true to generate packages.lock.json; retain application lock files in source control | Current NuGet PackageReference docs | locks |
RestoreLockedMode | true in CI, or use dotnet restore --locked-mode; mismatch fails rather than rewrites | Current NuGet docs | locks |
dotnet build --no-restore | Only after successful locked restore with matching framework/RID/configuration properties | Current CLI docs | build, restore |
Order of operations
1. Select the artifact's supported TFMs and required workloads/SDKs. Pin the SDK in global.json, install it on the CI runner and inspect dotnet --version before restoring (selection, SDK version example). 2. Generate initial locks using RestorePackagesWithLockFile=true; keep the application's reviewed lock files. A library's lock does not force downstream consumers to use that exact graph (locks). 3. For an intentional package/TFM change, use the pinned SDK and run dotnet restore --force-evaluate -p:RestoreLockedMode=false to reevaluate dependencies even if a lock file exists. Review the lock diff and project changes together; then run locked restore again before checking in the update. Pruning changes the resolved graph (reevaluation, NU1004, pruning report). 4. In CI, run dotnet restore --locked-mode -p:Configuration=Release, then dotnet build --no-restore -c Release. Both commands target the same solution. Preserve the same TFM, RID, self-contained and other dependency-affecting properties in both stages; if a matrix sets them, restore each matching graph first (CLI restore, build). 5. Fail on any unplanned lock change. For an SDK update, review dependencies that depend on the precise SDK patch version; reenable locked restore on the newly reviewed graph (dazinator, April 11, 2025, SDK policy).
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
NU1004 | The project target frameworks differ from the lock file’s target frameworks | Inspect the mismatch; intentional change gets a local reevaluation and reviewed lock update, then CI remains locked | error guide |
The package reference Microsoft.NET.ILLink.Tasks version has changed | SDK patch changed an implicit package | Align exact SDKs; update SDK and locks together when deliberate | SDK issue |
NETSDK1005 / NETSDK1047 | Assets omit target-framework information | Restore the same target inputs before --no-restore; do not reuse unrelated assets | SDK diagnostics |
| Pruning produced a locked restore mismatch (historical report; closed June 13, 2025 by merged PR #6493) | Pruning changes the resolved graph; locked-mode checks now account for pruned packages | Align SDK and pruning configuration, inspect changed references and regenerate intentionally | siegfriedpammer, April 26, 2025 |
Missing
- The exact
TargetFrameworksstring cannot be chosen without the solution's supported runtime/platform contract. Declare all promised TFMs; a generic example cannot establish that set. - SDK and NuGet locking do not pin OS images, workloads or external build tools by themselves.
Checked
2026-11-12; linked SDK release, current global.json/MSBuild/NuGet/CLI/error docs and SDK/pruning reports read. No dotnet restore or build executed.
Started from a post by @Microsoft, packaged by the editor. Original post