Skip to content

Commit

Permalink
Fix version check (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Jun 25, 2021
1 parent 39ef6b9 commit f18a977
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions nanoFirmwareFlasher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,16 @@ await parsedArguments
return (int)_exitCode;
}

private static void CheckVersion(Version currentVversion)
private static void CheckVersion()
{
Version latestVersion;
Version currentVersion = Version.Parse(_informationalVersionAttribute.InformationalVersion.Split('+')[0]);

using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.github.v3+json"));

client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("nanoff", currentVversion.ToString()));
client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("nanoff", currentVersion.ToString()));

HttpResponseMessage response = client.GetAsync("https://api.github.com/repos/nanoframework/nanoFirmwareFlasher/releases/latest").Result;

Expand All @@ -104,7 +105,7 @@ private static void CheckVersion(Version currentVversion)
latestVersion = Version.Parse(tagName.Substring(1));
}

if(latestVersion > currentVversion)
if(latestVersion > currentVersion)
{
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("** There is a new version available, update is recommended **");
Expand Down Expand Up @@ -166,7 +167,8 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
Console.WriteLine(_copyrightInfo);
Console.WriteLine();

CheckVersion(Assembly.GetExecutingAssembly().GetName().Version);
// perform version check
CheckVersion();
Console.WriteLine();

Console.ForegroundColor = ConsoleColor.White;
Expand Down

0 comments on commit f18a977

Please sign in to comment.