Skip to content

Commit

Permalink
Now application will exit if user tries to exit the application when …
Browse files Browse the repository at this point in the history
…Mandatory is set to true and UpdateMode is set to Forced or ForcedDownload.
  • Loading branch information
ravibpatel committed Aug 23, 2021
1 parent d6a14f8 commit d80321c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion AutoUpdater.NET/AutoUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ private static void ShowError(Exception exception)
/// <summary>
/// Detects and exits all instances of running assembly, including current.
/// </summary>
private static void Exit()
internal static void Exit()
{
var currentProcess = Process.GetCurrentProcess();
foreach (var process in Process.GetProcessesByName(currentProcess.ProcessName))
Expand Down
9 changes: 3 additions & 6 deletions AutoUpdater.NET/DownloadUpdateDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private void WebClientOnDownloadFileCompleted(object sender, AsyncCompletedEvent
processStartInfo = new ProcessStartInfo
{
FileName = "msiexec",
Arguments = $"/i \"{tempPath}\""
Arguments = $"/i \"{tempPath}\"",
};
if (!string.IsNullOrEmpty(installerArgs))
{
Expand Down Expand Up @@ -259,11 +259,8 @@ private void DownloadUpdateDialog_FormClosing(object sender, FormClosingEventArg
{
if (AutoUpdater.Mandatory && AutoUpdater.UpdateMode == Mode.ForcedDownload)
{
if (ModifierKeys == Keys.Alt || ModifierKeys == Keys.F4)
{
e.Cancel = true;
return;
}
AutoUpdater.Exit();
return;
}
if (_webClient is {IsBusy: true})
{
Expand Down
2 changes: 1 addition & 1 deletion AutoUpdater.NET/UpdateForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private void UpdateForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (AutoUpdater.Mandatory && AutoUpdater.UpdateMode == Mode.Forced)
{
e.Cancel = ModifierKeys == Keys.Alt || ModifierKeys == Keys.F4;
AutoUpdater.Exit();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2012-2020 RBSoft
Copyright (c) 2012-2021 RBSoft

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ AutoUpdater.NET is a class library that allows .NET developers to easily add aut
PM> Install-Package Autoupdater.NET.Official
````

## Supported .NET versions

* .NET Framework 4.5 or above
* .NET Core 3.1
* .NET 5.0 or above

## How it works

AutoUpdater.NET downloads the XML file containing update information from your server. It uses this XML file to get the information about the latest version of the software. If the latest version of the software is greater than the current version of the software installed on User's PC then AutoUpdater.NET shows update dialog to the user. If user press the update button to update the software then It downloads the update file (Installer) from URL provided in XML file and executes the installer file it just downloaded. It is a job of installer after this point to carry out the update. If you provide zip file URL instead of installer then AutoUpdater.NET will extract the contents of zip file to application directory.
Expand Down Expand Up @@ -220,15 +226,15 @@ AutoUpdater.Proxy = proxy;
You can specify where you want to download the update file by assigning DownloadPath field as shown below. It will be used for ZipExtractor too.

````csharp
AutoUpdater.DownloadPath = Environment.CurrentDirectory;
AutoUpdater.DownloadPath = Application.StartupPath;
````

### Specify where to extract zip file containing updated files

If you are using a zip file as an update file then you can set the "InstallationPath" equal to the path where your app is installed. This is only necessary when your installation directory differs from your executable path.

````csharp
var currentDirectory = new DirectoryInfo(Environment.CurrentDirectory);
var currentDirectory = new DirectoryInfo(Application.StartupPath);
if (currentDirectory.Parent != null)
{
AutoUpdater.InstallationPath = currentDirectory.Parent.FullName;
Expand Down

0 comments on commit d80321c

Please sign in to comment.