Pack generator DLLs via post-build target to fix empty analyzer packages#9785
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes analyzer/source-generator NuGet packages that were shipping without their generator DLLs by moving DLL inclusion from evaluation-time globbing to a pack-time target executed during nuspec generation.
Changes:
- Replace
None Include="$(OutputPath)\*.dll" Pack="true"with aTargetsForTfmSpecificContentInPackagehook that addsTfmSpecificPackageFileitems after build output exists. - For multi-targeting
CookieCrumble.Xunit/CookieCrumble.Xunit3, emit the analyzer DLL only once (fornet10.0) to avoid NU5118 duplicate-path collisions.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Mocha/src/Mocha.Analyzers/Mocha.Analyzers.csproj | Adds pack-time target to include analyzer DLL(s) into analyzers/dotnet/cs. |
| src/HotChocolate/Core/src/Types.Analyzers/HotChocolate.Types.Analyzers.csproj | Adds pack-time target to include generator DLL(s) into analyzers/dotnet/cs. |
| src/CookieCrumble/src/CookieCrumble.Xunit/CookieCrumble.Xunit.csproj | Adds pack-time target and conditions it to include the analyzer DLL only once. |
| src/CookieCrumble/src/CookieCrumble.Xunit3/CookieCrumble.Xunit3.csproj | Adds pack-time target and conditions it to include the analyzer DLL only once. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Jun 1, 2026
This was referenced Jun 8, 2026
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.
Summary
HotChocolate.Types.Analyzers,Mocha.Analyzers,CookieCrumble.Xunit,CookieCrumble.Xunit3) shipped without their generator DLL starting with the16.0.10previews — e.g.16.0.10-p.6contains only the nuspec. This breaks consumers witherror CS0121on the generatedAddTypes()(the call falls back to the two runtime overloads, which a zero-arg call matches ambiguously).<None Include="$(OutputPath)...dll" Pack="true" PackagePath="analyzers/dotnet/cs">. That item is expanded during MSBuild evaluation, before Build runs, so on a clean checkout it globs zero files and packs nothing — with no error. Nuke's separateCompilestep used to pre-populatebin/, masking the bug; Remove Nuke; switch CI and release to direct dotnet calls #9772 replaced that with a single-shotdotnet pack, exposing it. Confirmed by package timeline:16.0.10-p.2(pre-merge) intact,-p.5/-p.6(post-merge) empty.TargetsForTfmSpecificContentInPackagetarget, which runs during nuspec generation after pack's build phase has populated$(OutputPath). No explicitBuilddependency, sodotnet pack --no-buildstill works (an explicit dependency would trip NETSDK1085). For the two multi-targeting CookieCrumble packages, the analyzer is emitted only fornet10.0to avoid a duplicate package-path collision (NU5118).Test plan
dotnet packof each of the four projects includesanalyzers/dotnet/cs/<generator>.dll(verified viaunzip -l).dotnet buildthendotnet pack --no-buildof each project succeeds (no NETSDK1085) and still includes the analyzer DLL.CS0121builds successfully against a locally repackedHotChocolate.Types.Analyzers16.0.10-p.6.IncludeBuildOutput=false/ analyzer-packing csproj files; the*.props/*.targets/*.xamlpack entries are unaffected (static source files present at evaluation time).