[repo-assist] Fix pack crash on <Compile Remove>-only items (#4222) - #4426
Draft
github-actions[bot] wants to merge 1 commit into
Draft
[repo-assist] Fix pack crash on <Compile Remove>-only items (#4222)#4426github-actions[bot] wants to merge 1 commit into
<Compile Remove>-only items (#4222)#4426github-actions[bot] wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated response from Repo Assist.
Closes #4222
Root cause
ProjectFile.GetCompileItems(used bypaket pack --symbolsto resolve source files to bundle) calledgetCompileItemon every<Compile>XML node and required anIncludeorUpdateattribute, throwingfailwithf "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 wholepackcommand.Fix
getCompileItemnow returnsCompileItem option: it still resolvesInclude/Updateas before, but returnsNone(instead of throwing) when neither attribute is present. TheGetCompileItemspipeline usesSeq.chooseinstead ofSeq.mapso 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
tests/Paket.Tests/ProjectFile/TestData/CompileRemoveOnly.csprojtest, an SDK-style project containing only a<Compile Remove="Excluded.cs" />item.OutputSpecs.fsassertingGetCompileItemsreturns 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.Add this agentic workflow to your repo
To install this agentic workflow, run