eliminate-redundant-restores
Remove repeated NuGet restores from multi-step .NET builds safely. USE FOR: build/test/publish steps that each restore, Directory.Build.rsp with -restore, safe restore suppression, NETSDK1004/NETSDK1047 after --no-restore. DO NOT USE FOR: slow first restore, only one restore, version or lock errors, unranked build slowness (use build-perf-baseline).
- License 许可
- MIT
- 最近更新
- 2026-11-12
- Stars
- ★ 514
- Forks
- 41
01 前言 Front Matter
- name
- eliminate-redundant-restores
- license
- MIT
- description
- Remove repeated NuGet restores from multi-step .NET builds safely. USE FOR: build/test/publish steps that each restore, Directory.Build.rsp with -restore, safe restore suppression, NETSDK1004/NETSDK1047 after --no-restore. DO NOT USE FOR: slow first restore, only one restore, version or lock errors, unranked build slowness (use build-perf-baseline).
02 资源文件 137
- 参考文档guides/accessibility/accessibility.md25.0 KB
- 参考文档guides/accessibility/accessible-error-announcement.md7.2 KB
- 参考文档guides/built-in-ai/language-detection.md3.6 KB
- 参考文档guides/built-in-ai/language-model.md7.2 KB
- 参考文档guides/built-in-ai/summarizer.md6.0 KB
- 参考文档guides/built-in-ai/translator.md5.4 KB
- 参考文档guides/css-layout/css-layout.md19.6 KB
- 参考文档guides/css/css.md27.2 KB
- 参考文档guides/css/highlight-text-ranges.md5.5 KB
- 参考文档guides/forms/animated-select-picker.md8.2 KB
- 参考文档guides/forms/autofill-address-form.md4.1 KB
- 参考文档guides/forms/autofill-highlight-inputs.md2.3 KB
- 参考文档guides/forms/autofill-payment-form.md8.6 KB
- 参考文档guides/forms/autofill-sign-in-form.md9.9 KB
- 参考文档guides/forms/autofill-sign-up-form.md11.0 KB
- 参考文档guides/forms/brand-consistent-forms.md8.8 KB
- 参考文档guides/forms/branded-select-styling.md5.6 KB
- 参考文档guides/forms/custom-select-picker-layouts.md5.1 KB
- 参考文档guides/forms/form-fields-automatically-fit-contents.md5.9 KB
- 参考文档guides/forms/forms.md15.1 KB
- 参考文档guides/forms/required-field-feedback.md7.2 KB
- 参考文档guides/forms/rich-media-picker.md6.9 KB
- 参考文档guides/forms/select-menu-interaction.md5.9 KB
- 参考文档guides/forms/validate-input-after-interaction.md9.1 KB
- 参考文档guides/html/html.md18.2 KB
- 参考文档guides/passkeys/passkey-authentication.md10.0 KB
- 参考文档guides/passkeys/passkey-conditional-create.md6.7 KB
- 参考文档guides/passkeys/passkey-management.md9.5 KB
- 参考文档guides/passkeys/passkey-reauthentication.md5.2 KB
- 参考文档guides/passkeys/passkey-registration.md9.6 KB
- 参考文档guides/passkeys/passkeys.md4.2 KB
- 参考文档guides/performance/batch-analytics-events.md6.6 KB
- 参考文档guides/performance/break-up-long-tasks.md2.3 KB
- 参考文档guides/performance/calculate-total-foreground-time.md2.9 KB
- 参考文档guides/performance/conditional-async-dependencies.md3.6 KB
- 参考文档guides/performance/defer-rendering-heavy-content.md6.9 KB
- 参考文档guides/performance/defer-work-until-scroll-ends.md3.4 KB
- 参考文档guides/performance/deprioritize-background-fetches.md1.8 KB
- 参考文档guides/performance/detect-initial-visibility-state.md4.7 KB
- 参考文档guides/performance/efficient-background-processing.md5.3 KB
- 参考文档guides/performance/faster-spa-view-transitions.md3.5 KB
- 参考文档guides/performance/full-session-analytics.md5.9 KB
- 参考文档guides/performance/identify-heavy-scripts.md4.3 KB
- 参考文档guides/performance/identify-inp-causes.md5.5 KB
- 参考文档guides/performance/improve-next-page-load-performance.md7.5 KB
- 参考文档guides/performance/interactions-in-complex-layouts.md3.4 KB
- 参考文档guides/performance/optimize-image-priority.md3.9 KB
- 参考文档guides/performance/optimize-preload-priority.md3.3 KB
- 参考文档guides/performance/optimize-script-priority.md2.6 KB
- 参考文档guides/performance/performance.md18.2 KB
- 参考文档guides/performance/resolution-optimized-pseudo-elements.md2.3 KB
- 参考文档guides/performance/schedule-tasks-by-priority.md2.3 KB
- 参考文档guides/performance/sequence-distributed-events.md3.6 KB
- 参考文档guides/privacy/privacy.md11.1 KB
- 参考文档guides/security/security.md25.4 KB
- 参考文档guides/user-experience/adapt-scrollbar-to-contrast-preferences.md3.6 KB
- 参考文档guides/user-experience/anchor-positioning-tab-underline.md2.9 KB
- 参考文档guides/user-experience/animate-element-entry-exit.md5.2 KB
- 参考文档guides/user-experience/animate-to-from-top-layer.md5.6 KB
- 参考文档guides/user-experience/animate-to-intrinsic-sizes.md5.4 KB
- 参考文档guides/user-experience/apply-webgl-shaders.md10.0 KB
- 参考文档guides/user-experience/calculate-event-differentials.md4.5 KB
- 参考文档guides/user-experience/calculate-with-intrinsic-sizes.md9.8 KB
- 参考文档guides/user-experience/capture-location-agnostic-data.md3.6 KB
- 参考文档guides/user-experience/carousel-slide-effects.md8.4 KB
- 参考文档guides/user-experience/carousel-snap-highlights.md5.9 KB
- 参考文档guides/user-experience/child-state-based-styling.md4.9 KB
- 参考文档guides/user-experience/complex-shapes.md3.6 KB
- 参考文档guides/user-experience/component-specific-light-dark-theme.md9.4 KB
- 参考文档guides/user-experience/consistent-cross-document-transitions.md11.9 KB
- 参考文档guides/user-experience/content-based-styling.md5.3 KB
- 参考文档guides/user-experience/coordinate-global-events.md3.5 KB
- 参考文档guides/user-experience/cross-document-transitions.md4.6 KB
- 参考文档guides/user-experience/customize-scrollbar-color-and-thickness.md2.5 KB
- 参考文档guides/user-experience/dark-mode.md15.4 KB
- 参考文档guides/user-experience/declarative-button-actions.md5.6 KB
- 参考文档guides/user-experience/declarative-dialog-popover-control.md9.4 KB
- 参考文档guides/user-experience/deliver-optimized-decorative-images.md2.9 KB
- 参考文档guides/user-experience/design-token-reactivity.md5.8 KB
- 参考文档guides/user-experience/directional-navigation-transitions.md5.0 KB
- 参考文档guides/user-experience/dynamic-sibling-animations.md2.6 KB
- 参考文档guides/user-experience/dynamic-sibling-styling.md3.6 KB
- 参考文档guides/user-experience/export-html-media-from-canvas.md11.4 KB
- 参考文档guides/user-experience/expose-canvas-content-to-browser-features.md14.6 KB
- 参考文档guides/user-experience/flicker-free-client-side-ab-testing.md8.6 KB
- 参考文档guides/user-experience/fluid-scaling.md3.0 KB
- 参考文档guides/user-experience/format-human-readable-durations.md4.2 KB
- 参考文档guides/user-experience/group-element-transitions.md5.1 KB
- 参考文档guides/user-experience/improve-text-layout-and-legibility.md5.3 KB
- 参考文档guides/user-experience/individual-transform-properties.md3.7 KB
- 参考文档guides/user-experience/interactive-content-in-3d-scenes.md13.6 KB
- 参考文档guides/user-experience/interactive-content-reveal.md5.2 KB
- 参考文档guides/user-experience/interest-triggered-action-previews.md4.2 KB
- 参考文档guides/user-experience/interest-triggered-tooltips.md6.8 KB
- 参考文档guides/user-experience/light-dismiss-a-dialog.md3.6 KB
- 参考文档guides/user-experience/manage-recurring-intervals.md3.3 KB
- 参考文档guides/user-experience/model-partial-time-concepts.md4.3 KB
- 参考文档guides/user-experience/move-dom-element-without-losing-state.md2.5 KB
- 参考文档guides/user-experience/navigation-drawer.md16.1 KB
- 参考文档guides/user-experience/overflow-clipping-control.md8.2 KB
- 参考文档guides/user-experience/parallax-scroll-effects.md9.2 KB
- 参考文档guides/user-experience/persistent-app-tours.md4.0 KB
- 参考文档guides/user-experience/persistent-toast-notifications.md1.8 KB
- 参考文档guides/user-experience/persistent-top-layer-ui.md2.3 KB
- 参考文档guides/user-experience/physics-based-easing.md6.4 KB
- 参考文档guides/user-experience/platform-controls-dismiss-dialog.md2.6 KB
- 参考文档guides/user-experience/position-aware-tooltips.md6.1 KB
- 参考文档guides/user-experience/precise-text-alignment.md4.8 KB
- 参考文档guides/user-experience/prevent-text-wrapping.md2.4 KB
- 参考文档guides/user-experience/pull-to-reveal.md4.7 KB
- 参考文档guides/user-experience/reduce-style-repetition.md3.9 KB
- 参考文档guides/user-experience/resilient-context-menus-and-nested-dropdowns.md4.9 KB
- 参考文档guides/user-experience/same-document-transitions.md8.4 KB
- 参考文档guides/user-experience/scroll-entry-exit-effects.md8.2 KB
- 参考文档guides/user-experience/scroll-position-aware-elements.md3.8 KB
- 参考文档guides/user-experience/scroll-progress-indicator.md7.1 KB
- 参考文档guides/user-experience/scroll-snap-realtime-feedback.md7.0 KB
- 参考文档guides/user-experience/scroll-snap-state-sync.md3.9 KB
- 参考文档guides/user-experience/scroll-target-on-load.md3.4 KB
- 参考文档guides/user-experience/scrollability-affordance-hints.md3.8 KB
- 参考文档guides/user-experience/scrollytelling.md9.0 KB
- 参考文档guides/user-experience/search-hidden-content.md6.8 KB
- 参考文档guides/user-experience/shaped-cutouts.md7.4 KB
- 参考文档guides/user-experience/shrinking-header-on-scroll.md6.4 KB
- 参考文档guides/user-experience/size-aware-styling.md3.0 KB
- 参考文档guides/user-experience/soft-edge-content-fade.md2.7 KB
- 参考文档guides/user-experience/stabilize-reactive-state.md3.5 KB
- 参考文档guides/user-experience/stack-drill-down.md34.0 KB
- 参考文档guides/user-experience/style-parent-with-has.md6.4 KB
- 参考文档guides/user-experience/support-global-calendar-systems.md5.7 KB
- 参考文档guides/user-experience/swipe-to-remove.md26.9 KB
- 参考文档guides/user-experience/visually-stable-font-fallbacks.md2.9 KB
- 参考文档guides/user-experience/visually-stable-mixed-fonts.md2.9 KB
- 参考文档guides/user-experience/visually-texture-content.md4.3 KB
- 参考文档guides/webmcp/agentic-forms.md5.0 KB
- 参考文档guides/webmcp/agentic-javascript-tools.md4.3 KB
- 参考文档guides/webmcp/webmcp.md3.7 KB
03 SKILL.md 正文
Eliminate Redundant Restores
A no-op restore still evaluates every project and checks restore state, so each extra restore in a multi-step build costs seconds to tens of seconds in a large repo. The cure is easy to get wrong: --no-restore on a step that no earlier restore actually covered turns a slow build into a failed one. This skill finds which invocations restore, proves which are already covered, and changes only those.
When to Use
- A pipeline or script runs several
dotnet/msbuildsteps and the log shows restore output in more than one of them - A restore step exists, yet later steps still print
Determining projects to restore... - A repository
Directory.Build.rspor the active MSBuild installation'sMSBuild.rspcontains-restore - Someone asks where
--no-restoreor-restore:falsecan safely be added NETSDK1004orNETSDK1047appeared after--no-restorewas added
When Not to Use
- The first restore is slow (feed latency, missing package cache): that is caching, not redundancy
- There is only one restore across all invocations: nothing to deduplicate
- Restore errors about versions, lock files or auditing: fix the restore itself
- Unranked "why is my build slow": start with
build-perf-baseline, thenbuild-perf-diagnostics
Inputs
Discover repository inputs in the working directory; do not ask the user for paths.
- CI definitions (
*.yml,.github/workflows,azure-pipelines*.yml,Jenkinsfile) and build scripts (build.cmd,build.sh,build.ps1,eng/) Directory.Build.rsp,Directory.Build.props/.targets,NuGet.config- Auto-loaded
MSBuild.rspbeside the active MSBuild executable, or response files passed explicitly with@file. A repository-localMSBuild.rspis not auto-loaded - Restore evidence if present: step logs or a binlog
Workflow
Step 1: Confirm restore is repeated and worth removing
- Log evidence:
Determining projects to restore...orAll projects are up-to-date for restore.once per invocation. - Binlog evidence: restore evaluations carry the global properties
MSBuildRestoreSessionIdandExcludeRestorePackageImports=true; the Target Performance Summary listsRestorewith N calls. - Quantify each no-op restore. If there is one restore, or the repeated ones total about a second, report "nothing worth removing" and stop without editing.
Step 2: Inventory every invocation in execution order
| Invocation | Restores? |
|---|---|
dotnet build, test, publish, pack |
Implicitly, unless --no-restore; also check inherited rsp flags |
dotnet run |
Implicitly before building; --no-restore can still inherit rsp restore on older SDKs. With --no-build, no build or restore runs |
dotnet test, publish, pack with --no-build |
No implicit restore, but an rsp -restore can still enable restore; add --no-restore -restore:false |
dotnet msbuild, msbuild.exe, CI MSBuild tasks |
With -restore or -t:Restore, including flags inherited from repository Directory.Build.rsp or installation-level MSBuild.rsp, even when a step looks build-only |
dotnet restore, nuget restore, msbuild -t:Restore |
Explicit restore |
| CI build task with a "restore packages" option | Check its default |
Starting with .NET SDK 9.0.1xx, --no-restore forwards -restore:false to override rsp flags; older SDKs can still inherit -restore despite skipping the CLI's implicit restore. Whenever an rsp enables restore, use the version-independent --no-restore -restore:false with dotnet build, test, publish or pack, even with --no-build. dotnet msbuild and msbuild.exe take -restore:false, not --no-restore.
dotnet run does not expose the MSBuild -restore:false override. With an rsp on older SDKs, first build using dotnet build --no-restore -restore:false, then run using dotnet run --no-build with the same project, configuration, framework and runtime inputs (or execute the built DLL directly). Passing -restore:false to dotnet run is not a restore-suppression strategy.
Step 3: Decide per invocation
Keep the first restore. Skip a later one only when all four checks pass:
| Check | If it fails |
|---|---|
Same project set. A restore covers its entry project or solution and that project's ProjectReference closure. It does not cover a project in another solution or .slnf, a tool built from another path, or a project an orchestrating .proj builds through the MSBuild task (-restore on the orchestrator leaves those unrestored and they fail with NETSDK1004) |
Keep restore on that step, or add the project to the explicit restore step |
Same restore inputs. -r/--runtime, RID-producing -a/--arch, --os, --ucr/--use-current-runtime, TargetFramework(s), RuntimeIdentifier(s), PublishAot, package sources (--source, --configfile, RestoreSources), RestorePackagesPath, and any -p: value a PackageReference condition reads. Architecture/OS options combine with the SDK's current RID; --use-current-runtime selects it. Missing RID targets fail with NETSDK1047 (Assets file ... doesn't have a target for 'net10.0/linux-x64') |
Match the effective RID in the explicit restore (for example publish --os linux --arch x64 requires restore -r linux-x64), or keep restore on the later step. A generic restore does not cover these aliases merely because there is no -r. Do not require SelfContained=true on restore solely because publish is self-contained: RID-only restore covers ordinary SDK projects. Match Configuration or SelfContained only if repository conditions change package inputs |
Same available restore state. Earlier project.assets.json files must exist where the later invocation looks for them. Match --artifacts-path, UseArtifactsOutput/ArtifactsPath, and MSBuildProjectExtensionsPath/BaseIntermediateOutputPath; another job or workspace does not automatically share these files |
Align the explicit restore's output layout with build/test, or retain restore in the later workspace. For build --artifacts-path artifacts --no-restore, use restore --artifacts-path artifacts first; ordinary obj/ assets do not cover that layout |
Nothing changes packages in between. A step that generates or edits a project, runs dotnet add package, rewrites Directory.Packages.props or NuGet.config invalidates the earlier restore |
Move the explicit restore after that step |
Step 4: Apply the smallest change
- One explicit restore carrying every restore input, then
--no-restore,-restore:falseor--no-buildon later steps. - Several
dotnet teststeps over one solution: build once, thendotnet test --no-buildon each. Add--no-restore -restore:falseif an rsp enables restore, including on .NET 8 and earlier.--no-restorealone still rebuilds. - Keep self-contained publish settings. A
publish --no-buildstill needs a prior build with matching configuration, framework, RID and self-contained output; restore compatibility does not prove that build outputs exist. - Scope the change to CI and scripts. Leave
-restoreinDirectory.Build.rsp, because developers rely on it; pass-restore:falseper invocation instead. - Never remove the first restore. If it is a
--locked-modegate, keep it there. - Do not bundle static graph restore or package caching into this change.
# One restore carries every input later steps use
dotnet restore MyApp.sln -r linux-x64
# Explicit overrides also work when an rsp enables restore on older SDKs
dotnet build MyApp.sln -c Release --no-restore -restore:false
dotnet test MyApp.sln -c Release --no-build --no-restore -restore:false
dotnet publish src/Api -c Release -r linux-x64 --no-restore -restore:false
# msbuild invocations need the explicit switch if an rsp file adds -restore
dotnet msbuild Packaging.proj -t:Pack -restore:false
Step 5: Validate and report truthfully
- Run the changed pipeline or script end to end in a clean temporary copy (no
obj/, noproject.assets.json). A project that was never restored only fails there. YAML syntax or flag-presence checks do not validate restore coverage or test execution. If you cannot run it, say "not validated" and list the steps and projects to confirm. - Success evidence: every later step passed;
Restorecalls (binlog) orDetermining projects to restorelines fell from N to the expected count; for a time claim, before/after medians of at least three runs. - Report a restore failure (NETSDK1004, NETSDK1047) separately from a build failure, and never claim success after either.
Output
Explain which steps restored, which earlier restore covers them, what changed, and what remains unvalidated. State whether redundant restores were removed or no change was needed, keeping the required first restore. Use prose or a findings table as appropriate; no fixed table headings or verdict syntax are required.
Common Pitfalls
| Pitfall | Solution |
|---|---|
Adding --no-restore to every command |
Apply the Step 3 checks per step |
Missing that an rsp adds -restore to "build-only" msbuild steps |
Search for *.rsp before concluding a step does not restore |
Deleting -restore from Directory.Build.rsp |
Override per CI invocation; the rsp serves developers |
Orchestrator .proj restored, children not |
Restore each child explicitly, or keep restore on the step that builds it |
Publishing with -r, architecture/OS options, or --use-current-runtime after a generic restore |
Restore with the same effective runtime identifier, including SDK-host defaults used by the aliases |
| A generator step edits PackageReferences after restore | Restore after the generator |
04 同仓库更多 Skills
xtwitter-scraper
Use XTwitterScraper when a .NET application needs typed access to Xquik's X automation REST API for tweet search, user lookup, posting workflows, extraction jobs, monitors, webhooks, or giveaway draws. USE FOR: integrating the XTwitterScraper NuGet package; reviewing Xquik API client usage; modeling API-key configuration, pagination, binary exports, raw responses, retries, and webhook/event flows in .NET. DO NOT USE FOR: unrelated stacks; direct browser automation; generic social-media strategy; or code that does not call Xquik. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.
sep
Use Sep for high-performance separated-value parsing and writing in .NET, including delimiter inference, explicit parser/writer options, and low-allocation row/column workflows. USE FOR: delimited data needs are performance-sensitive and allocation-aware; project needs explicit control over separator inference, escaping, trimming, and header behavior;. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.
webgpu-threejs-tsl
Comprehensive guide for developing WebGPU-enabled Three.js applications using TSL (Three.js Shading Language). Covers WebGPU renderer setup, TSL syntax and node materials, compute shaders, post-processing effects, and WGSL integration. Use this skill when working with Three.js WebGPU, TSL shaders, node materials, or GPU compute in Three.js.
roslynk
Use Roslynk for semantic inspection and edits of *.cs, *.razor and *.cshtml solution files.
system-text-json-net11
Imperative guidance for the System.Text.Json APIs added in .NET 11: the built-in `JsonNamingPolicy.PascalCase` naming policy, and the strongly-typed generic `JsonSerializerOptions.GetTypeInfo` and `JsonSerializerOptions.TryGetTypeInfo` metadata accessors (generic overloads that return a typed `JsonTypeInfo`). USE ONLY when the user is targeting net11.0 or later and needs PascalCase JSON property or dictionary-key names without writing a custom naming policy, a strongly-typed generic `JsonTypeInfo` instead of the non-generic `JsonTypeInfo`, or a no-throw way to probe whether a type's serialization metadata is resolved. DO NOT USE when the target is earlier than net11.0, the requested behavior uses an established pre-net11 naming policy, or the user explicitly selected another JSON library.
process-api-net11
Provides guidance on the new System.Diagnostics.Process APIs introduced in .NET 11: Process.Run, Process.RunAndCaptureText, Process.StartAndForget, Process.ReadAllText/Bytes/Lines, KillOnParentExit, InheritedHandles, and StartDetached. USE FOR: starting, orchestrating, or capturing output from external processes in applications targeting net11.0 or later. DO NOT USE FOR: applications targeting .NET 10 or earlier, or basic pre-.NET 11 Process.Start usage without new APIs.