Skip to content

[repo-assist] Fix pack crash on <Compile Remove>-only items (#4222) - #4426

Draft
github-actions[bot] wants to merge 1 commit into
masterfrom
repo-assist/fix-issue-4222-compile-remove-1c319795c689a05e
Draft

[repo-assist] Fix pack crash on <Compile Remove>-only items (#4222)#4426
github-actions[bot] wants to merge 1 commit into
masterfrom
repo-assist/fix-issue-4222-compile-remove-1c319795c689a05e

Conversation

@github-actions

@github-actions github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🤖 This is an automated response from Repo Assist.

Closes #4222

Root cause

ProjectFile.GetCompileItems (used by paket pack --symbols to resolve source files to bundle) called getCompileItem on every <Compile> XML node and required an Include or Update attribute, throwing failwithf "Compile entry is in unknown format" otherwise. However, MSBuild also allows <Compile Remove="pattern" /> items with neither attribute — a valid, common construct used to exclude files from compilation (e.g., after disabling a file's build action). Any project containing such an item crashed the whole pack command.

Fix

getCompileItem now returns CompileItem option: it still resolves Include/Update as before, but returns None (instead of throwing) when neither attribute is present. The GetCompileItems pipeline uses Seq.choose instead of Seq.map so these non-compile entries are silently skipped.

Trade-offs

This purely widens acceptance — no previously-valid project files change behavior. Entries with neither attribute are, by MSBuild semantics, not compile-item declarations, so skipping them (rather than trying to guess a source file) is correct.

Test Status

  • Added tests/Paket.Tests/ProjectFile/TestData/CompileRemoveOnly.csprojtest, an SDK-style project containing only a <Compile Remove="Excluded.cs" /> item.
  • Added a regression test in OutputSpecs.fs asserting GetCompileItems returns an empty sequence (no exception) for this project.
  • dotnet build src/Paket.Core/Paket.Core.fsproj -c Release: succeeded (net461 + netstandard2.0, no new warnings/errors).
  • dotnet test tests/Paket.Tests/Paket.Tests.fsproj --filter "FullyQualifiedName~OutputSpecs" -f net10.0: 38/38 passed, including the new test.

Generated by 🌈 Repo Assist, see workflow run. Learn more.
Comment /repo-assist to run again

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@ae8d551f07c7ed7619f8c58c7bb4c3ac89395d38

paket pack --symbols threw 'Compile entry is in unknown format' when
a project's <Compile Remove="..." /> item had neither Include nor
Update attributes (a valid MSBuild construct used to exclude files
from compilation). GetCompileItems now skips such entries instead of
throwing.

Closes #4222

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

dotnet pack --symbols fails with error about Compile entry not containing Update or Include attribute

0 participants