@@ -214,75 +214,81 @@ public static void OpenUrlInBrowser(string url)
214214 /// if no external tools are configured or can download the config file.</returns>
215215 public static ExternalTool [ ] GetExternalTools ( )
216216 {
217- UpdateStatus ? . Invoke ( "Retrieving external tools information..." , 5 ) ;
218-
219- using var httpClient = new HttpClient ( ) ;
220- string json = httpClient . GetStringAsync ( GeneralConfig . ToolsListURL ) . GetAwaiter ( ) . GetResult ( ) ;
221- var tools = JsonSerializer . Deserialize < ExternalTool [ ] > ( json ) ;
222-
223- int max = tools . Length ;
224- int prg = 10 ;
225- for ( int n = 0 ; n < max ; n ++ )
217+ try
226218 {
227- var tool = tools [ n ] ;
228- prg = ( n * 90 ) / max ;
229- UpdateStatus ? . Invoke ( $ "Retrieving versions for { tool . Name } ...", prg + 10 ) ;
219+ UpdateStatus ? . Invoke ( "Retrieving external tools information..." , 5 ) ;
230220
231- tool . Versions = GetAvailableToolVersion ( tool ) ;
232- if ( tool . Versions == null )
233- {
234- tool . Versions = new ExternalTools_Version [ 0 ] ;
235- }
236- tool . InstalledVersion = GetToolVersion ( tool . Id ) ;
221+ using var httpClient = new HttpClient ( ) ;
222+ string json = httpClient . GetStringAsync ( GeneralConfig . ToolsListURL ) . GetAwaiter ( ) . GetResult ( ) ;
223+ var tools = JsonSerializer . Deserialize < ExternalTool [ ] > ( json ) ;
237224
238- // Set latest version
239- if ( GeneralConfig . OnlyStableVersions )
225+ int max = tools . Length ;
226+ int prg = 10 ;
227+ for ( int n = 0 ; n < max ; n ++ )
240228 {
241- tool . LatestVersion = tool . Versions .
242- Where ( d => d . OperatingSystem == CurrentOperatingSystem &&
243- d . BetaNumber == 0 ) .
244- OrderByDescending ( d => d . VersionNumber ) .
245- FirstOrDefault ( ) ;
246- }
247- if ( tool . LatestVersion == null || ! GeneralConfig . OnlyStableVersions )
248- {
249- tool . LatestVersion = tool . Versions .
250- Where ( d => d . OperatingSystem == CurrentOperatingSystem ) .
251- OrderByDescending ( d => d . VersionNumber ) .
252- FirstOrDefault ( ) ;
253- }
229+ var tool = tools [ n ] ;
230+ prg = ( n * 90 ) / max ;
231+ UpdateStatus ? . Invoke ( $ "Retrieving versions for { tool . Name } ...", prg + 10 ) ;
254232
255- // Path for first versions of ZXBSInstalller
256- if ( tool . Id == "zxbsinstaller" && tool . LatestVersion == null )
257- {
258- tool . LatestVersion = tool . InstalledVersion ;
259- }
233+ tool . Versions = GetAvailableToolVersion ( tool ) ;
234+ if ( tool . Versions == null )
235+ {
236+ tool . Versions = new ExternalTools_Version [ 0 ] ;
237+ }
238+ tool . InstalledVersion = GetToolVersion ( tool . Id ) ;
260239
261- // Determine whether you need to update
262- if ( tool . InstalledVersion == null )
263- {
264- tool . UpdateNeeded = true ;
265- }
266- else
267- {
268- if ( tool . LatestVersion != null )
240+ // Set latest version
241+ if ( GeneralConfig . OnlyStableVersions )
242+ {
243+ tool . LatestVersion = tool . Versions .
244+ Where ( d => d . OperatingSystem == CurrentOperatingSystem &&
245+ d . BetaNumber == 0 ) .
246+ OrderByDescending ( d => d . VersionNumber ) .
247+ FirstOrDefault ( ) ;
248+ }
249+ if ( tool . LatestVersion == null || ! GeneralConfig . OnlyStableVersions )
250+ {
251+ tool . LatestVersion = tool . Versions .
252+ Where ( d => d . OperatingSystem == CurrentOperatingSystem ) .
253+ OrderByDescending ( d => d . VersionNumber ) .
254+ FirstOrDefault ( ) ;
255+ }
256+
257+ // Path for first versions of ZXBSInstalller
258+ if ( tool . Id == "zxbsinstaller" && tool . LatestVersion == null )
259+ {
260+ tool . LatestVersion = tool . InstalledVersion ;
261+ }
262+
263+ // Determine whether you need to update
264+ if ( tool . InstalledVersion == null )
269265 {
270- if ( tool . LatestVersion . VersionNumber > tool . InstalledVersion . VersionNumber )
266+ tool . UpdateNeeded = true ;
267+ }
268+ else
269+ {
270+ if ( tool . LatestVersion != null )
271271 {
272- tool . UpdateNeeded = true ;
272+ if ( tool . LatestVersion . VersionNumber > tool . InstalledVersion . VersionNumber )
273+ {
274+ tool . UpdateNeeded = true ;
275+ }
273276 }
274277 }
275- }
276-
277- tool . LocalPath = Path . Combine ( GeneralConfig . BasePath , tool . Id ) ;
278- }
279278
280- //GetPaths(ref tools);
279+ tool . LocalPath = Path . Combine ( GeneralConfig . BasePath , tool . Id ) ;
280+ }
281281
282- ExternalTools = tools . OrderBy ( d => d . Order ) . ToArray ( ) ;
282+ //GetPaths(ref tools );
283283
284- return ExternalTools ;
284+ ExternalTools = tools . OrderBy ( d => d . Order ) . ToArray ( ) ;
285285
286+ return ExternalTools ;
287+ }
288+ catch ( Exception ex )
289+ {
290+ return null ;
291+ }
286292#if GENERATE_JSON
287293 var lst = new List < ExternalTool > ( ) ;
288294 // Compiler
0 commit comments