@@ -96,29 +96,39 @@ await parsedArguments
9696
9797 private static void CheckVersion ( )
9898 {
99- Version latestVersion ;
100- Version currentVersion = Version . Parse ( _informationalVersionAttribute . InformationalVersion . Split ( '+' ) [ 0 ] ) ;
101-
102- using ( var client = new HttpClient ( ) )
99+ try
103100 {
104- client . DefaultRequestHeaders . Accept . Add ( new MediaTypeWithQualityHeaderValue ( "application/vnd.github.v3+json" ) ) ;
101+ Version latestVersion ;
102+ Version currentVersion = Version . Parse ( _informationalVersionAttribute . InformationalVersion . Split ( '+' ) [ 0 ] ) ;
105103
106- client . DefaultRequestHeaders . UserAgent . Add ( new ProductInfoHeaderValue ( "nanoff" , currentVersion . ToString ( ) ) ) ;
104+ using ( var client = new HttpClient ( ) )
105+ {
106+ client . DefaultRequestHeaders . Accept . Add ( new MediaTypeWithQualityHeaderValue ( "application/vnd.github.v3+json" ) ) ;
107107
108- HttpResponseMessage response = client . GetAsync ( "https://api.github.com/repos/nanoframework/nanoFirmwareFlasher/releases/latest" ) . Result ;
108+ client . DefaultRequestHeaders . UserAgent . Add ( new ProductInfoHeaderValue ( "nanoff" , currentVersion . ToString ( ) ) ) ;
109109
110- dynamic responseContent = JsonConvert . DeserializeObject ( response . Content . ReadAsStringAsync ( ) . Result ) ;
111- string tagName = responseContent . tag_name . ToString ( ) ;
110+ HttpResponseMessage response = client . GetAsync ( "https://api.github.com/repos/nanoframework/nanoFirmwareFlasher/releases/latest" ) . Result ;
112111
113- latestVersion = Version . Parse ( tagName . Substring ( 1 ) ) ;
114- }
112+ dynamic responseContent = JsonConvert . DeserializeObject ( response . Content . ReadAsStringAsync ( ) . Result ) ;
113+ string tagName = responseContent . tag_name . ToString ( ) ;
114+
115+ latestVersion = Version . Parse ( tagName . Substring ( 1 ) ) ;
116+ }
115117
116- if ( latestVersion > currentVersion )
118+ if ( latestVersion > currentVersion )
119+ {
120+ Console . ForegroundColor = ConsoleColor . DarkYellow ;
121+ Console . WriteLine ( "** There is a new version available, update is recommended **" ) ;
122+ Console . WriteLine ( "** You should consider updating via the 'dotnet tool update -g nanoff' command **" ) ;
123+ Console . WriteLine ( "** If you have it installed on a specific path please check the instructions here: https://git.io/JiU0C **" ) ;
124+ Console . ForegroundColor = ConsoleColor . White ;
125+ }
126+ }
127+ catch ( Exception )
117128 {
118129 Console . ForegroundColor = ConsoleColor . DarkYellow ;
119- Console . WriteLine ( "** There is a new version available, update is recommended **" ) ;
120- Console . WriteLine ( "** You should consider updating via the 'dotnet tool update -g nanoff' command **" ) ;
121- Console . WriteLine ( "** If you have it installed on a specific path please check the instructions here: https://git.io/JiU0C **" ) ;
130+ Console . WriteLine ( "** Can't check the version! **" ) ;
131+ Console . WriteLine ( "** Continuing anyway. **" ) ;
122132 Console . ForegroundColor = ConsoleColor . White ;
123133 }
124134 }
0 commit comments