Skip to content

ci(http-client-csharp): parallelize generation, cache NuGet packages, remove redundant builds - #12754

Open
Alan Zimmer (alzimmermsft) wants to merge 2 commits into
microsoft:mainfrom
alzimmermsft:alzimmermsft-csharp-ci-build-improvements
Open

Alan Zimmer (alzimmermsft) wants to merge 2 commits into
microsoft:mainfrom
alzimmermsft:alzimmermsft-csharp-ci-build-improvements

Conversation

@alzimmermsft

@alzimmermsft Alan Zimmer (alzimmermsft) commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Brings CI improvements similar to #12752 (Java) to the C# emitter. Changes are scoped to packages/http-client-csharp; shared emitter pipeline templates are untouched.

Changes

  • NuGet cache (eng/pipeline/templates/ci-stages.yml): sets NUGET_PACKAGES and adds a Cache@2 step keyed on OS + eng/nuget.config + Packages.Data.props + Directory.Build.targets + *.csproj. Also sets DOTNET_NOLOGO, DOTNET_CLI_TELEMETRY_OPTOUT, DOTNET_SKIP_FIRST_TIME_EXPERIENCE.
  • Parallel generation (Generation.psm1): new Get-SpecGenerationCommands / Invoke-ParallelGeneration helpers. Parallelism defaults to processor count, override with CSHARP_GENERATION_PARALLELISM. Output is only printed in full for failed specs. Existing Generate-Versioning / Generate-Srv-Driven remain for Test-Spector.ps1.
  • Generate.ps1 (RegenCheck): Sample-TypeSpec and Spector specs generate in parallel. -LaunchOnly no longer generates versioning/srv-driven specs.
  • Get-Spector-Coverage.ps1: new -SkipBuild switch; parallel generation; one parallel build of a temporary .slnx replaces the serial per-project builds; dotnet test --no-build.
  • CI scope: Spector coverage runs only in the primary-Node Linux test job (the one that uploads coverage), selected through CSHARP_RUN_SPECTOR_COVERAGE; Windows and secondary-Node jobs skip it. Only .NET 10 is installed. CI passes -GenerationParallelism = 2x processor count; local default parallelism is unchanged.
  • Nested specs: generation jobs whose output directories are nested (http/type/union and .../discriminated/extends) are merged and run sequentially, outer folder first, because generation deletes project files under its output directory.
  • Test-Packages.ps1: unit tests use dotnet test --no-build after npm run build; coverage runs with -SkipBuild; GenerationChecks drops a redundant npm run build (Generate.ps1 builds what it needs).

Local validation (16 cores, Windows)

  • Generate.ps1 (full): ~6.8 min, no git diff (previously ~33 min serially).
  • Get-Spector-Coverage.ps1 -SkipBuild (full): 11.2 min; 971 passed, 10 skipped (previously estimated 45+ min).
  • npm run cop passes.

Notes / follow-ups

  • The Spector test run itself is ~24s and reuses a single server, so NUnit parallelization isn't worthwhile.

… remove redundant builds

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 4, 2026 21:54
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Dec 4, 2026
@pkg-pr-new

pkg-pr-new Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-csharp@12754

commit: fb8feaa

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

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.

🟡 Changes recommended

Parallel generation can silently delete child project files, and coverage collects project paths before regeneration, potentially validating stale or incomplete output.

2 open issues
What changed in this PR

Speeds up C# emitter CI through caching, parallel generation, and fewer redundant builds, without changing shared pipeline templates.

Changes:

  • Adds NuGet caching and .NET CLI environment settings.
  • Runs generation concurrently with configurable parallelism.
  • Consolidates Spector builds and reuses existing build outputs for tests.
File Description
packages/​http-client-csharp/​eng/​scripts/​Test-Packages.ps1 Removes redundant builds and enables build reuse.
packages/​http-client-csharp/​eng/​scripts/​Get-Spector-Coverage.ps1 Parallelizes generation and consolidates project builds.
packages/​http-client-csharp/​eng/​scripts/​Generation.psm1 Adds command collection and parallel execution helpers.
packages/​http-client-csharp/​eng/​scripts/​Generate.ps1 Queues generation jobs and skips generation in launch-only mode.
packages/​http-client-csharp/​eng/​pipeline/​templates/​ci-stages.yml Configures NuGet caching and .NET CLI settings.

Review effort: Balanced

…age once, install only .NET 10

- Merge generation jobs with nested output directories so parent and child specs run sequentially
- Collect Spector projects after generation
- Run Spector coverage only in the primary Linux test job
- Pass 2x processor count generation parallelism on CI
- Install only .NET 10 and avoid the cspell failure

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 4, 2026 23:12

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.

🟢 Approval recommended

No active review issues are reported for the C# emitter CI optimizations.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

This branch has not been deployed

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

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants