dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.42k stars 4.76k forks source link

Hostfxr Installation Location Path Key May Diverge from Specification #109974

Closed nagilson closed 1 day ago

nagilson commented 2 days ago

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\\InstallLocation.

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

https://github.com/dotnet/runtime/blob/e33be4d53ab951272c9161c50b549e5e7db60262/src/installer/pkg/sfx/installers/dotnet-host.proj#L11

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[bot] commented 2 days ago

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

elinor-fung commented 2 days ago

The InstallLocation value is always written to the 32-bit registry: https://github.com/dotnet/runtime/blob/e33be4d53ab951272c9161c50b549e5e7db60262/src/installer/pkg/sfx/installers/host.wxs#L35-L39

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: https://github.com/dotnet/designs/pull/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. https://github.com/dotnet/runtime/blob/e33be4d53ab951272c9161c50b549e5e7db60262/src/installer/pkg/sfx/installers/host.wxs#L41-L55

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 commented 1 day ago

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.