Repository navigation
[repo-assist] Fix dotnet pack failure with --include-symbols due to multiple nuspec files - #4367
Conversation
… files When --include-symbols or --include-source is used, dotnet's GenerateNuspec target produces both a regular .nuspec and a .symbols.nuspec file. The PaketOverrideNuspec target's _NuspecFiles glob then matched both files, and MSBuild joined them with ';' when converted to the single NuspecFileAbsolutePath property used by PackTask, producing an invalid combined path and causing 'filename ... syntax is incorrect' errors during pack. This adds a _PrimaryNuspecFile item that excludes *.symbols.nuspec files (with fallback to the original list if nothing remains), and uses it for NuspecFileAbsolutePath while fix-nuspecs still processes all nuspec files. Closes #3272 Co-authored-by: Copilot <[email protected]>
|
/repo-assist It must be possible to add an integration test of some kind for this. he problem with appveyor has ben fixed so you should be able to build and test |
|
✓ Repo Assist completed successfully, see workflow run.
|
Co-authored-by: Copilot <[email protected]>
|
🤖 This is an automated response from Repo Assist. Added an integration test scenario ( Verified locally:
Add this agentic workflow to your repoTo install this agentic workflow, run |
🤖 AI Disclosure: This PR was created by Repo Assist, an automated AI assistant, in response to issue #3272 (and duplicate #3160).
Closes #3272
Root cause
When
dotnet packis run with--include-symbols(or--include-source), the .NET SDK'sGenerateNuspectarget produces two nuspec files in the intermediate output directory: e.g.Foo.1.0.0.nuspecandFoo.1.0.0.symbols.nuspec.Paket's
PaketOverrideNuspectarget (insrc/Paket.Core/embedded/Paket.Restore.targets) globs for*.$(PackageVersion).nuspec, which matches both files. That@(_NuspecFiles)item list is then converted viaConvertToAbsolutePathinto a single MSBuild property,NuspecFileAbsolutePath, which is used directly asPackTask'sNuspecFileparameter. When the item list has more than one entry, MSBuild joins them with;, producing something like...\Foo.1.0.0.nuspec;...\Foo.1.0.0.symbols.nuspec.PackTask/the underlying pack machinery then fails with an error like:because it isn't expecting a semicolon-joined string in that parameter.
Fix
Added a new
_PrimaryNuspecFileitem that excludes files matching*.symbols.nuspecfrom_NuspecFiles(falling back to the original, unfiltered list if that exclusion leaves nothing — e.g. for older SDKs/configurations where only a.symbols.nuspecexists).NuspecFileAbsolutePathis now derived from_PrimaryNuspecFileinstead of the raw_NuspecFileslist, so packing always resolves to exactly one nuspec path. The existingpaket fix-nuspecscall is left operating on the full_NuspecFileslist, so both the regular and symbols nuspecs still get corrected by Paket as before.Trade-offs / notes
--include-symbolspack scenario end-to-end in this sandbox (no livedotnet pack --include-symbolsrepro against a real project was run), so I verified: (a) the change compiles/builds correctly as an embedded resource inPaket.Core.dll, and (b) the MSBuild XML remains well-formed. Manual verification with a real project using--include-symbolsbefore merging would be valuable..symbols.nuspecfile, or failing loudly with a clearer error) is preferred.Test Status
dotnet restore src/Paket.Core/Paket.Core.fsproj -p:PaketDisableGlobalRestore=true— succeeded.dotnet build src/Paket.Core/Paket.Core.fsproj -f netstandard2.0 --no-restore -p:PaketDisableGlobalRestore=true— Build succeeded, 0 errors (11 pre-existing warnings unrelated to this change).stringson the builtPaket.Core.dllthat the updated embeddedPaket.Restore.targetscontent (including the new_PrimaryNuspecFileitem) is present in the compiled assembly.dotnet pack --include-symbolsintegration test against a real project in this sandbox environment — this would be a good manual verification step before merging.Add this agentic workflow to your repo
To install this agentic workflow, run