Skip to content

pwsh via dotnet tool#4134

Open
mdaigle wants to merge 9 commits intomainfrom
dev/mdaigle/pwsh-via-dotnet-tool
Open

pwsh via dotnet tool#4134
mdaigle wants to merge 9 commits intomainfrom
dev/mdaigle/pwsh-via-dotnet-tool

Conversation

@mdaigle
Copy link
Copy Markdown
Contributor

@mdaigle mdaigle commented Apr 2, 2026

This pull request improves the consistency and reliability of using PowerShell scripts and .NET CLI tools across the build and test pipelines. It standardizes the way the pwsh command is invoked by leveraging a restored .NET tool, and ensures all required CLI tools are restored before builds or tests run. It also simplifies the MSBuild targets by removing redundant tool restore steps.

Passing non-official build: https://sqlclientdrivers.visualstudio.com/ADO.Net/_build/results?buildId=145950&view=results

Copilot AI review requested due to automatic review settings April 2, 2026 21:18
@github-project-automation github-project-automation bot moved this to To triage in SqlClient Board Apr 2, 2026
Copy link
Copy Markdown
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 switches IntelliSense XML doc trimming to use pwsh via a .NET CLI tool (from dotnet-tools.json) and updates CI/OneBranch pipelines to restore tool manifests before builds that depend on them.

Changes:

  • Add powershell (pwsh) to the repo’s dotnet-tools.json tool manifest.
  • Update doc-trimming MSBuild logic to invoke pwsh via dotnet tool run.
  • Add a reusable pipeline step to run dotnet tool restore, and invoke it from key CI/OneBranch job templates.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools/targets/TrimDocsForIntelliSense.targets Switches trimming Exec to dotnet tool run pwsh.
tools/targets/CompareMdsRefAssemblies.targets Removes _RestoreTools target (currently leaving dangling dependencies).
src/Microsoft.Data.SqlClient/ref/Microsoft.Data.SqlClient.csproj Updates TrimDocs target to use dotnet tool run pwsh and adds a dependency (currently incorrect).
eng/pipelines/steps/tool-restore.yml New pipeline step template to restore dotnet tools.
eng/pipelines/onebranch/steps/build-all-configurations-signed-dlls-step.yml Invokes tool restore before building.
eng/pipelines/onebranch/jobs/build-signed-sqlclient-package-job.yml Invokes tool restore before building.
eng/pipelines/onebranch/jobs/build-signed-csproj-package-job.yml Invokes tool restore before building.
eng/pipelines/common/templates/jobs/ci-run-tests-job.yml Invokes tool restore after SDK install.
eng/pipelines/common/templates/jobs/ci-build-nugets-job.yml Invokes tool restore after SDK install.
dotnet-tools.json Adds the powershell tool entry exposing pwsh.
Comments suppressed due to low confidence (1)

tools/targets/CompareMdsRefAssemblies.targets:118

  • The _RestoreTools target was removed, but _RunRefApiCompat still depends on _RestoreTools later in this file. As-is, invoking CompareMdsRefAssemblies will fail with a missing target error. Either reintroduce _RestoreTools (to run dotnet tool restore) or update _RunRefApiCompat.DependsOnTargets to reference the new tool-restore mechanism (and ensure it exists for non-pipeline/manual invocations too).

  <!-- ================================================================== -->
  <!-- _BuildLegacyRefNetFx                                               -->
  <!-- ================================================================== -->
  <Target Name="_BuildLegacyRefNetFx" DependsOnTargets="_SetApiCompatProperties" Condition="'$(IsEnabledWindows)' == 'true'">

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.51%. Comparing base (60d4b92) to head (a3d2516).
⚠️ Report is 16 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (60d4b92) and HEAD (a3d2516). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (60d4b92) HEAD (a3d2516)
CI-SqlClient 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4134      +/-   ##
==========================================
- Coverage   73.22%   66.51%   -6.71%     
==========================================
  Files         280      274       -6     
  Lines       43000    65782   +22782     
==========================================
+ Hits        31486    43755   +12269     
- Misses      11514    22027   +10513     
Flag Coverage Δ
CI-SqlClient ?
PR-SqlClient-Project 66.51% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@mdaigle mdaigle changed the title Dev/mdaigle/pwsh via dotnet tool pwsh via dotnet tool Apr 2, 2026
Copilot AI review requested due to automatic review settings April 2, 2026 22:40
@mdaigle mdaigle added this to the 7.1.0-preview1 milestone Apr 2, 2026
@mdaigle mdaigle added the Hotfix 7.0.1 When this PR merges, automatically open a PR to cherry-pick to the 7.0.1 branch label Apr 2, 2026
Copy link
Copy Markdown
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

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

@mdaigle mdaigle marked this pull request as ready for review April 3, 2026 18:25
@mdaigle mdaigle requested a review from a team as a code owner April 3, 2026 18:25
Copilot AI review requested due to automatic review settings April 3, 2026 18:46
Copy link
Copy Markdown
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

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

<PowerShellCommand Condition="'$(OS)' != 'Windows_NT'">pwsh</PowerShellCommand>
<PowerShellCommand>
$(PowerShellCommand)
dotnet pwsh
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

dotnet pwsh depends on the PowerShell tool being runnable as a dotnet subcommand (i.e., resolved as dotnet-pwsh). If the powershell tool only installs a pwsh shim, this invocation won’t work even after restore. Using dotnet tool run pwsh -- ... is more resilient and still keeps the invocation bound to the restored local tool.

Suggested change
dotnet pwsh
dotnet tool run pwsh --

Copilot uses AI. Check for mistakes.
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.

I think this is fine since we're explicitly installing the dotnet pwsh tool.

- **Visual Studio 2019** with imported components: [VS19Components](/tools/vsconfig/VS19Components.vsconfig)

- **Powershell**: To build SqlClient on Linux, powershell is needed as well. Follow the distro specific instructions at [Install Powershell on Linux](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-linux?view=powershell-7.4)
- **Powershell**: PowerShell is included as a .NET local tool in this repository. Running `dotnet tool restore` (see below) will make it available. No separate installation is required.
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

Typo/casing: use “PowerShell” (official product name) instead of “Powershell” in this prerequisite bullet for consistency with the rest of the document.

Suggested change
- **Powershell**: PowerShell is included as a .NET local tool in this repository. Running `dotnet tool restore` (see below) will make it available. No separate installation is required.
- **PowerShell**: PowerShell is included as a .NET local tool in this repository. Running `dotnet tool restore` (see below) will make it available. No separate installation is required.

Copilot uses AI. Check for mistakes.
@paulmedynski paulmedynski added Hotfix 7.0.2 PRs targeting main whose changes should be backported to release/7.0 for the 7.0.2 release. and removed Hotfix 7.0.1 When this PR merges, automatically open a PR to cherry-pick to the 7.0.1 branch labels Apr 6, 2026
@paulmedynski paulmedynski self-assigned this Apr 6, 2026
@paulmedynski paulmedynski moved this from To triage to In review in SqlClient Board Apr 6, 2026
- template: /eng/pipelines/steps/install-dotnet.yml@self

# Restore dotnet CLI tools (e.g. pwsh, apicompat) before building.
- template: /eng/pipelines/steps/dotnet-tool-restore.yml@self
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.

nit: Most of our other template files use verb-noun names, so maybe this file should be restore-dotnet-tools.yml. Not worth changing unless there are other things to fix.

<PowerShellCommand Condition="'$(OS)' != 'Windows_NT'">pwsh</PowerShellCommand>
<PowerShellCommand>
$(PowerShellCommand)
dotnet pwsh
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.

I think this is fine since we're explicitly installing the dotnet pwsh tool.

<PowerShellCommand Condition="'$(OS)' != 'Windows_NT'">pwsh</PowerShellCommand>
<PowerShellCommand>
$(PowerShellCommand)
dotnet pwsh
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.

For dotnet commands, our entry point to them has been build(2).proj, and in those files, we have a way to override the path to dotnet. With this change, the path to dotnet can't be overridden. Whether that's acceptable or not is up for discussion, but we already have pipeline mechanisms that use the dotnet override for x86 behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see what you mean, but this step isn't architecture sensitive. Whatever dotnet version is on the path works just fine.

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

Labels

Hotfix 7.0.2 PRs targeting main whose changes should be backported to release/7.0 for the 7.0.2 release.

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

4 participants