@@ -93,7 +93,6 @@ bool fxr_resolver::try_get_path(
93
93
bool search_app_relative = (search & search_location_app_relative) != 0 && app_relative_dotnet_root != nullptr && !app_relative_dotnet_root->empty ();
94
94
bool search_env = (search & search_location_environment_variable) != 0 ;
95
95
bool search_global = (search & search_location_global) != 0 ;
96
- pal::string_t default_install_location;
97
96
pal::string_t dotnet_root_env_var_name;
98
97
if (search_app_relative && pal::fullpath (app_relative_dotnet_root))
99
98
{
@@ -111,10 +110,11 @@ bool fxr_resolver::try_get_path(
111
110
}
112
111
else if (search_global)
113
112
{
114
- if (pal::get_dotnet_self_registered_dir (&default_install_location) || pal::get_default_installation_dir (&default_install_location))
113
+ pal::string_t global_install_location;
114
+ if (pal::get_dotnet_self_registered_dir (&global_install_location) || pal::get_default_installation_dir (&global_install_location))
115
115
{
116
- trace::info (_X (" Using global install location [%s] as runtime location." ), default_install_location .c_str ());
117
- out_dotnet_root->assign (default_install_location );
116
+ trace::info (_X (" Using global install location [%s] as runtime location." ), global_install_location .c_str ());
117
+ out_dotnet_root->assign (global_install_location );
118
118
}
119
119
else
120
120
{
@@ -130,35 +130,7 @@ bool fxr_resolver::try_get_path(
130
130
return get_latest_fxr (std::move (fxr_dir), out_fxr_path);
131
131
132
132
// Failed to find hostfxr
133
- if (trace::is_enabled ())
134
- {
135
- trace::verbose (_X (" The required library %s could not be found. Search location options [0x%x]" ), LIBFXR_NAME, search);
136
- if (search_app_local)
137
- trace::verbose (_X (" app-local: [%s]" ), root_path.c_str ());
138
-
139
- if (search_app_relative)
140
- trace::verbose (_X (" app-relative: [%s]" ), app_relative_dotnet_root->c_str ());
141
-
142
- if (search_env)
143
- trace::verbose (_X (" environment variable: [%s]" ), dotnet_root_env_var_name.c_str ());
144
-
145
- if (search_global)
146
- {
147
- if (default_install_location.empty ())
148
- {
149
- pal::get_dotnet_self_registered_dir (&default_install_location);
150
- }
151
- if (default_install_location.empty ())
152
- {
153
- pal::get_default_installation_dir (&default_install_location);
154
- }
155
-
156
- pal::string_t self_registered_config_location = pal::get_dotnet_self_registered_config_location (get_current_arch ());
157
- trace::verbose (_X (" global install location [%s]\n self-registered config location [%s]" ),
158
- default_install_location.c_str (),
159
- self_registered_config_location.c_str ());
160
- }
161
- }
133
+ trace::verbose (_X (" The required library %s could not be found. Search location options [0x%x]" ), LIBFXR_NAME, search);
162
134
163
135
pal::string_t host_path;
164
136
pal::get_own_executable_path (&host_path);
@@ -187,6 +159,66 @@ bool fxr_resolver::try_get_path(
187
159
}
188
160
}
189
161
162
+ pal::string_t searched_locations = _X (" The following locations were searched:" );
163
+ if (search_app_local && !root_path.empty ())
164
+ {
165
+ searched_locations.append (_X (" \n Application directory:\n " ));
166
+ searched_locations.append (root_path);
167
+ }
168
+
169
+ if (search_app_relative)
170
+ {
171
+ searched_locations.append (_X (" \n App-relative location:\n " ));
172
+ searched_locations.append (*app_relative_dotnet_root);
173
+ }
174
+
175
+ if (search_env)
176
+ {
177
+ searched_locations.append (_X (" \n Environment variable:\n " ));
178
+ if (dotnet_root_env_var_name.empty ())
179
+ {
180
+ searched_locations.append (get_dotnet_root_env_var_for_arch (get_current_arch ()));
181
+ searched_locations.append (_X (" = <not set>\n " ));
182
+ searched_locations.append (DOTNET_ROOT_ENV_VAR _X (" = <not set>" ));
183
+ }
184
+ else
185
+ {
186
+ searched_locations.append (dotnet_root_env_var_name);
187
+ searched_locations.append (_X (" = " ));
188
+ searched_locations.append (*out_dotnet_root);
189
+ }
190
+ }
191
+
192
+ // Global locations are only searched if environment variables are not set
193
+ if (search_global && dotnet_root_env_var_name.empty ())
194
+ {
195
+ searched_locations.append (_X (" \n Registered location:\n " ));
196
+ searched_locations.append (pal::get_dotnet_self_registered_config_location (get_current_arch ()));
197
+
198
+ pal::string_t self_registered_dir;
199
+ if (pal::get_dotnet_self_registered_dir (&self_registered_dir) && !self_registered_dir.empty ())
200
+ {
201
+ searched_locations.append (_X (" = " ));
202
+ searched_locations.append (self_registered_dir);
203
+ }
204
+ else
205
+ {
206
+ searched_locations.append (_X (" = <not set>" ));
207
+ }
208
+
209
+ // Default install location is only searched if self-registered location is not set
210
+ if (self_registered_dir.empty ())
211
+ {
212
+ pal::string_t default_install_location;
213
+ pal::get_default_installation_dir (&default_install_location);
214
+ searched_locations.append (_X (" \n Default location:\n " ));
215
+ searched_locations.append (default_install_location);
216
+ }
217
+ }
218
+
219
+ location.append (_X (" \n\n " ));
220
+ location.append (searched_locations);
221
+
190
222
trace::error (
191
223
MISSING_RUNTIME_ERROR_FORMAT,
192
224
INSTALL_NET_ERROR_MESSAGE,
0 commit comments