Skip to content

Commit 3f4622f

Browse files
authored
Fix StartupTests.StartsWithDotnetInstallLocation (#6589)
1 parent cbbdeae commit 3f4622f

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

src/Servers/IIS/AspNetCoreModuleV2/CommonLib/HostFxrResolver.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,22 @@ HostFxrResolver::GetAbsolutePathToDotnet(
259259
}
260260

261261
auto isWow64Process = Environment::IsRunning64BitProcess();
262-
const auto platform = isWow64Process? L"x64" : L"x86";
262+
263+
std::wstring regKeySubSection;
264+
265+
if (isWow64Process)
266+
{
267+
regKeySubSection = L"SOFTWARE\\WOW6432Node\\dotnet\\Setup\\InstalledVersions\\x64\\sdk";
268+
}
269+
else
270+
{
271+
regKeySubSection = L"SOFTWARE\\dotnet\\Setup\\InstalledVersions\\x86\\sdk";
272+
}
263273

264274
const auto installationLocation = RegistryKey::TryGetString(
265275
HKEY_LOCAL_MACHINE,
266-
std::wstring(L"SOFTWARE\\dotnet\\Setup\\InstalledVersions\\") + platform + L"\\sdk",
267-
L"InstallLocation",
268-
RRF_SUBKEY_WOW6432KEY);
276+
regKeySubSection,
277+
L"InstallLocation");
269278

270279
if (installationLocation.has_value())
271280
{

src/Servers/IIS/AspNetCoreModuleV2/CommonLib/RegistryKey.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ std::optional<DWORD> RegistryKey::TryGetDWORD(HKEY section, const std::wstring&
1616
return dwData;
1717
}
1818

19-
std::optional<std::wstring> RegistryKey::TryGetString(HKEY section, const std::wstring& subSectionName, const std::wstring& valueName, DWORD flags)
19+
std::optional<std::wstring> RegistryKey::TryGetString(HKEY section, const std::wstring& subSectionName, const std::wstring& valueName)
2020
{
2121
DWORD cbData;
2222

23-
if (!CheckReturnValue(RegGetValue(section, subSectionName.c_str(), valueName.c_str(), RRF_RT_REG_SZ | flags, nullptr, nullptr, &cbData) != NO_ERROR))
23+
if (!CheckReturnValue(RegGetValue(section, subSectionName.c_str(), valueName.c_str(), RRF_RT_REG_SZ, nullptr, nullptr, &cbData)))
2424
{
2525
return std::nullopt;
2626
}
2727

2828
std::wstring data;
2929
data.resize(cbData / sizeof(wchar_t));
3030

31-
if (!CheckReturnValue(RegGetValue(section, subSectionName.c_str(), valueName.c_str(), RRF_RT_REG_SZ | flags, nullptr, data.data(), &cbData) != NO_ERROR))
31+
if (!CheckReturnValue(RegGetValue(section, subSectionName.c_str(), valueName.c_str(), RRF_RT_REG_SZ, nullptr, data.data(), &cbData)))
3232
{
3333
return std::nullopt;
3434
}

src/Servers/IIS/AspNetCoreModuleV2/CommonLib/RegistryKey.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class RegistryKey
1313
std::optional<DWORD> TryGetDWORD(HKEY section, const std::wstring& subSectionName, const std::wstring& valueName, DWORD flags = 0);
1414

1515
static
16-
std::optional<std::wstring> TryGetString(HKEY section, const std::wstring& subSectionName, const std::wstring& valueName, DWORD flags = 0);
16+
std::optional<std::wstring> TryGetString(HKEY section, const std::wstring& subSectionName, const std::wstring& valueName);
1717

1818
private:
1919
static

0 commit comments

Comments
 (0)