WebView2Utilities icon indicating copy to clipboard operation
WebView2Utilities copied to clipboard

Easy update to newer versions

Open oggy22 opened this issue 1 year ago • 1 comments

Make it as easy as possible to update to the newest version of the tool. Possible solutions:

  • Have a button for updating to the latest
  • Make the tool check if it is the latest version and suggest to the user to update

oggy22 avatar May 03 '24 20:05 oggy22

The key code looks like this

        string owner = "david-risney" +
            ""; // Replace with the repository owner
        string repo = "WebView2Utilities";   // Replace with the repository name
        string url = $"https://api.github.com/repos/{owner}/{repo}/releases";

        HttpClient client = new HttpClient();
        client.DefaultRequestHeaders.Accept.Clear();
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.github.v3+json"));
        client.DefaultRequestHeaders.Add("User-Agent", ".NET Foundation Repository Reporter");
        //client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "YOUR_PERSONAL_ACCESS_TOKEN");
        var response = client.GetStringAsync(url).Result;
        var releases = JsonSerializer.Deserialize<Release>(response);

        //using (
        //)
        //{
        //    JsonElement root = doc.RootElement;
        //    string name = root.GetProperty("name").GetString();
        //    int stars = root.GetProperty("stargazers_count").GetInt32();

        //    Console.WriteLine($"Repository: {name}, Stars: {stars}");
        //}

oggy22 avatar Sep 17 '24 06:09 oggy22