diff --git a/src/NetSparkle/AppCastHandlers/AppCastHelper.cs b/src/NetSparkle/AppCastHandlers/AppCastHelper.cs
index 912609c1..ef9cb5dd 100644
--- a/src/NetSparkle/AppCastHandlers/AppCastHelper.cs
+++ b/src/NetSparkle/AppCastHandlers/AppCastHelper.cs
@@ -75,7 +75,8 @@ public AppCastHelper()
/// installed version of the software
/// Object to check signatures of app cast information
/// object that you can utilize to do any necessary logging
- public virtual void SetupAppCastHelper(IAppCastDataDownloader dataDownloader, string castUrl, string? installedVersion, ISignatureVerifier? signatureVerifier, ILogger? logWriter = null)
+ public virtual void SetupAppCastHelper(IAppCastDataDownloader dataDownloader, string castUrl,
+ string? installedVersion, ISignatureVerifier? signatureVerifier, ILogger? logWriter = null)
{
_dataDownloader = dataDownloader;
_installedVersion = installedVersion;
@@ -245,7 +246,9 @@ public virtual List FilterUpdates(List items)
}
var signatureNeeded = IsSignatureNeeded();
- _logWriter?.PrintMessage("Looking for available updates; our installed version is {0}; do we need a signature? {1}; are we filtering out smaller versions than our current version? {2}", installedVersion, signatureNeeded, shouldFilterOutSmallerVersions);
+ _logWriter?.PrintMessage("Looking for available updates; our installed version is {0}; " +
+ "do we need a signature? {1}; are we filtering out smaller versions than our " +
+ "current version? {2}", installedVersion, signatureNeeded, shouldFilterOutSmallerVersions);
return items.Where((item) =>
{
var filterResult = FilterAppCastItem(installedVersion, shouldFilterOutSmallerVersions, signatureNeeded, item);
@@ -262,7 +265,8 @@ public virtual List FilterUpdates(List items)
return false;
}
// accept all valid items
- _logWriter?.PrintMessage("Item with version {0} ({1}) is a valid update! It can be downloaded at {2}", item.Version ?? "[Unknown version]", item.ShortVersion ?? "[Unknown short version]", item.DownloadLink ?? "[Unknown download link]");
+ _logWriter?.PrintMessage("Item with version {0} ({1}) is a valid update! It can be downloaded at {2}",
+ item.Version ?? "[Unknown version]", item.ShortVersion ?? "[Unknown short version]", item.DownloadLink ?? "[Unknown download link]");
return true;
}
return false;
@@ -337,17 +341,23 @@ protected FilterItemResult FilterAppCastItemByOS(AppCastItem item)
// operating system
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !item.IsWindowsUpdate)
{
- _logWriter?.PrintMessage("Rejecting update for {0} ({1}, {2}) because it isn't a Windows update and we're on Windows", item.Version ?? "[Unknown version]", item.ShortVersion ?? "[Unknown short version]", item.DownloadLink ?? "[Unknown download link]");
+ _logWriter?.PrintMessage("Rejecting update for {0} ({1}, {2}) because it isn't a Windows " +
+ "update and we're on Windows", item.Version ?? "[Unknown version]",
+ item.ShortVersion ?? "[Unknown short version]", item.DownloadLink ?? "[Unknown download link]");
return FilterItemResult.NotThisPlatform;
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && !item.IsMacOSUpdate)
{
- _logWriter?.PrintMessage("Rejecting update for {0} ({1}, {2}) because it isn't a macOS update and we're on macOS", item.Version ?? "[Unknown version]", item.ShortVersion ?? "[Unknown short version]", item.DownloadLink ?? "[Unknown download link]");
+ _logWriter?.PrintMessage("Rejecting update for {0} ({1}, {2}) because it isn't a macOS " +
+ "update and we're on macOS", item.Version ?? "[Unknown version]",
+ item.ShortVersion ?? "[Unknown short version]", item.DownloadLink ?? "[Unknown download link]");
return FilterItemResult.NotThisPlatform;
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && !item.IsLinuxUpdate)
{
- _logWriter?.PrintMessage("Rejecting update for {0} ({1}, {2}) because it isn't a Linux update and we're on Linux", item.Version ?? "[Unknown version]", item.ShortVersion ?? "[Unknown short version]", item.DownloadLink ?? "[Unknown download link]");
+ _logWriter?.PrintMessage("Rejecting update for {0} ({1}, {2}) because it isn't a Linux " +
+ "update and we're on Linux", item.Version ?? "[Unknown version]",
+ item.ShortVersion ?? "[Unknown short version]", item.DownloadLink ?? "[Unknown download link]");
return FilterItemResult.NotThisPlatform;
}
#endif
diff --git a/src/NetSparkle/Configurations/Configuration.cs b/src/NetSparkle/Configurations/Configuration.cs
index 34566dcd..63794c95 100644
--- a/src/NetSparkle/Configurations/Configuration.cs
+++ b/src/NetSparkle/Configurations/Configuration.cs
@@ -26,7 +26,7 @@ public abstract class Configuration
///
/// The currently-installed version, e.g. "1.4.3"
///
- public string InstalledVersion { get; protected set; }
+ public string? InstalledVersion { get; protected set; }
///
/// Flag to indicate if we should check for updates
///
diff --git a/src/NetSparkle/Configurations/RegistryConfiguration.cs b/src/NetSparkle/Configurations/RegistryConfiguration.cs
index edd21d37..f8d97f64 100644
--- a/src/NetSparkle/Configurations/RegistryConfiguration.cs
+++ b/src/NetSparkle/Configurations/RegistryConfiguration.cs
@@ -224,7 +224,10 @@ private bool SaveValuesToPath(string regPath)
key.SetValue("SkipThisVersion", LastVersionSkipped ?? "", RegistryValueKind.String);
key.SetValue("DidRunOnce", DidRunOnce.ToString(), RegistryValueKind.String);
key.SetValue("LastProfileUpdate", ConvertDateToString(LastConfigUpdate), RegistryValueKind.String);
- key.SetValue("PreviousVersionRun", InstalledVersion, RegistryValueKind.String);
+ if (InstalledVersion != null)
+ {
+ key.SetValue("PreviousVersionRun", InstalledVersion, RegistryValueKind.String);
+ }
return true;
}
diff --git a/src/NetSparkle/SparkleUpdater.cs b/src/NetSparkle/SparkleUpdater.cs
index c5221987..40168d65 100644
--- a/src/NetSparkle/SparkleUpdater.cs
+++ b/src/NetSparkle/SparkleUpdater.cs
@@ -756,7 +756,7 @@ protected async Task GetUpdateStatus(Configuration config, bool igno
// check if the version will be the same then the installed version
if (updates.Count == 0)
{
- LogWriter?.PrintMessage("Installed version is latest, no update needed ({0})", config.InstalledVersion);
+ LogWriter?.PrintMessage("Installed version is latest, no update needed ({0})", config.InstalledVersion ?? "[no installed version]");
return new UpdateInfo(UpdateStatus.UpdateNotAvailable, updates);
}
LogWriter?.PrintMessage("Latest version on the server is {0}", updates[0].Version ?? "[Unknown]");
@@ -1789,7 +1789,8 @@ private async Task CheckForUpdates(bool isUserManuallyCheckingForUpd
if (_latestDownloadedUpdateInfo.Status == UpdateStatus.UpdateAvailable)
{
// there's an update available!
- LogWriter?.PrintMessage("Update needed from version {0} to version {1}", config.InstalledVersion, updates[0].Version ?? "[unknown version]");
+ LogWriter?.PrintMessage("Update needed from version {0} to version {1}",
+ config.InstalledVersion ?? "[no installed version]", updates[0].Version ?? "[unknown version]");
UpdateDetectedEventArgs ev = new UpdateDetectedEventArgs(
NextUpdateAction.ShowStandardUserInterface,
@@ -1979,7 +1980,8 @@ private async void OnWorkerDoWork()
{
List updates = _latestDownloadedUpdateInfo.Updates;
// show the update window
- LogWriter?.PrintMessage("Update needed from version {0} to version {1}", config.InstalledVersion, updates[0].Version ?? "[Unknown version]");
+ LogWriter?.PrintMessage("Update needed from version {0} to version {1}",
+ config.InstalledVersion ?? "[no installed version]", updates[0].Version ?? "[Unknown version]");
// send notification if needed
UpdateDetectedEventArgs ev = new UpdateDetectedEventArgs(