Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Microsoft Autogen Dotnet Build Workflow

From Leeroopedia
Knowledge Sources
Domains CI_CD, Build_Automation, Testing, DotNet
Last Updated 2026-02-11 17:00 GMT

Overview

A comprehensive GitHub Actions workflow for building, testing, and publishing .NET packages in the AutoGen repository.

Description

This workflow implements continuous integration and delivery for the .NET components of AutoGen. It includes a paths filter to skip unnecessary builds, runs format checks and unit tests on Ubuntu and macOS, executes integration tests with .NET Aspire workload, performs AOT (Ahead-of-Time) compilation compatibility tests, runs OpenAI integration tests on the main branch, and publishes nightly builds to multiple package feeds (Azure DevOps, GitHub Packages, MyGet). The workflow uses both .NET 8.0 and 9.0 SDKs and coordinates with Python environment setup for cross-platform testing.

Usage

This workflow is triggered by:

  • Manual workflow dispatch
  • Pull requests to main or staging branches
  • Push events to main or staging branches
  • Merge group check requests

It validates .NET code quality and functionality before merging, and automatically publishes packages when running on the main branch after all tests pass.

Code Reference

Source Location

Signature

name: dotnet-ci
on:
  workflow_dispatch:
  pull_request:
    branches: ["main", "staging"]
  push:
    branches: ["main", "staging"]
  merge_group:
    types: [checks_requested]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
  cancel-in-progress: ${{ github.ref != 'refs/heads/main' || github.ref != 'refs/heads/dotnet' }}

permissions:
  contents: read
  packages: write

jobs:
  paths-filter: # Detect dotnet/proto changes
  build: # Build and test on Ubuntu/macOS
  integration-test: # Integration tests with Aspire
  aot-test: # AOT compatibility validation
  openai-test: # OpenAI integration tests (main only)
  publish: # Publish to package feeds (main only)

Import

# Triggered by: Push, PR, workflow_dispatch, or merge_group events
# Uses: dorny/paths-filter@v2 for change detection
# Uses: astral-sh/setup-uv@v5 for Python environment
# Uses: actions/setup-dotnet@v4 for .NET 8.0 and 9.0
# Uses: codecov/codecov-action@v5 for coverage reporting

I/O Contract

Inputs

Name Type Required Description
github.ref string Yes Branch reference for triggering workflow
github.workspace string Yes Workspace directory path
secrets.CODECOV_TOKEN string Yes Token for Codecov upload
secrets.AZURE_DEVOPS_TOKEN string Conditional Token for Azure DevOps feed (main branch only)
secrets.MYGET_TOKEN string Conditional Token for MyGet feed (main branch only)
secrets.GITHUB_TOKEN string Conditional Token for GitHub Packages (main branch only)
secrets.AZURE_OPENAI_API_KEY string Conditional Azure OpenAI key for integration tests (main only)
secrets.AZURE_OPENAI_ENDPOINT string Conditional Azure OpenAI endpoint (main only)
secrets.AZURE_GPT_35_MODEL_ID string Conditional Model ID for testing (main only)
secrets.OPENAI_API_KEY string Conditional OpenAI API key (main only)

Outputs

Name Type Description
Test Results Status Pass/fail status for all test jobs
Coverage Report Artifact Code coverage reports in Cobertura and HTML formats
Nightly Packages Artifact .nupkg files with nightly version suffix
Release Packages Artifact .nupkg files with release version
Published Packages Status Confirmation of package publication to feeds

Usage Examples

Automatic Build on Pull Request

# Create PR to trigger build and test:
gh pr create --base main --head feature-branch
# Runs paths-filter, build, integration-test, and aot-test jobs
# Skips openai-test and publish jobs (main branch only)

Automatic Build and Publish on Main

# Push to main triggers full pipeline:
git push origin main
# Runs all jobs including OpenAI tests and package publishing

Manual Workflow Dispatch

# Manually trigger workflow:
gh workflow run dotnet-build.yml --ref main

# View workflow runs:
gh run list --workflow=dotnet-build.yml

# Download build artifacts:
gh run download <run-id> --name nightly
gh run download <run-id> --name CodeCoverageReport

Running Tests Locally

cd dotnet

# Format check:
dotnet format --verify-no-changes -v diag

# Build:
dotnet build --configuration Release /p:SignAssembly=true

# Run unit tests:
dotnet test --configuration Release --filter "Category=UnitV2"

# Run integration tests:
dotnet test --configuration Release --filter "Category=Integration"

# Run gRPC tests:
dotnet dev-certs https --trust
dotnet test --configuration Release --filter "Category=GRPC"

Job Details

paths-filter Job

Uses dorny/paths-filter to detect changes in dotnet/** or protos/** directories. Subsequent jobs only run if hasChanges=true, avoiding unnecessary builds when only Python or documentation files change.

build Job

Matrix job running on Ubuntu and macOS with Python 3.11. Steps include:

  • Set up Python environment with UV
  • Install .NET 8.0 and 9.0 SDKs
  • Restore dependencies with binary logging
  • Format verification (fails if code needs formatting)
  • Build with assembly signing enabled
  • UnitV1 tests (older test suite)
  • UnitV2 tests with code coverage collection
  • GRPC tests with dev certificates (Ubuntu only)
  • Coverage report generation using reportgenerator tool
  • Coverage upload to Codecov

integration-test Job

Runs on Ubuntu with .NET 8.0 and 9.0. Installs .NET Aspire workload (requires temporary global.json override to .NET 9.0), installs dev certificates, and runs tests marked with Category=Integration filter.

aot-test Job

Tests AOT (Ahead-of-Time) compilation compatibility to ensure AutoGen.Core works with native AOT scenarios. Uses PowerShell script .tools/test-aot-compatibility.ps1 to publish an AOT test app, validate static analysis warnings, and run the compiled application.

openai-test Job

Only runs on main branch after aot-test succeeds. Sets up Python with Jupyter and ipykernel for notebook testing, builds the project, runs OpenAI integration tests using secrets for API access, creates nightly packages (with version suffix nightly-$Template:Github.run id), and creates release packages without suffix.

publish Job

Only runs on main branch after openai-test succeeds. Downloads nightly and release artifacts and publishes to three feeds:

  • Azure DevOps internal feed (continues on error)
  • GitHub Packages (continues on error)
  • MyGet agentchat feed (continues on error)

Uses --skip-duplicate flag to prevent errors when re-publishing the same version.

Test Categories

The workflow uses test filters to organize test execution:

  • UnitV1 - Legacy unit tests
  • UnitV2 - Current unit tests with coverage
  • GRPC - gRPC communication tests (requires dev certificates)
  • Integration - Integration tests (requires .NET Aspire)
  • type!=integration - All non-integration tests for OpenAI job

Package Publishing Strategy

Versioning

  • Nightly builds: Use version suffix format nightly-$Template:Github.run id
  • Release builds: Use version from project files without suffix

Feeds

  • Azure DevOps: Internal Microsoft feed for development
  • GitHub Packages: Public feed at nuget.pkg.github.com/microsoft
  • MyGet: Public feed at myget.org/F/agentchat for community access

All publishing steps use continue-on-error: true to ensure partial failures don't block the entire workflow.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment