}
[Fact]
+ public void EnvironmentVariable_DotNetRootIsUsedOverInstallLocationIfSet()
+ {
+ var fixture = sharedTestState.PortableAppFixture
+ .Copy();
+
+ var appExe = fixture.TestProject.AppExe;
+ var arch = fixture.RepoDirProvider.BuildArchitecture.ToUpper();
+ var dotnet = fixture.BuiltDotnet.BinPath;
+
+ using (var registeredInstallLocationOverride = new RegisteredInstallLocationOverride(appExe))
+ {
+ registeredInstallLocationOverride.SetInstallLocation((arch, "some/install/location"));
+
+ Command.Create(appExe)
+ .EnableTracingAndCaptureOutputs()
+ .ApplyRegisteredInstallLocationOverride(registeredInstallLocationOverride)
+ .DotNetRoot(dotnet, arch)
+ .Execute()
+ .Should().Pass()
+ .And.HaveUsedDotNetRootInstallLocation(dotnet, fixture.CurrentRid, arch)
+ .And.NotHaveStdErrContaining("Using global install location");
+ }
+ }
+
+ [Fact]
public void EnvironmentVariable_DotnetRootPathDoesNotExist()
{
var fixture = sharedTestState.PortableAppFixture
}
[Fact]
- [SkipOnPlatform(TestPlatforms.Windows, "This test targets the install_location config file which is only used on Linux and macOS.")]
public void InstallLocationFile_ArchSpecificLocationIsPickedFirst()
{
var fixture = sharedTestState.PortableAppFixture
(arch2, path2)
});
- Command.Create(appExe)
+ CommandResult result = Command.Create(appExe)
.EnableTracingAndCaptureOutputs()
.ApplyRegisteredInstallLocationOverride(registeredInstallLocationOverride)
.DotNetRoot(null)
- .Execute()
- .Should().HaveFoundDefaultInstallLocationInConfigFile(path1)
- .And.HaveFoundArchSpecificInstallLocationInConfigFile(path1, arch1)
- .And.HaveFoundArchSpecificInstallLocationInConfigFile(path2, arch2)
- .And.HaveUsedGlobalInstallLocation(path2);
+ .Execute();
+
+ if (!OperatingSystem.IsWindows())
+ {
+ result.Should().HaveFoundDefaultInstallLocationInConfigFile(path1)
+ .And.HaveFoundArchSpecificInstallLocationInConfigFile(path1, arch1)
+ .And.HaveFoundArchSpecificInstallLocationInConfigFile(path2, arch2);
+ }
+
+ result.Should().HaveUsedGlobalInstallLocation(path2);
}
}
# Specify non-default Windows libs to be used for Arm/Arm64 builds
if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64))
- target_link_libraries(apphost Advapi32.lib shell32.lib)
+ target_link_libraries(apphost shell32.lib)
endif()
# Specify non-default Windows libs to be used for Arm/Arm64 builds
if (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64)
- list(APPEND WINLIBS Advapi32.lib Ole32.lib OleAut32.lib)
+ list(APPEND WINLIBS Ole32.lib OleAut32.lib)
endif()
target_link_libraries(comhost ${WINLIBS})
# Specify the import library to link against for Arm32 build since the default set is minimal
if (CLR_CMAKE_TARGET_ARCH_ARM)
if (CLR_CMAKE_TARGET_WIN32)
- target_link_libraries(${DOTNET_PROJECT_NAME} shell32.lib)
+ target_link_libraries(${DOTNET_PROJECT_NAME} shell32.lib advapi32.lib)
else()
target_link_libraries(${DOTNET_PROJECT_NAME} atomic.a)
endif()
pal::get_default_installation_dir(&default_install_location);
}
- pal::string_t self_registered_config_location;
- pal::string_t self_registered_message;
- if (pal::get_dotnet_self_registered_config_location(&self_registered_config_location))
- {
- self_registered_message =
- pal::string_t(_X(" or register the runtime location in [") + self_registered_config_location + _X("]"));
- }
+ pal::string_t self_registered_config_location = pal::get_dotnet_self_registered_config_location();
+ pal::string_t self_registered_message = _X(" or register the runtime location in [") + self_registered_config_location + _X("]");
trace::error(_X("A fatal error occurred. The required library %s could not be found.\n"
"If this is a self-contained application, that library should exist in [%s].\n"
// Returns the globally registered install location (if any)
bool get_dotnet_self_registered_dir(string_t* recv);
// Returns name of the global registry location (for error messages)
- bool get_dotnet_self_registered_config_location(string_t* recv);
+ string_t get_dotnet_self_registered_config_location();
// Returns the default install location for a given platform
bool get_default_installation_dir(string_t* recv);
return false;
}
-bool pal::get_dotnet_self_registered_config_location(pal::string_t* recv)
+pal::string_t pal::get_dotnet_self_registered_config_location()
{
- recv->assign(_X("/etc/dotnet/install_location"));
-
// ***Used only for testing***
pal::string_t environment_install_location_override;
if (test_only_getenv(_X("_DOTNET_TEST_INSTALL_LOCATION_FILE_PATH"), &environment_install_location_override))
{
- recv->assign(environment_install_location_override);
+ return environment_install_location_override;
}
- return true;
+ return _X("/etc/dotnet/install_location");
}
namespace
}
// ***************************
- pal::string_t install_location_file_path;
- if (!get_dotnet_self_registered_config_location(&install_location_file_path))
- {
- return false;
- }
- // ***************************
-
+ pal::string_t install_location_file_path = get_dotnet_self_registered_config_location();
trace::verbose(_X("Looking for install_location file in '%s'."), install_location_file_path.c_str());
FILE* install_location_file = pal::file_open(install_location_file_path, "r");
if (install_location_file == nullptr)
}
}
-bool pal::get_dotnet_self_registered_config_location(pal::string_t* recv)
+pal::string_t pal::get_dotnet_self_registered_config_location()
{
-#if !defined(TARGET_AMD64) && !defined(TARGET_X86)
- return false;
-#else
HKEY key_hive;
pal::string_t sub_key;
const pal::char_t* value;
get_dotnet_install_location_registry_path(&key_hive, &sub_key, &value);
- recv->assign((key_hive == HKEY_CURRENT_USER ? _X("HKCU\\") : _X("HKLM\\")) + sub_key + _X("\\") + value);
- return true;
-#endif
+ return (key_hive == HKEY_CURRENT_USER ? _X("HKCU\\") : _X("HKLM\\")) + sub_key + _X("\\") + value;
}
bool pal::get_dotnet_self_registered_dir(pal::string_t* recv)
{
-#if !defined(TARGET_AMD64) && !defined(TARGET_X86)
- // Self-registered SDK installation directory is only supported for x64 and x86 architectures.
- return false;
-#else
recv->clear();
// ***Used only for testing***
recv->assign(buffer.data());
::RegCloseKey(hkey);
return true;
-#endif
}
bool pal::get_global_dotnet_dirs(std::vector<pal::string_t>* dirs)
# Specify non-default Windows libs to be used for Arm/Arm64 builds
if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64))
- target_link_libraries(ijwhost Advapi32.lib Ole32.lib)
+ target_link_libraries(ijwhost Ole32.lib)
endif()
install_with_stripped_symbols(ijwhost TARGETS corehost)
# Specify non-default Windows libs to be used for Arm/Arm64 builds
if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64))
- target_link_libraries(${DOTNET_PROJECT_NAME} Advapi32.lib Ole32.lib OleAut32.lib)
+ target_link_libraries(${DOTNET_PROJECT_NAME} Ole32.lib OleAut32.lib)
endif()