Skip to content

Give clearer errors when Microsoft.dotnet-msidentity is not installed - #3799

Open
haileymck wants to merge 1 commit into
mainfrom
dev/hmckelvie/msidentity-error-messages
Open

Give clearer errors when Microsoft.dotnet-msidentity is not installed#3799
haileymck wants to merge 1 commit into
mainfrom
dev/hmckelvie/msidentity-error-messages

Conversation

@haileymck

Copy link
Copy Markdown
Member

Summary

When the Microsoft.dotnet-msidentity tool was missing, Entra ID scaffolding failed with cryptic errors. RegisterAppStep invoked dotnet msidentity directly with no install/detection check, so a missing tool surfaced as a raw dotnet "command not found" error. AddClientSecretStep had its own duplicated install logic but no user-facing guidance on how to fix a failure.

This PR centralizes the detection/install logic and makes every failure path emit clear, actionable guidance.

Changes

  • New Helpers/MsIdentityToolHelper.cs — shared helper exposing:
    • IsMsIdentityInstalled / EnsureMsIdentityIsInstalled (lifted from AddClientSecretStep, now reusable).
    • NotInstalledMessage — a single actionable message telling the user exactly how to install the tool:

      The 'Microsoft.dotnet-msidentity' tool is required for Entra ID scaffolding but is not installed or could not be found. Install it by running 'dotnet tool install --global Microsoft.dotnet-msidentity' (append '--prerelease' when using a prerelease build), then run the scaffolder again.

  • RegisterAppStep.cs — now calls EnsureMsIdentityIsInstalled up front (it previously had no check at all) and appends NotInstalledMessage on register/update CLI failures.
  • AddClientSecretStep.cs — removed the duplicated EnsureMsIdentityIsInstalled/IsMsIdentityAlreadyInstalled methods in favor of the shared helper, and surfaces NotInstalledMessage on CLI failure.

Tests

  • Added MsIdentityToolHelperTests (7 tests) verifying the tool name/command constants and that NotInstalledMessage includes the install command, prerelease guidance, and Entra ID context. All pass.
  • Existing RegisterAppStep/AddClientSecretStep tests still compile and build cleanly.

Notes

The repo pins an SDK (11.0.100-preview.6) that isn't installed on the build machine, so builds/tests were verified against the installed preview.5 via a temporary global.json swap (reverted afterward — global.json is unchanged in this PR).

Extract msidentity install/detection into a shared MsIdentityToolHelper with an actionable NotInstalledMessage, wire RegisterAppStep (which previously had no install check) and AddClientSecretStep to it, and surface the guidance on CLI failures. Add MsIdentityToolHelperTests covering the message and constants.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

1 participant