feat: autoupdater
This commit is contained in:
@@ -21,7 +21,7 @@ namespace CarManagerV3.Manager
|
||||
private static DateTime lastChecked = DateTime.MinValue;
|
||||
private static readonly int CacheDurationMinutes = 60;
|
||||
private static bool cacheIncludesPrerelease = false;
|
||||
private static readonly string debugVersion = "1.2.0";
|
||||
private static readonly string debugVersion = null;//"1.2.0";
|
||||
|
||||
public static string GetCurrentVersion()
|
||||
{
|
||||
@@ -111,7 +111,7 @@ namespace CarManagerV3.Manager
|
||||
}
|
||||
|
||||
|
||||
public static async void DownloadNewestInstaller(bool includePreRelease = false)
|
||||
public static void DownloadNewestInstaller(bool includePreRelease = false)
|
||||
{
|
||||
string latestVersion = GetLatestVersion(includePreRelease);
|
||||
if (latestVersion == null)
|
||||
@@ -137,27 +137,25 @@ namespace CarManagerV3.Manager
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (downloadUrl != null)
|
||||
{
|
||||
PleaseWait loadForm = new PleaseWait("Downloading the newest version...");
|
||||
loadForm.Show();
|
||||
Application.DoEvents();
|
||||
await Task.Run(() =>
|
||||
|
||||
|
||||
// Download the installer to the users set Data dir, run it, and then exit the application.
|
||||
string tempFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), $"CarManagerInstaller_{latestVersion}.msi");
|
||||
using (var downloadClient = new System.Net.WebClient())
|
||||
{
|
||||
// Download the installer to the users set Data dir, run it, and then exit the application.
|
||||
string tempFilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), $"CarManagerInstaller_{latestVersion}.msi");
|
||||
using (var downloadClient = new System.Net.WebClient())
|
||||
{
|
||||
downloadClient.DownloadFile(downloadUrl, tempFilePath);
|
||||
}
|
||||
// Use ProcessStartInfo with UseShellExecute to launch the MSI file
|
||||
var processStartInfo = new System.Diagnostics.ProcessStartInfo
|
||||
{
|
||||
FileName = tempFilePath,
|
||||
UseShellExecute = true
|
||||
};
|
||||
System.Diagnostics.Process.Start(processStartInfo);
|
||||
});
|
||||
downloadClient.DownloadFile(downloadUrl, tempFilePath);
|
||||
}
|
||||
// Use ProcessStartInfo with UseShellExecute to launch the MSI file
|
||||
var processStartInfo = new System.Diagnostics.ProcessStartInfo
|
||||
{
|
||||
FileName = tempFilePath,
|
||||
UseShellExecute = true
|
||||
};
|
||||
System.Diagnostics.Process.Start(processStartInfo);
|
||||
|
||||
|
||||
Application.Exit();
|
||||
}
|
||||
@@ -181,5 +179,19 @@ namespace CarManagerV3.Manager
|
||||
string latestVersion = GetLatestVersion(includePreRelease);
|
||||
return IsNewerVersion(latestVersion, currentVersion);
|
||||
}
|
||||
|
||||
public static void openReleasePage(string version = null)
|
||||
{
|
||||
if(version == null)
|
||||
{
|
||||
version = GetLatestVersion(true);
|
||||
}
|
||||
string releaseUrl = $"https://git.jaro.digital/{GitRepoOwner}/{GitRepoName}/releases/tag/{version}";
|
||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
|
||||
{
|
||||
FileName = releaseUrl,
|
||||
UseShellExecute = true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user