Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 23, 2025

This change mirrors aspnetcore PR 62619 by adding two new properties to the sdk section of global.json:

  • paths: [ ".dotnet", "$host$" ] - Instructs the .NET CLI to probe the repository-local .dotnet directory before falling back to host locations, enabling automatic use of the pinned local SDK without requiring manual PATH modifications.

  • errorMessage: Provides clear guidance to developers when the SDK is missing, directing them to run the appropriate restore script (./restore.sh for Linux/macOS or ./restore.cmd for Windows).

Benefits

  1. Improved Developer Experience: Developers no longer need to manually configure their PATH or DOTNET_ROOT to use the pinned SDK version.
  2. Automatic SDK Resolution: The .NET CLI will automatically find and use the local SDK installation in the .dotnet directory.
  3. Better Error Messaging: When the local SDK is missing, developers get actionable guidance instead of generic error messages.
  4. Consistency: Aligns with the same approach being used in the aspnetcore repository.

Changes

The modification is minimal and surgical - only two properties were added to the existing sdk section:

 "sdk": {
   "version": "10.0.100-preview.5.25277.114",
   "rollForward": "major",
-  "allowPrerelease": true
+  "allowPrerelease": true,
+  "paths": [ ".dotnet", "$host$" ],
+  "errorMessage": "The .NET SDK could not be found. Run ./restore.sh (Linux/macOS) or ./restore.cmd (Windows) to install the local SDK."
 },

All other sections (tools, runtimes, msbuild-sdks) remain completely unchanged, and the existing SDK version and configuration are preserved.

Verification

  • ✅ Build system continues to work with the pinned SDK version
  • ✅ Local .dotnet directory is correctly prioritized for SDK resolution
  • ✅ Fallback to host SDK works when local SDK is unavailable
  • ✅ JSON syntax is valid
  • ✅ No impact on existing tools, runtimes, or MSBuild SDK configurations

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Add sdk paths and errorMessage to global.json Add sdk.paths and sdk.errorMessage to global.json Aug 23, 2025
@Copilot Copilot AI requested a review from davidfowl August 23, 2025 05:28
Copilot finished work on behalf of davidfowl August 23, 2025 05:28
@davidfowl davidfowl marked this pull request as ready for review August 23, 2025 05:29
@Copilot Copilot AI review requested due to automatic review settings August 23, 2025 05:29
Copy link
Contributor

@Copilot 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 adds two new properties to the sdk section of global.json to improve developer experience and SDK resolution. The change enables automatic discovery of the repository-local .NET SDK installation and provides clear error messaging when the SDK is missing.

  • Adds paths property to prioritize local .dotnet directory for SDK resolution
  • Adds errorMessage property to guide developers when the SDK is not found
  • Maintains all existing SDK configuration and version settings

@davidfowl
Copy link
Member

cc @baronfel @JakeRadMSFT

@davidfowl davidfowl requested a review from JamesNK August 24, 2025 04:51
Copy link
Member

@mitchdenny mitchdenny left a comment

Choose a reason for hiding this comment

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

Looks good. Did an extra check on codespaces.

@davidfowl davidfowl merged commit 341ecf3 into main Aug 25, 2025
579 of 583 checks passed
@davidfowl davidfowl deleted the copilot/fix-4a84f61c-6d80-41bb-8d9a-1a71a1b63b7a branch August 25, 2025 14:26
@dotnet-policy-service dotnet-policy-service bot added this to the 9.5 milestone Aug 25, 2025
@baronfel
Copy link
Member

I was gonna suggest pumping the brakes a little bit on this - there's a open tooling issue that we're trying to work on at the IDE/tooling layers when local SDKs are used. But that problem mostly arises when building apps that target a runtime that isn't available outside of the 'local' SDK root. Since Aspire is still targeting the 8 TFM you should mostly sidestep the issue.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants