diff --git a/Package.nuspec b/Package.nuspec index e2dbbcb..02559de 100644 --- a/Package.nuspec +++ b/Package.nuspec @@ -11,16 +11,16 @@ https://codedead.com/Software/codedead.png true - This library can be used to check for application updates. It is designed for WPF and Windows Forms applications. In order to use it, you require an XML or JSON file on a remote or local server that represents the Update class. + This library can be used to check for application updates. It is designed for .NET Standard 2.0 applications. In order to use it, you require an XML or JSON file on a remote or local server that represents the Update class. - Added support for asynchronously checking for updates + Library is now .NET Standard 2.0 compliant and added support for asynchronously checking for updates Copyright © 2019 CodeDead CodeDead UpdateManager Update Updater updates updating downloader downloading - + \ No newline at end of file diff --git a/README.md b/README.md index 20bfb3b..28e4379 100644 --- a/README.md +++ b/README.md @@ -1,82 +1,138 @@ -# UpdateManager -UpdateManager was created by DeadLine. This library was developed free of charge. +

+ +

+# UpdateManager [![NuGet](https://img.shields.io/nuget/v/CodeDead.UpdateManager)](https://www.nuget.org/packages/CodeDead.UpdateManager/) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://codedead.com/?page_id=302) This library can be used to check for application updates. It is designed for WPF and Windows Forms applications. In order to use it, you require an XML or JSON file on a remote or local server that represents the Update class. -## Dependencies -* [.NET Framework 4.8](https://dotnet.microsoft.com/download/dotnet-framework/net48) +### Dependencies +* .NET Standard 2.0 + +## Sample projects +Sample projects can be found here: +https://github.com/CodeDead/UpdateManager/tree/master/UpdateManager.Sample +https://github.com/CodeDead/UpdateManager/tree/master/UpdateManager.Sample.WPF ## Usage UpdateManager is available as a [NuGet package](https://www.nuget.org/packages/CodeDead.UpdateManager/). You can find it here: https://www.nuget.org/packages/CodeDead.UpdateManager/ -Sample projects can be found here: -https://github.com/CodeDead/UpdateManager/tree/master/UpdateManager.Sample -https://github.com/CodeDead/UpdateManager/tree/master/UpdateManager.Sample.WPF +You can install the package using your package manager: +```NuGet +Install-Package CodeDead.UpdateManager +``` +Command-line: +```CLI +dotnet add package CodeDead.UpdateManager +``` -Create a new *UpdateManager* object like this: +After the package has been added to your project, you can create a new *UpdateManager* object using the default constructor: ```C# -// Import statement -using CodeDead.UpdateManager.Classes; - // Initialize a new UpdateManager object UpdateManager updateManager = new UpdateManager(); ``` -You can check for updates like this: +It is important to set the platform of the current application. The *CurrentPlatform* property is used to determine which *Update* object is applicable to the running application: + ```C# -try -{ - // Retrieve the latest Update object from the remote location - Update update = updateManager.GetLatestVersion(); -} -catch (Exception ex) -{ - MessageBox.Show(ex.Message, "Application title", MessageBoxButton.OK, MessageBoxImage.Error); -} +// Set the CurrentPlatform property +updateManager.CurrentPlatform = "win32"; ``` -## Update types -Updates can be stored and parsed in two different formats: *JSON* or *XML*. By default, the *DataType* property will be set to *Json*. You can change the *DataType* property by setting the appropriate property on the *UpdateManager* object: + +In order to retrieve the latest version, you will also need to specify a remote location where the *PlatformUpdates* object is stored: +```C# +// Set the UpdateUrl property +updateManager.UpdateUrl = "https://codedead.com/Software/UpdateManager/example.json"; +``` + +After the *CurrentPlatform* and *UpdateUrl* properties have been set, you can check for updates by calling the *GetLatestVersion()* method of an *UpdateManager* object. An *Update* object will be returned, that you can then use to check for updates: +```C# +// Retrieve the latest Update object from the remote location +Update update = updateManager.GetLatestVersion(); +// Check if an update is available +bool updateAvailable = update.UpdateAvailable(Assembly.GetExecutingAssembly().GetName().Version); +``` + +## PlatformUpdates +*Update* objects can be retrieved for multiple platforms. The *PlatformUpdates* object is the root object that should be retrieved from a remote location. + +A *PlatformUpdates* object can be stored and parsed in two different formats: *JSON* or *XML*. By default, the *DataType* property will be set to *Json*. You can change the *DataType* property by setting the appropriate property on the *UpdateManager* object: ```C# -// Initialize a new UpdateManager object -UpdateManager updateManager = new UpdateManager(); // Set the data type of the remote Update object representation updateManager.DataType = DataType.Json; ``` ```C# -// Initialize a new UpdateManager object -UpdateManager updateManager = new UpdateManager(); // Set the data type of the remote Update object representation updateManager.DataType = DataType.Xml; ``` -### JSON Update example +### *PlatformUpdates* JSON example ```JSON { - "MajorVersion": 1, - "MinorVersion": 0, - "BuildVersion": 0, - "RevisionVersion": 0, - "UpdateUrl": "https://codedead.com/update.exe", - "InfoUrl": "https://codedead.com", - "UpdateInfo": "A new version is now available. Please click the download button to download version 1.0.0.0" + "PlatformUpdateList": [ + { + "PlatformName": "win32", + "Update": { + "MajorVersion": 2, + "MinorVersion": 0, + "BuildVersion": 0, + "RevisionVersion": 0, + "UpdateUrl": "https://codedead.com/example.exe", + "InfoUrl": "https://codedead.com", + "UpdateInfo": "A new version is now available.\nPlease click the download button to download version 2.0.0.0" + } + }, + { + "PlatformName": "linux", + "Update": { + "MajorVersion": 2, + "MinorVersion": 0, + "BuildVersion": 0, + "RevisionVersion": 0, + "UpdateUrl": "https://codedead.com/example.exe", + "InfoUrl": "https://codedead.com", + "UpdateInfo": "A new version is now available.\nPlease click the download button to download version 2.0.0.0" + } + } + ] } ``` -### XML Update example +### *PlatformUpdates* XML example ```XML - - 1 - 0 - 0 - 0 - https://example.com/update.exe - https://codedead.com/ - A new version is now available. Please click the download button to download version 1.0.0.0 - + + + + win32 + + 2 + 0 + 0 + 0 + https://codedead.com/Software/PK%20Finder/PK_setup.exe + https://codedead.com + A new version is now available. Please click the download button to download version 2.0.0.0 + + + + linux + + 2 + 0 + 0 + 0 + https://codedead.com/Software/PK%20Finder/PK_setup.exe + https://codedead.com + A new version is now available. Please click the download button to download version 2.0.0.0 + + + + ``` # About diff --git a/UpdateManager.Sample.WPF/App.xaml b/UpdateManager.Sample.WPF/App.xaml index 0c7be3d..1733365 100644 --- a/UpdateManager.Sample.WPF/App.xaml +++ b/UpdateManager.Sample.WPF/App.xaml @@ -1,7 +1,7 @@  + StartupUri="Windows/MainWindow.xaml"> diff --git a/UpdateManager.Sample.WPF/UpdateManager.Sample.WPF.csproj b/UpdateManager.Sample.WPF/UpdateManager.Sample.WPF.csproj index 118f208..e2e9b0b 100644 --- a/UpdateManager.Sample.WPF/UpdateManager.Sample.WPF.csproj +++ b/UpdateManager.Sample.WPF/UpdateManager.Sample.WPF.csproj @@ -35,6 +35,9 @@ 4 + + ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll + @@ -50,7 +53,7 @@ MSBuild:Compile Designer - + MSBuild:Compile Designer @@ -58,7 +61,7 @@ App.xaml Code - + MainWindow.xaml Code @@ -81,6 +84,7 @@ ResXFileCodeGenerator Resources.Designer.cs + SettingsSingleFileGenerator Settings.Designer.cs @@ -91,9 +95,14 @@ - {4e804ead-446a-47cc-b231-0a6255b867a3} + {2a14f99d-81a1-432d-80da-6471eda85aaa} UpdateManager + + {60ea74ad-ae82-4259-ba77-780c4bf9527d} + UpdateManager.WPF + + \ No newline at end of file diff --git a/UpdateManager.Sample.WPF/MainWindow.xaml b/UpdateManager.Sample.WPF/Windows/MainWindow.xaml similarity index 75% rename from UpdateManager.Sample.WPF/MainWindow.xaml rename to UpdateManager.Sample.WPF/Windows/MainWindow.xaml index ef7827f..16bdda5 100644 --- a/UpdateManager.Sample.WPF/MainWindow.xaml +++ b/UpdateManager.Sample.WPF/Windows/MainWindow.xaml @@ -1,10 +1,10 @@ - + Title="UpdateManager WPF Sample" Height="450" Width="800">