Fix source-generator package delivery and preview restore (Roslyn packaging)#4041
Conversation
…kaging) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Fixes Roslyn source-generator NuGet packaging and preview restore behavior so generator analyzers and their private runtime closure are correctly delivered, with deterministic Debug/Release package IDs and pipeline validation.
Changes:
- Adds a shared MSBuild
.targetsto package generator assemblies + private runtime closure underanalyzers/dotnet/cswhile suppressing dependencies. - Updates generator projects to use
.DebugPackageIds and imports the new packaging targets. - Fixes preview restore invocation and adds CI validation that inspects packages and builds clean net10 consumers.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/Opc.Ua.SourceGeneration/SourceGeneratorPackaging.targets | Introduces custom packing logic for analyzer payload + runtime closure. |
| tools/Opc.Ua.SourceGeneration/Opc.Ua.SourceGeneration.csproj | Adds Debug PackageId suffix and hooks in packaging targets / analyzer metadata. |
| tools/Opc.Ua.SourceGeneration.Stack/Opc.Ua.SourceGeneration.Stack.csproj | Same packaging/Debug PackageId updates for Stack generator. |
| .github/workflows/preview-publish.yml | Removes invalid restore args; adds package validation step. |
| .azurepipelines/validate-source-generator-packages.ps1 | New script to validate nupkg contents and build clean consumers. |
| .azurepipelines/preview.yml | Removes invalid restore args; adds validation task in Release preview. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4041 +/- ##
==========================================
- Coverage 73.55% 73.54% -0.01%
==========================================
Files 1345 1345
Lines 180036 180038 +2
Branches 31677 31678 +1
==========================================
- Hits 132427 132417 -10
- Misses 36911 36915 +4
- Partials 10698 10706 +8 🚀 New features to boost your workflow:
|
Failure
The source-generator projects disabled normal build-output packing without adding
their analyzer assemblies and private runtime closure back to the NuGet payload.
Debug and Release packages also shared IDs, and both preview workflows passed the
unsupported
--configurationoption todotnet restore.Fix
analyzers/dotnet/cs, excluding Roslyn host assemblies and package dependencies..DebugIDs.Reference
Tests
Opc.Ua.SourceGeneration.Tests: 68 passed on net10.0 and 68 on net48.Opc.Ua.SourceGeneration.Stack.Tests: 90 passed on net10.0 and 87 on net48.preview-pack.slnxand restored it with--disable-parallel.--no-build; package-content checks and two clean net10 consumer builds passed with zero warnings/errors.