Skip to content

Add searched .NET install locations to error message #117796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 21, 2025

Conversation

elinor-fung
Copy link
Member

Include searched locations in error message when host cannot find a .NET install (hostfxr)

Example - the 'following locations were searched' section is new:

You must install .NET to run this application.

App: /home/elinor/helloworld/bin/Debug/net10.0/helloworld
Architecture: x64
App host version: 10.0.0-dev
.NET location: Not found

The following locations were searched:
  Application directory:
    /home/elinor/helloworld/bin/Debug/net10.0/
  Environment variable:
    DOTNET_ROOT_X64 = <not set>
    DOTNET_ROOT = <not set>
  Registered location:
    /etc/dotnet/install_location_x64 = <not set>
  Default location:
    /usr/share/dotnet

Learn more:
https://aka.ms/dotnet/app-launch-failed

Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=linux-x64&os=ubuntu.22.04&apphost_version=10.0.0-dev

Resolves #116108

cc @dotnet/appmodel @AaronRobinsonMSFT

@Copilot Copilot AI review requested due to automatic review settings July 17, 2025 23:53
@elinor-fung elinor-fung added this to the 10.0.0 milestone Jul 17, 2025
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 enhances the error messaging when the .NET host cannot find a .NET installation by adding detailed information about which locations were searched during the discovery process.

Key changes:

  • Modified get_dotnet_root_from_env to clear the environment variable name when no valid path is found
  • Enhanced error message generation in fxr_resolver.cpp to include a comprehensive list of searched locations
  • Added a new test case to verify the improved error message format

Reviewed Changes

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

Show a summary per file
File Description
src/native/corehost/hostmisc/utils.cpp Modified to clear environment variable name when dotnet root is not found
src/native/corehost/fxr_resolver.cpp Enhanced error message generation with detailed search location information
src/native/corehost/corehost.cpp Removed redundant error logging since detailed error is now handled elsewhere
src/native/corehost/apphost/standalone/hostfxr_resolver.cpp Added error message for non-fully-qualified hostfxr paths
src/installer/tests/HostActivation.Tests/InstallLocation.cs Added test case to verify new error message format
Comments suppressed due to low confidence (1)

src/native/corehost/fxr_resolver.cpp:162

  • [nitpick] The variable name 'searched_locations' could be more descriptive. Consider renaming it to 'search_details_message' or 'location_search_summary' to better indicate it's building an error message.
    pal::string_t searched_locations = _X("The following locations were searched:");

Copy link
Contributor

Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT left a comment

Choose a reason for hiding this comment

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

Minor style nit.

@elinor-fung
Copy link
Member Author

/ba-g #117811 and timeout in leg unaffected by this change (libraries tests linux_musl)

@elinor-fung elinor-fung merged commit e768358 into dotnet:main Jul 21, 2025
145 of 151 checks passed
@elinor-fung elinor-fung deleted the host-error-searchedLocations branch July 21, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include searched locations in error message when host cannot find a .NET install
3 participants