{
for (pal::string_t dir : global_dirs)
{
- if (dir != own_dir_temp)
+ if (!pal::are_paths_equal_with_normalized_casing(dir, own_dir_temp))
{
hive_dir.push_back(dir);
}
for (pal::string_t dir : global_dirs)
{
// Avoid duplicate of dotnet_dir_temp
- if (dir != dotnet_dir_temp)
+ if (!pal::are_paths_equal_with_normalized_casing(dir, dotnet_dir_temp))
{
hive_dir.push_back(dir);
}
{
for (pal::string_t dir : global_dirs)
{
- if (dir != own_dir_temp)
+ if (!pal::are_paths_equal_with_normalized_casing(dir, own_dir_temp))
{
hive_dir.push_back(dir);
}
std::vector<pal::string_t> global_dirs;
bool multilevel_lookup = multilevel_lookup_enabled();
+ pal::string_t dotnet_root_temp;
if (!dotnet_root.empty())
{
- hive_dir.push_back(dotnet_root);
+ // dotnet_root contains DIR_SEPARATOR appended that we need to remove.
+ dotnet_root_temp = dotnet_root;
+ remove_trailing_dir_seperator(&dotnet_root_temp);
+ hive_dir.push_back(dotnet_root_temp);
}
if (multilevel_lookup && pal::get_global_dotnet_dirs(&global_dirs))
{
for (pal::string_t dir : global_dirs)
{
- hive_dir.push_back(dir);
+ // Avoid duplicate of dotnet_root_temp
+ if (!pal::are_paths_equal_with_normalized_casing(dir, dotnet_root_temp))
+ {
+ hive_dir.push_back(dir);
+ }
}
}
void unload_library(dll_t library);
bool is_running_in_wow64();
+
+ bool are_paths_equal_with_normalized_casing(const string_t& path1, const string_t& path2);
}
#endif // PAL_H
{
return false;
}
+
+bool pal::are_paths_equal_with_normalized_casing(const string_t& path1, const string_t& path2)
+{
+#if defined(__APPLE__)
+ // On Mac, paths are case-insensitive
+ return (strcasecmp(path1.c_str(), path2.c_str()) == 0);
+#else
+ // On Linux, paths are case-sensitive
+ return path1 == path2;
+#endif
+}
}
return (fWow64Process != FALSE);
}
+
+bool pal::are_paths_equal_with_normalized_casing(const string_t& path1, const string_t& path2)
+{
+ // On Windows, paths are case-insensitive
+ return (strcasecmp(path1.c_str(), path2.c_str()) == 0);
+}