void get_framework_and_sdk_locations(const pal::string_t& dotnet_dir, std::vector<pal::string_t>* locations) { bool multilevel_lookup = multilevel_lookup_enabled(); // Multi-level lookup will look for the most appropriate version in several locations // by following the priority rank below: // .exe directory // Global .NET directories // If it is not activated, then only .exe directory will be considered pal::string_t dotnet_dir_temp; if (!dotnet_dir.empty()) { // own_dir contains DIR_SEPARATOR appended that we need to remove. dotnet_dir_temp = dotnet_dir; remove_trailing_dir_seperator(&dotnet_dir_temp); locations->push_back(dotnet_dir_temp); } std::vector<pal::string_t> global_dirs; if (multilevel_lookup && pal::get_global_dotnet_dirs(&global_dirs)) { for (pal::string_t dir : global_dirs) { // avoid duplicate paths if (!pal::are_paths_equal_with_normalized_casing(dir, dotnet_dir_temp)) { locations->push_back(dir); } } } }
/*static*/ void framework_info::get_all_framework_infos( const pal::string_t& own_dir, const pal::string_t& fx_name, std::vector<framework_info>* framework_infos) { std::vector<pal::string_t> global_dirs; bool multilevel_lookup = multilevel_lookup_enabled(); // own_dir contains DIR_SEPARATOR appended that we need to remove. pal::string_t own_dir_temp = own_dir; remove_trailing_dir_seperator(&own_dir_temp); std::vector<pal::string_t> hive_dir; hive_dir.push_back(own_dir_temp); if (multilevel_lookup && pal::get_global_dotnet_dirs(&global_dirs)) { for (pal::string_t dir : global_dirs) { if (!pal::are_paths_equal_with_normalized_casing(dir, own_dir_temp)) { hive_dir.push_back(dir); } } } for (pal::string_t dir : hive_dir) { auto fx_shared_dir = dir; append_path(&fx_shared_dir, _X("shared")); if (pal::directory_exists(fx_shared_dir)) { std::vector<pal::string_t> fx_names; if (fx_name.length()) { // Use the provided framework name fx_names.push_back(fx_name); } else { // Read all frameworks, including "Microsoft.NETCore.App" pal::readdir_onlydirectories(fx_shared_dir, &fx_names); } for (pal::string_t fx_name : fx_names) { auto fx_dir = fx_shared_dir; append_path(&fx_dir, fx_name.c_str()); if (pal::directory_exists(fx_dir)) { trace::verbose(_X("Gathering FX locations in [%s]"), fx_dir.c_str()); std::vector<pal::string_t> versions; pal::readdir_onlydirectories(fx_dir, &versions); for (const auto& ver : versions) { // Make sure we filter out any non-version folders. fx_ver_t parsed; if (fx_ver_t::parse(ver, &parsed, false)) { trace::verbose(_X("Found FX version [%s]"), ver.c_str()); framework_info info(fx_name, fx_dir, parsed); framework_infos->push_back(info); } } } } } } std::sort(framework_infos->begin(), framework_infos->end(), compare_by_name_and_version); }