Skip to content

C#: Resolve the hostfxr path using dotnet CLI #96146

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

Conversation

raulsntos
Copy link
Member

Instead of trying to get the location of the dotnet CLI from PATH (which is unavailable in some platforms that don't allow reading environment variables), we execute the dotnet CLI to list the available SDKs and find the hostfxr location that way.

@raulsntos raulsntos added this to the 4.4 milestone Aug 27, 2024
@raulsntos raulsntos requested a review from a team as a code owner August 27, 2024 05:21
@bruvzg
Copy link
Member

bruvzg commented Aug 27, 2024

Supersedes #74221

This will do nothing on macOS (unless running for terminal, or with #81266), bundled macOS app will never have dotnet in PATH.

Edit: Updated and retested #74221, might be not the cleanest option, but should work.

@raulsntos
Copy link
Member Author

I would prefer this PR with #81266 to avoid hardcoding non-standard hostfxr locations.

@akien-mga
Copy link
Member

#81266 was merged, so this could now be rebased / retested and should be mergeable.

Instead of trying to get the location of the dotnet CLI from PATH (which is unavailable in some platforms that don't allow reading environment variables), we execute the dotnet CLI to list the available SDKs and find the hostfxr location that way.
@raulsntos raulsntos force-pushed the dotnet/resolve-hostfxr-path-from-command-line branch from 4b660a4 to 5a2c033 Compare June 9, 2025 04:35
@akien-mga akien-mga modified the milestones: 4.x, 4.5 Jun 9, 2025
Comment on lines +131 to +132
String version_string = sdk.get_slice(" ", 0);
String path = sdk.get_slice(" ", 1);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
String version_string = sdk.get_slice(" ", 0);
String path = sdk.get_slice(" ", 1);
String version_string = sdk.get_slicec(' ', 0);
String path = sdk.get_slicec(' ', 1);

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I didn't get a chance to make the change before the PR got merged.

@Repiteo Repiteo merged commit 0cd7bb5 into godotengine:master Jun 9, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Jun 9, 2025

Thanks!

@raulsntos raulsntos deleted the dotnet/resolve-hostfxr-path-from-command-line branch June 28, 2025 17:43
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.

"Unable to load .NET runtime, specifically hostfxr" due to Godot not seeing manually installed .NET SDK
5 participants