Skip to content

Fix source-generator package delivery and preview restore (Roslyn packaging)#4041

Open
marcschier wants to merge 2 commits into
OPCFoundation:masterfrom
marcschier:marcschier/review-fix/source-generator-packaging
Open

Fix source-generator package delivery and preview restore (Roslyn packaging)#4041
marcschier wants to merge 2 commits into
OPCFoundation:masterfrom
marcschier:marcschier/review-fix/source-generator-packaging

Conversation

@marcschier

Copy link
Copy Markdown
Collaborator

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 --configuration option to dotnet restore.

Fix

  • Package each generator and its private runtime closure under
    analyzers/dotnet/cs, excluding Roslyn host assemblies and package dependencies.
  • Preserve Roslyn compile references for project-reference test consumers.
  • Give Debug generator packages .Debug IDs.
  • Validate package contents and clean net10 consumers in both preview pipelines.
  • Remove invalid restore configuration arguments from both preview workflows.

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.
  • Generated preview-pack.slnx and restored it with --disable-parallel.
  • Packed both Release generators with --no-build; package-content checks and two clean net10 consumer builds passed with zero warnings/errors.

…kaging)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@marcschier
marcschier marked this pull request as ready for review July 19, 2026 11:54
Copilot AI review requested due to automatic review settings July 19, 2026 11:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .targets to package generator assemblies + private runtime closure under analyzers/dotnet/cs while suppressing dependencies.
  • Updates generator projects to use .Debug PackageIds 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.

Comment thread tools/Opc.Ua.SourceGeneration/SourceGeneratorPackaging.targets
Comment thread .azurepipelines/validate-source-generator-packages.ps1 Outdated
Comment thread .azurepipelines/validate-source-generator-packages.ps1 Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@marcschier
marcschier marked this pull request as draft July 19, 2026 16:21
@marcschier
marcschier marked this pull request as ready for review July 19, 2026 16:30
@marcschier
marcschier requested a review from romanett July 19, 2026 18:37
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.54%. Comparing base (70c74e7) to head (80de016).
⚠️ Report is 8 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            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     

see 26 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants