Skip to content

Delete the Slice output manifest when the last Slice file is removed - #4930

Merged
pepone merged 2 commits into
mainfrom
fix/slice-tools-retained-manifest
Sep 11, 2026
Merged

Delete the Slice output manifest when the last Slice file is removed#4930
pepone merged 2 commits into
mainfrom
fix/slice-tools-retained-manifest

Conversation

@pepone

@pepone pepone commented Sep 10, 2026

Copy link
Copy Markdown
Member

Follow-up to #4923, where the same gap was found in the Protobuf targets (Copilot's suppressed comment on _ProtoPruneStaleOutputs).

_SlicecWriteOutputManifest only runs when the project has SliceFile items. Removing the last .slice file therefore leaves the previous slicec.outputs.txt in place after _SlicecPruneStaleOutputs deletes its outputs, and every later build prunes the same paths again. A file created at one of those paths since, such as a hand-written replacement for the generated code, is deleted on each build.

_SlicecPruneStaleOutputs now deletes the manifest when there are no SliceFile items, after pruning the recorded outputs.

Verification

Two-file probe importing the source-build props/targets (macOS, .NET SDK 10.0.201), slicec runs per build:

Scenario Before After
Remove both .slice files, build outputs pruned, manifest kept outputs pruned, manifest deleted
Then create generated/a.cs by hand, build a.cs deleted a.cs kept
Add the .slice files back, build 1 1, manifest recorded again
Rename a.slice to alpha.slice a.cs pruned a.cs pruned
Unchanged build / Rebuild / Clean 1 / 1 / outputs and manifest deleted 1 / 1 / outputs and manifest deleted
Remove both .slice files, Clean outputs and manifest deleted outputs and manifest deleted

src/IceRpc (which imports these targets) builds clean from this branch.

What's Changed entry

None — only affects a hand-written file placed at a former generated-code path after the last Slice file is removed, which no project does in practice.

_SlicecWriteOutputManifest only runs when the project has SliceFile
items, so removing the last Slice file left the previous manifest in
place after its outputs were pruned. Every later build then pruned the
same paths again, deleting any file created there since, such as a
hand-written replacement for the generated code.

_SlicecPruneStaleOutputs now deletes the manifest when there are no
SliceFile items, after pruning the recorded outputs. Same fix as the
Protobuf targets in #4923.
Copilot AI lite review requested due to automatic review settings September 10, 2026 16:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is narrowly scoped to manifest lifecycle handling and aligns with the existing manifest/prune design, reducing the risk of unintended deletions in later builds.

Pull request overview

This PR closes an incremental-build safety gap in the Slice MSBuild targets: when the last SliceFile is removed from a project, the prior slicec.outputs.txt manifest could be left behind and cause subsequent builds to keep pruning files at the old generated output paths (including newly hand-written replacements).

Changes:

  • Extend _SlicecPruneStaleOutputs to delete $(IntermediateOutputPath)slicec.outputs.txt when there are no SliceFile items.
  • Prevent repeated stale-output pruning in SliceFile-empty builds by removing the now-stale manifest after the recorded outputs have been pruned.
File summaries
File Description
src/IceRpc.Slice.Tools/IceRpc.Slice.Tools.targets Deletes slicec.outputs.txt in the no-SliceFile case to stop repeated pruning of former generated-code paths.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bernardnormier bernardnormier left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment nit, the same one as on #4923.

The What's Changed entry can go: the scenario needs a hand-written file at a former generated-code path after the
last Slice file is removed, which no project does in practice. Suggested replacement:

None — only affects a hand-written file placed at a former generated-code path after the last Slice file is
removed, which no project does in practice.

Follow-up, not for this PR: the Slice targets could take the #4923 cleanups (BeforeTargets trimmed to Slicec and
SlicecClean, MatchOnMetadata instead of the relative item, no MakeDir or Exists guards, WriteOnlyWhenDifferent
on the manifest).

Comment thread src/IceRpc.Slice.Tools/IceRpc.Slice.Tools.targets Outdated
Co-authored-by: Bernard Normier <bernard@zeroc.com>
@pepone pepone added this to the 0.6.1 milestone Sep 11, 2026
@pepone
pepone merged commit ce468b3 into main Sep 11, 2026
14 checks passed
@pepone
pepone deleted the fix/slice-tools-retained-manifest branch September 11, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants