Skip to content

[release/v7.5] Create github copilot setup workflow#26807

Merged
daxian-dbw merged 1 commit intoPowerShell:release/v7.5from
daxian-dbw:backport/release/v7.5/26285-7ec011163
Feb 13, 2026
Merged

[release/v7.5] Create github copilot setup workflow#26807
daxian-dbw merged 1 commit intoPowerShell:release/v7.5from
daxian-dbw:backport/release/v7.5/26285-7ec011163

Conversation

@daxian-dbw
Copy link
Member

Backport of #26285 to release/v7.5

Triggered by @daxian-dbw on behalf of @TravisEz13

Original CL Label: CL-Tools

/cc @PowerShell/powershell-maintainers

Impact

REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.

Tooling Impact

  • Required tooling change
  • Optional tooling change (include reasoning)

Adds a new GitHub Actions workflow for Copilot setup steps that allows testing and customization of the environment setup. Also adds new bootstrap scenarios (Tools, All) to build.psm1.

Customer Impact

  • Customer reported
  • Found internally

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

This is not a regression.

Testing

The workflow can be tested from the Actions tab using workflow_dispatch. The new bootstrap scenarios were validated as part of the original PR.

Risk

REQUIRED: Check exactly one box.

  • High
  • Medium
  • Low

Only adds new optional tooling workflow and new bootstrap scenarios. Does not modify existing behavior or critical code paths.

@daxian-dbw daxian-dbw requested a review from a team as a code owner February 13, 2026 19:10
@daxian-dbw daxian-dbw added the CL-Tools Indicates that a PR should be marked as a tools change in the Change Log label Feb 13, 2026
Copilot AI review requested due to automatic review settings February 13, 2026 19:10
@daxian-dbw daxian-dbw added the CL-Tools Indicates that a PR should be marked as a tools change in the Change Log label Feb 13, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR backports a Copilot “setup steps” GitHub Actions workflow to release/v7.5 and extends Start-PSBootstrap to support additional bootstrap scenarios intended to prepare the Copilot agent environment.

Changes:

  • Add .github/workflows/copilot-setup-steps.yml to run Copilot pre-agent setup via workflow_dispatch (and on PR edits to the workflow).
  • Extend Start-PSBootstrap -Scenario with Tools and All, and install dotnet-format as a global tool for the Tools scenario.
  • Add helpers to persist PATH/environment variables into GitHub Actions job environment and update Find-Dotnet to use them.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
build.psm1 Adds new bootstrap scenarios, installs .NET global tools, and persists PATH/DOTNET_ROOT to GitHub Actions environment files.
.github/workflows/copilot-setup-steps.yml Introduces a Copilot setup workflow to run bootstrap/tag sync/environment setup steps before the agent starts.


pull_request:
branches:
- master
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

This workflow’s pull_request trigger is restricted to master. Since this file is being backported to release/v7.5, PRs targeting release/** (including this branch) won’t run the workflow to validate changes. Consider adding release/** (matching other CI workflows here) or removing the branch filter so edits are validated on release branches too.

Suggested change
- master
- master
- release/**

Copilot uses AI. Check for mistakes.
Comment on lines +2289 to +2290
# All: Install all dependencies (packaging, .NET SDK, and tools)
[ValidateSet("Package", "DotNet", "Both", "Tools", "All")]
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

Scenario = 'All' is documented as installing packaging + .NET SDK + tools, but several dependency-install branches earlier in Start-PSBootstrap still only check for Both/Package (e.g., OS package deps, WiX on Windows). As-is, All won't actually include all packaging dependencies. Update the other $Scenario -eq 'Both' -or $Scenario -eq 'Package' checks to include All (or switch them to the same -in 'All','Both','Package' pattern used below).

Suggested change
# All: Install all dependencies (packaging, .NET SDK, and tools)
[ValidateSet("Package", "DotNet", "Both", "Tools", "All")]
[ValidateSet("Package", "DotNet", "Both", "Tools")]

Copilot uses AI. Check for mistakes.
Comment on lines +2493 to +2497
# Install dotnet-format
Write-Verbose -Verbose "Installing dotnet-format global tool"
Start-NativeExecution {
dotnet tool install --global dotnet-format
}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The .NET global tools install uses dotnet tool install --global dotnet-format, which is not idempotent (it fails if the tool is already installed). Consider switching to dotnet tool update --global or checking dotnet tool list --global first so Start-PSBootstrap can be safely re-run.

Suggested change
# Install dotnet-format
Write-Verbose -Verbose "Installing dotnet-format global tool"
Start-NativeExecution {
dotnet tool install --global dotnet-format
}
# Ensure dotnet-format is installed as a global tool (idempotent)
Write-Verbose -Verbose "Ensuring dotnet-format global tool is installed"
$dotnetToolListOutput = Start-NativeExecution -IgnoreExitcode {
dotnet tool list --global
}
$dotnetFormatInstalled = $false
if ($LASTEXITCODE -eq 0 -and $dotnetToolListOutput -match '^\s*dotnet-format\b') {
$dotnetFormatInstalled = $true
}
if ($dotnetFormatInstalled) {
Write-Verbose -Verbose "dotnet-format is already installed. Updating global tool."
Start-NativeExecution {
dotnet tool update --global dotnet-format
}
}
else {
Write-Verbose -Verbose "dotnet-format is not installed. Installing global tool."
Start-NativeExecution {
dotnet tool install --global dotnet-format
}
}

Copilot uses AI. Check for mistakes.
Comment on lines +2754 to 2778
Add-PSEnvironmentPath -Path $dotnetPath -Prepend

if ($SetDotnetRoot) {
Write-Verbose -Verbose "Setting DOTNET_ROOT to $dotnetPath"
$env:DOTNET_ROOT = $dotnetPath
Set-PSEnvironmentVariable -Name 'DOTNET_ROOT' -Value $dotnetPath
}
} elseif ($SetDotnetRoot) {
Write-Verbose -Verbose "Expected dotnet version found, setting DOTNET_ROOT to $dotnetPath"
$env:DOTNET_ROOT = $dotnetPath
Set-PSEnvironmentVariable -Name 'DOTNET_ROOT' -Value $dotnetPath
}
}
else {
Write-Warning "Could not find 'dotnet', appending $dotnetPath to PATH."
$env:PATH += [IO.Path]::PathSeparator + $dotnetPath
Add-PSEnvironmentPath -Path $dotnetPath

if ($SetDotnetRoot) {
Write-Verbose -Verbose "Setting DOTNET_ROOT to $dotnetPath"
Set-PSEnvironmentVariable -Name 'DOTNET_ROOT' -Value $dotnetPath
}
}

if (-not (precheck 'dotnet' "Still could not find 'dotnet', restoring PATH.")) {
# Give up, restore original PATH. There is nothing to persist since we didn't make a change.
$env:PATH = $originalPath
}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

Find-Dotnet now persists PATH/DOTNET_ROOT to GitHub Actions via Add-PSEnvironmentPath/Set-PSEnvironmentVariable before the final precheck succeeds. If precheck fails, the code restores only $env:PATH, but any prior writes to $GITHUB_PATH/$GITHUB_ENV (and DOTNET_ROOT in-process) remain, leaving the job environment inconsistent. Persist only after the final precheck passes, or stage changes locally and write to GitHub env files conditionally on success.

Copilot uses AI. Check for mistakes.
Comment on lines +2781 to +2782
# Add .NET global tools to PATH when setting up the environment
$dotnetToolsPath = Join-Path $dotnetPath "tools"
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The global tools PATH being added uses Join-Path $dotnetPath "tools". On Windows, dotnet tool install --global typically installs to $env:USERPROFILE\.dotnet\tools, not under $env:LocalAppData\Microsoft\dotnet\tools, so this may not put global tools on PATH. Consider computing the tools path per-platform (or from DOTNET_CLI_HOME/USERPROFILE) to ensure dotnet-format is discoverable.

Suggested change
# Add .NET global tools to PATH when setting up the environment
$dotnetToolsPath = Join-Path $dotnetPath "tools"
# Compute .NET global tools path based on DOTNET_CLI_HOME/USERPROFILE/HOME
$dotnetCliHome = if (-not [string]::IsNullOrWhiteSpace($env:DOTNET_CLI_HOME)) {
$env:DOTNET_CLI_HOME
}
elseif ($environment.IsWindows) {
$env:USERPROFILE
}
else {
$env:HOME
}
$dotnetToolsRoot = Join-Path $dotnetCliHome ".dotnet"
$dotnetToolsPath = Join-Path $dotnetToolsRoot "tools"

Copilot uses AI. Check for mistakes.
@daxian-dbw daxian-dbw merged commit 6b2a15e into PowerShell:release/v7.5 Feb 13, 2026
34 of 36 checks passed
@daxian-dbw daxian-dbw deleted the backport/release/v7.5/26285-7ec011163 branch February 13, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Tools Indicates that a PR should be marked as a tools change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants