Skip to content
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

Hostfxr Installation Location Path Key May Diverge from Specification #109974

Closed
nagilson opened this issue Nov 19, 2024 · 3 comments
Closed

Hostfxr Installation Location Path Key May Diverge from Specification #109974

nagilson opened this issue Nov 19, 2024 · 3 comments
Labels
area-Host documentation Documentation bug or enhancement, does not impact product or test code question Answer questions and provide assistance, not an issue with source code or documentation.

Comments

@nagilson
Copy link
Member

nagilson commented Nov 19, 2024

Description

sharedhost has Path but InstallLocation does not, and does not exist

My understanding based on this spec is that the registry should contain a path key to the dotnet host. I looked at my registry to see if that was valid. I was able to find a Path key under a location very similar to what the spec stated, but it was in sharedhost, which seems to be inconsistent with the design decision determined in https://github.com/dotnet/designs/blob/main/accepted/2021/install-location-per-architecture.md#:~:text=On%20Windows%20the,arch%3E%5CInstallLocation, where InstallLocation is mentioned as the place in which the install location is stored.

On Windows the multi-arch situation already exists with x86 and x64 architectures. Each installs into a different location and is registered accordingly. The registration mechanism in registry includes the architecture, the key path is HKLM\SOFTWARE\dotnet\Setup\InstalledVersions<arch>\InstallLocation.

On my machine, this is stored in sharedhost, not InstallLocation. My machine is Win 11 and x64.
Image

<RegKeyProductName>sharedhost</RegKeyProductName>

That seems to be what the code does as well. I didn't see any reference to InstallLocation as mentioned in the doc. I also didnt see a new doc describing this sharedhost behavior. Is that expected? Or, Is this design / spec wrong and needs to be updated? Or am I confused and this Path key is for something else, and there never was a place where the path to .NET is marked in the registry?

WoW Node Missing Path Key

There is also information that can be put in the Wow Node. For this information, it doesn't appear to have a Path key? Is that expected?

Image

Registry Inconsistency with --info

Here's another interesting observation. My 9.0.0-preview.7.24405.7 host running dotnet --info says there is an x86 dotnet registered at InstallLocation, but that doesn't exist on my registry. It's got a sharedhost key, though. The registry above shows hostfxr under the InstalledVersions node and some other installation information which is good, but none of those seem to store the path. Is InstalledVersions a placeholder text, then, and substitutable for hostfxr, sharedhost, etc?
Image

cc @elinor-fung @richlander

Reproduction Steps

Install .NET 9 or .NET 8 preview host on various machines and observe regedit behavior can be different. Install the .NET 9 host and see sharedhost is used instead of InstallLocation.

Expected behavior

Should it not be in InstallLocation?

Actual behavior

See above.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Nov 19, 2024
Copy link
Contributor

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

@nagilson nagilson changed the title Inconsistent Hostfxr Installation Location Hostfxr Installation Location Path Key Nov 20, 2024
@nagilson nagilson changed the title Hostfxr Installation Location Path Key Hostfxr Installation Location Path Key May Diverge from Specification Nov 20, 2024
@nagilson nagilson added the question Answer questions and provide assistance, not an issue with source code or documentation. label Nov 20, 2024
@elinor-fung
Copy link
Member

The InstallLocation value is always written to the 32-bit registry:

<Component Id="cmpInstallLocation" Directory="TARGETDIR" Guid="*" Win64="no">
<RegistryKey Root="HKLM" Key="SOFTWARE\dotnet\Setup\InstalledVersions\$(var.Platform)">
<RegistryValue Action="write" Name="InstallLocation" Type="string" Value="[DOTNETHOME]" KeyPath="yes"/>
</RegistryKey>
</Component>

That is what the host uses when determining registered installs. It does not look under the 64-bit hive or at ...\sharedhost\Path.

Or, Is this design / spec wrong and needs to be updated?

Added a clarification to the design doc: dotnet/designs#325

WoW Node Missing Path Key

Looking at the setup authoring, the sharedhost\Path key is used to add to the PATH environment variable. It is only added for the native machine architecture, so will not exist in the WoW node / 32-bit hive on a 64-bit machine.

<Component Id="cmdPath" Directory="DOTNETHOME" Guid="*">
<?if $(var.Platform)~=x64 ?>
<!-- For x64 installer, only add to PATH when actually on native architecture -->
<Condition>NOT NON_NATIVE_ARCHITECTURE</Condition>
<?elseif $(var.Platform)~=x86 ?>
<!-- For x86 installer, only add to PATH when not on 64-bit platform -->
<Condition>NOT VersionNT64</Condition>
<?endif?>
<!-- A stable keypath with the right SxS characteristics for our PATH entry-->
<RegistryKey Root="HKLM" Key="SOFTWARE\dotnet\Setup\InstalledVersions\$(var.Platform)\sharedhost">
<RegistryValue KeyPath="yes" Action="write" Name="Path" Type="string" Value="[DOTNETHOME]"/>
</RegistryKey>
<Environment Id="E_PATH" Name="PATH" Value="[DOTNETHOME]" Part="last" Action="set" System="yes" />
</Component>

dotnet --info says there is an x86 dotnet registered at InstallLocation, but that doesn't exist on my registry

Can you check the 32-bit view?

@nagilson
Copy link
Member Author

Can you check the 32-bit view?

Aha, thank you -- they are under the node here! Image

I assume it's also under the 32-bit view on arm64, but I'll verify that with a VM.

Looking at the setup authoring, the sharedhost\Path key is used to add to the PATH environment variable. It is only added for the native machine architecture, so will not exist in the WoW node / 32-bit hive on a 64-bit machine.

Awesome, that's super helpful to know as well. My understanding, then, is that InstallLocation stores all of the possible installs, and the sharedhost\Path key is used for PATH lookup / should theoretically be the default host when calling dotnet on the terminal.

Knowing that will always be in that location is great.

This was super helpful. Thank you. I think updating the doc is good, so I'll add that tag to this issue.

@nagilson nagilson added documentation Documentation bug or enhancement, does not impact product or test code and removed untriaged New issue has not been triaged by the area owner labels Nov 20, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Host documentation Documentation bug or enhancement, does not impact product or test code question Answer questions and provide assistance, not an issue with source code or documentation.
Projects
Archived in project
Development

No branches or pull requests

2 participants