Skip to content

Add multi-version .NET Copilot workflow with deterministic package restoration#8

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/create-multi-version-dotnet-workflow
Draft

Add multi-version .NET Copilot workflow with deterministic package restoration#8
Copilot wants to merge 3 commits intomasterfrom
copilot/create-multi-version-dotnet-workflow

Conversation

Copy link

Copilot AI commented Dec 12, 2025

Creates GitHub Actions workflow for Copilot environment setup with .NET 6.0.428, 8.0.416, and 10.0.101 SDKs.

Workflow Configuration

  • Job name: copilot-setup-steps (required for Copilot recognition)
  • Multi-version setup: Single step installs all three SDK versions using pipe-delimited syntax
  • NuGet caching: Enabled with cache-dependency-path: '**/packages.lock.json'
  • Permissions: contents: read only
  • Triggers: workflow_dispatch, push/pull_request on workflow file changes

Deterministic Builds

Enables package lock files across all projects:

  • Added <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile> to 3 project files
  • Generated and committed packages.lock.json for each project
  • Workflow uses dotnet restore --locked-mode to enforce exact package versions

Environment Setup

- name: Setup .NET SDKs (6.0, 8.0, 10.0)
  uses: actions/setup-dotnet@v4
  with:
    dotnet-version: |
      6.0.428
      8.0.416
      10.0.101
    cache: true
    cache-dependency-path: '**/packages.lock.json'

Note: dotnet format is built into .NET SDK 6+ - no separate tool installation required.

Original prompt

This section details on the original issue you should resolve

<issue_title>Create Multi-Version .NET Setup Copilot Workflow</issue_title>
<issue_description># Create Multi-Version .NET Setup Copilot Workflow

Objective

Create a GitHub Actions workflow file that sets up a multi-version .NET environment for GitHub Copilot to work with .NET 6, 8, and 10 projects using best practices for security, performance, and maintainability.

Role

You are a DevOps engineer specializing in GitHub Actions and .NET CI/CD pipelines. Your task is to create a workflow that properly configures multiple .NET SDK versions following documented best practices.

Context

The workflow needs to be named copilot-setup-steps.yml and placed in .github/workflows/. It will automatically run when changed to validate the setup, and can be manually triggered through the Actions tab. The job must be named copilot-setup-steps to be recognized by Copilot. Docs: https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/customize-the-agent-environment

Requirements

  • Create a GitHub Actions workflow that sets up .NET 6.0, 8.0, and 10.0 SDKs in a single step using multi-version syntax
  • Use specific version numbers for reproducibility (not wildcards)
  • Include NuGet package caching with lock files for performance
  • Add .NET environment variables setup
  • Install dotnet-format tool for code formatting
  • Use minimum required permissions for security
  • Add proper validation and build steps
  • Enable package lock files for deterministic restores

Instructions

  • If ./gitub/workflows/copilot-setup-steps.yml already exists, do not continue.
    Create a workflow file with the following structure:
  • Name: "Copilot Setup Steps for Multi-Version .NET"
  • Triggers: workflow_dispatch, push, and pull_request on the workflow file path
  • Job name: copilot-setup-steps
  • Runner: ubuntu-latest
  • Permissions: contents: read (minimum required)
  • Steps: checkout with full history, setup .NET SDKs (multi-version with caching), restore dependencies with --locked-mode, install dotnet-format, set environment variables, build validation

Project File Updates Required

For the caching to work correctly, each .NET project file (.csproj or .fsproj) must include:

<PropertyGroup>
    <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

And commit the generated packages.lock.json files to source control.

Expected Output

The workflow should create a .github/workflows/copilot-setup-steps.yml file that:

  1. Sets up all three .NET SDK versions in a single step using proper multi-version syntax
  2. Uses specific version numbers (e.g., 6.0.428, 8.0.416, 10.0.101)
  3. Includes NuGet package caching with lock files and cache-dependency-path for performance optimization
  4. Installs dotnet-format tool globally
  5. Sets up .NET environment variables (DOTNET_ROOT, DOTNET_CLI_TELEMETRY_OPTOUT)
  6. Includes build validation to ensure setup works correctly
  7. Uses proper GitHub Actions syntax with comments explaining each section
  8. Follows security best practices with minimal permissions
  9. Uses --locked-mode for dotnet restore to ensure exact package versions

Acceptance Criteria

  • If an existing ./gitub/workflows/copilot-setup-steps.yml exists, it is left untouched and no other files are changed
  • Workflow file is properly formatted YAML
  • All three .NET versions are configured in a single setup step using multi-version syntax
  • Specific version numbers are used (not wildcards)
  • NuGet caching is implemented with cache: true and cache-dependency-path: "**/packages.lock.json"
  • dotnet-format tool installation step is included
  • Environment variables for .NET are configured
  • Build validation step is included to verify setup
  • Job is named copilot-setup-steps
  • Workflow triggers on appropriate events
  • Permissions are set to minimum required (contents: read)
  • Comments explain each section and security considerations
  • Follows best practices for reproducibility and performance
  • Uses --locked-mode for dotnet restore to ensure deterministic package versions
    </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 12, 2025 13:29
Co-authored-by: dburriss <5071495+dburriss@users.noreply.github.com>
Co-authored-by: dburriss <5071495+dburriss@users.noreply.github.com>
Copilot AI changed the title [WIP] Create multi-version .NET setup Copilot workflow Add multi-version .NET Copilot workflow with deterministic package restoration Dec 12, 2025
Copilot AI requested a review from dburriss December 12, 2025 13:36
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.

Create Multi-Version .NET Setup Copilot Workflow

2 participants