├── .gitignore ├── docs └── SampleApp1.2.zip ├── leetreveil.AutoUpdate.sln ├── libs ├── dontnetzipreduced │ └── Ionic.Zip.Reduced.dll └── nunit │ └── nunit.framework.dll ├── src ├── app │ ├── leetreveil.AutoUpdate.Framework │ │ ├── AppcastReader.cs │ │ ├── FileDownloader.cs │ │ ├── IUpdateFeedSource.cs │ │ ├── Progress.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── Update.cs │ │ ├── UpdateManager.cs │ │ ├── UpdateStarter.cs │ │ ├── app.config │ │ └── leetreveil.AutoUpdate.Framework.csproj │ ├── leetreveil.AutoUpdate.SampleApp │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── MainWindow.xaml │ │ ├── MainWindow.xaml.cs │ │ ├── Properties │ │ │ ├── AssemblyInfo.cs │ │ │ ├── Resources.Designer.cs │ │ │ ├── Resources.resx │ │ │ ├── Settings.Designer.cs │ │ │ └── Settings.settings │ │ ├── Resources │ │ │ ├── ltupdater.exe │ │ │ └── updater.exe │ │ ├── UpdateWindow.xaml │ │ ├── UpdateWindow.xaml.cs │ │ ├── app.config │ │ ├── leetreveil.AutoUpdate.SampleApp.csproj │ │ └── sampleappupdatefeed.xml │ └── leetreveil.AutoUpdate.Updater │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── AppStart.cs │ │ ├── Assets │ │ ├── updateicon.ico │ │ └── updateicon.png │ │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ │ ├── ZipFileExtractor.cs │ │ ├── app.config │ │ ├── app.manifest │ │ ├── leetreveil.AutoUpdate.Updater.csproj │ │ └── updateicon.ico └── test │ └── leetreveil.AutoUpdate.Tests │ ├── Integration │ └── FileDownloaderTests.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── Samples │ └── zunesocialtagger.xml │ ├── Unit │ └── AppcastReaderTests.cs │ └── leetreveil.AutoUpdate.Tests.csproj └── tools └── ilmerge └── ilmerge.exe /.gitignore: -------------------------------------------------------------------------------- 1 | *.dep 2 | *.aps 3 | *.vbw 4 | *.suo 5 | *.obj 6 | *.plg 7 | *.bsc 8 | *.ilk 9 | *.exp 10 | *.sbr 11 | *.opt 12 | *.pdb 13 | *.idb 14 | *.pch 15 | *.res 16 | *.user 17 | *\obj 18 | *\bin 19 | *\Debug 20 | *\Release 21 | *\Resharp* 22 | *\_ReSharp* 23 | Thumbs.db 24 | *.ncb 25 | *.suo 26 | *.cache -------------------------------------------------------------------------------- /docs/SampleApp1.2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leetreveil/.NET-Auto-Update/fbec9ece6d8685cbf45cbb435144fe584bc3ee01/docs/SampleApp1.2.zip -------------------------------------------------------------------------------- /leetreveil.AutoUpdate.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{BDD7694F-9B8D-45B1-B75E-3901BC6F04DD}" 5 | EndProject 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{69829CE6-2507-4208-83A0-4AFF3773DC69}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "leetreveil.AutoUpdate.Tests", "src\test\leetreveil.AutoUpdate.Tests\leetreveil.AutoUpdate.Tests.csproj", "{2742ABE7-977D-4989-B12A-992A50B28E2F}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "leetreveil.AutoUpdate.Updater", "src\app\leetreveil.AutoUpdate.Updater\leetreveil.AutoUpdate.Updater.csproj", "{7D4D18D4-DBD2-4ADC-9D82-397D6C5E9F40}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "leetreveil.AutoUpdate.SampleApp", "src\app\leetreveil.AutoUpdate.SampleApp\leetreveil.AutoUpdate.SampleApp.csproj", "{D4321517-F941-4B1C-A9F7-9F63F5B86EE8}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "leetreveil.AutoUpdate.Framework", "src\app\leetreveil.AutoUpdate.Framework\leetreveil.AutoUpdate.Framework.csproj", "{5C07EBDF-D43F-4BE9-B560-D7A443C0EDCE}" 15 | EndProject 16 | Global 17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 18 | Debug|Any CPU = Debug|Any CPU 19 | Release|Any CPU = Release|Any CPU 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {2742ABE7-977D-4989-B12A-992A50B28E2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {2742ABE7-977D-4989-B12A-992A50B28E2F}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {2742ABE7-977D-4989-B12A-992A50B28E2F}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {2742ABE7-977D-4989-B12A-992A50B28E2F}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {7D4D18D4-DBD2-4ADC-9D82-397D6C5E9F40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {7D4D18D4-DBD2-4ADC-9D82-397D6C5E9F40}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {7D4D18D4-DBD2-4ADC-9D82-397D6C5E9F40}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {7D4D18D4-DBD2-4ADC-9D82-397D6C5E9F40}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {D4321517-F941-4B1C-A9F7-9F63F5B86EE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {D4321517-F941-4B1C-A9F7-9F63F5B86EE8}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {D4321517-F941-4B1C-A9F7-9F63F5B86EE8}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {D4321517-F941-4B1C-A9F7-9F63F5B86EE8}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {5C07EBDF-D43F-4BE9-B560-D7A443C0EDCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {5C07EBDF-D43F-4BE9-B560-D7A443C0EDCE}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {5C07EBDF-D43F-4BE9-B560-D7A443C0EDCE}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {5C07EBDF-D43F-4BE9-B560-D7A443C0EDCE}.Release|Any CPU.Build.0 = Release|Any CPU 38 | EndGlobalSection 39 | GlobalSection(SolutionProperties) = preSolution 40 | HideSolutionNode = FALSE 41 | EndGlobalSection 42 | GlobalSection(NestedProjects) = preSolution 43 | {7D4D18D4-DBD2-4ADC-9D82-397D6C5E9F40} = {BDD7694F-9B8D-45B1-B75E-3901BC6F04DD} 44 | {D4321517-F941-4B1C-A9F7-9F63F5B86EE8} = {BDD7694F-9B8D-45B1-B75E-3901BC6F04DD} 45 | {5C07EBDF-D43F-4BE9-B560-D7A443C0EDCE} = {BDD7694F-9B8D-45B1-B75E-3901BC6F04DD} 46 | {2742ABE7-977D-4989-B12A-992A50B28E2F} = {69829CE6-2507-4208-83A0-4AFF3773DC69} 47 | EndGlobalSection 48 | EndGlobal 49 | -------------------------------------------------------------------------------- /libs/dontnetzipreduced/Ionic.Zip.Reduced.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leetreveil/.NET-Auto-Update/fbec9ece6d8685cbf45cbb435144fe584bc3ee01/libs/dontnetzipreduced/Ionic.Zip.Reduced.dll -------------------------------------------------------------------------------- /libs/nunit/nunit.framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leetreveil/.NET-Auto-Update/fbec9ece6d8685cbf45cbb435144fe584bc3ee01/libs/nunit/nunit.framework.dll -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.Framework/AppcastReader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Xml; 4 | 5 | namespace leetreveil.AutoUpdate.Framework 6 | { 7 | public class AppcastReader : IUpdateFeedSource 8 | { 9 | public List Read(string url) 10 | { 11 | var updates = new List(); 12 | 13 | var document = new XmlDocument(); 14 | document.Load(url); 15 | 16 | var nsManager = new XmlNamespaceManager(document.NameTable); 17 | nsManager.AddNamespace("appcast", "http://www.adobe.com/xml-namespaces/appcast/1.0"); 18 | 19 | var nodes = document.SelectNodes("/rss/channel/item"); 20 | 21 | for (int i = 0; i < nodes.Count; i++) 22 | { 23 | var node = nodes.Item(i); 24 | 25 | var titleNode = node.SelectSingleNode("title"); 26 | var versionNode = node.SelectSingleNode("appcast:version", nsManager); 27 | var enclosureNode = node.SelectSingleNode("enclosure"); 28 | var fileUrlNode = enclosureNode.Attributes["url"]; 29 | var fileLengthNode = enclosureNode.Attributes["length"]; 30 | 31 | var update = new Update 32 | { 33 | Title = titleNode.InnerText, 34 | Version = new Version(versionNode.InnerText), 35 | FileUrl = fileUrlNode.Value, 36 | FileLength = Convert.ToInt64(fileLengthNode.Value) 37 | }; 38 | 39 | updates.Add(update); 40 | } 41 | return updates; 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.Framework/FileDownloader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | 4 | namespace leetreveil.AutoUpdate.Framework 5 | { 6 | public class FileDownloader 7 | { 8 | private readonly Uri _uri; 9 | 10 | public FileDownloader(string url) 11 | { 12 | _uri = new Uri(url); 13 | } 14 | 15 | public byte[] Download() 16 | { 17 | using (var client = new WebClient()) 18 | return client.DownloadData(_uri); 19 | } 20 | 21 | public void DownloadAsync(Action callback) 22 | { 23 | using (var client = new WebClient()) 24 | { 25 | client.DownloadDataCompleted += (sender, args) => callback(args.Result); 26 | client.DownloadDataAsync(_uri); 27 | } 28 | } 29 | 30 | public void DownloadAsync(Action finishedCallback, Action progressChangedCallback) 31 | { 32 | using (var client = new WebClient()) 33 | { 34 | client.DownloadProgressChanged += (sender, args) => 35 | progressChangedCallback(new Progress { Current = args.BytesReceived, Total = args.TotalBytesToReceive }); 36 | 37 | client.DownloadDataCompleted += (sender, args) => finishedCallback(args.Result); 38 | client.DownloadDataAsync(_uri); 39 | } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.Framework/IUpdateFeedSource.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace leetreveil.AutoUpdate.Framework 4 | { 5 | public interface IUpdateFeedSource 6 | { 7 | List Read(string url); 8 | } 9 | } -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.Framework/Progress.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace leetreveil.AutoUpdate.Framework 6 | { 7 | public class Progress 8 | { 9 | public long Current { get; set; } 10 | public long Total { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.Framework/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("leetreveil.AutoUpdate")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("leetreveil.AutoUpdate")] 13 | [assembly: AssemblyCopyright("Copyright © 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("563ca010-168f-46c0-a12d-219e3f48dc41")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.1.0")] 36 | [assembly: AssemblyFileVersion("1.0.1.0")] 37 | -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.Framework/Update.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace leetreveil.AutoUpdate.Framework 4 | { 5 | public class Update 6 | { 7 | public string FileUrl { get; set; } 8 | public Version Version { get; set; } 9 | public string Title { get; set; } 10 | public long FileLength { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.Framework/UpdateManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | using System; 4 | using System.Reflection; 5 | using System.Threading; 6 | 7 | namespace leetreveil.AutoUpdate.Framework 8 | { 9 | public sealed class UpdateManager 10 | { 11 | #region Singleton Stuff 12 | 13 | private static readonly UpdateManager instance = new UpdateManager(); 14 | 15 | static UpdateManager(){} 16 | 17 | private UpdateManager() {} 18 | 19 | public static UpdateManager Instance 20 | { 21 | get { return instance; } 22 | } 23 | 24 | #endregion 25 | 26 | public byte[] UpdateExeBinary { get; set; } 27 | public string AppFeedUrl { get; set; } 28 | public string UpdateExePath { get; set; } 29 | public Update NewUpdate { get; private set; } 30 | public byte[] UpdateData { get; private set; } 31 | 32 | /// 33 | /// Removes the updater executable from the directory its in and fails silently 34 | /// 35 | public void CleanUp() 36 | { 37 | if (String.IsNullOrEmpty(UpdateExePath)) 38 | throw new ArgumentException("The UpdateExePath has not been set"); 39 | 40 | try 41 | { 42 | //clean up updater after it has been extracted (if it has) 43 | if (File.Exists(UpdateExePath)) 44 | File.Delete(UpdateExePath); 45 | } 46 | catch{} 47 | } 48 | 49 | /// 50 | /// Checks for the latest update and sets the NewUpdate property if one is available 51 | /// 52 | /// 53 | public bool CheckForUpdate() 54 | { 55 | if (String.IsNullOrEmpty(AppFeedUrl)) 56 | throw new ArgumentException("The AppFeedUrl has not been set"); 57 | 58 | List results = new AppcastReader().Read(AppFeedUrl); 59 | 60 | return GetLatestUpdateFromUpdates(results); 61 | } 62 | 63 | private bool GetLatestUpdateFromUpdates(List results) 64 | { 65 | if (results.Count <= 0) return false; 66 | 67 | Update update = results[0]; 68 | 69 | var assemblyVersion = Assembly.GetEntryAssembly().GetName().Version; 70 | 71 | if (update.Version > assemblyVersion) 72 | { 73 | NewUpdate = update; 74 | return true; 75 | } 76 | 77 | return false; 78 | } 79 | 80 | public bool CheckForUpdate(IUpdateFeedSource updateReader) 81 | { 82 | if (String.IsNullOrEmpty(AppFeedUrl)) 83 | throw new ArgumentException("The AppFeedUrl has not been set"); 84 | 85 | List results = updateReader.Read(this.AppFeedUrl); 86 | 87 | return GetLatestUpdateFromUpdates(results); 88 | } 89 | 90 | public void CheckForUpdateAsync(Action callback) 91 | { 92 | ThreadPool.QueueUserWorkItem(_ => CheckForUpdate()); 93 | } 94 | 95 | public bool DownloadUpdate() 96 | { 97 | FileDownloader fileDownloader = GetFileDownloader(); 98 | 99 | byte[] update = fileDownloader.Download(); 100 | 101 | if (update == null) 102 | return false; 103 | 104 | if (update.Length == 0) 105 | return false; 106 | 107 | this.UpdateData = update; 108 | 109 | return true; 110 | } 111 | 112 | public void DownloadUpdateAsync(Action finishedCallback) 113 | { 114 | FileDownloader fileDownloader = GetFileDownloader(); 115 | 116 | fileDownloader.DownloadAsync(downloadedData => 117 | { 118 | //validate that the downloaded data is actually valid and not erroneous 119 | this.UpdateData = downloadedData; 120 | finishedCallback(true); 121 | }); 122 | } 123 | 124 | public void DownloadUpdateAsync(Action finishedCallback, Action progressPercentageCallback) 125 | { 126 | FileDownloader fileDownloader = GetFileDownloader(); 127 | 128 | fileDownloader.DownloadAsync(downloadedData => 129 | { 130 | //TODO: validate that the downloaded data is actually valid and not erroneous 131 | this.UpdateData = downloadedData; 132 | finishedCallback(true); 133 | }, 134 | (progress) => progressPercentageCallback((int)(100 * (progress.Current / progress.Total)))); 135 | } 136 | 137 | private FileDownloader GetFileDownloader() 138 | { 139 | if (NewUpdate == null) 140 | throw new ArgumentException("NewUpdate has not been set"); 141 | 142 | if (String.IsNullOrEmpty(NewUpdate.FileUrl)) 143 | throw new ArgumentException("NewUpdate.FileUrl is not valid"); 144 | 145 | return new FileDownloader(this.NewUpdate.FileUrl); 146 | } 147 | 148 | /// 149 | /// Starts the updater executable and sends update data to it 150 | /// 151 | public void ApplyUpdate() 152 | { 153 | if (String.IsNullOrEmpty(UpdateExePath)) 154 | throw new ArgumentException("The UpdateExePath has not been set"); 155 | 156 | if (UpdateExeBinary == null || UpdateExeBinary.Length == 0) 157 | throw new ArgumentException("UpdateExeBinary has not been set"); 158 | 159 | new UpdateStarter(UpdateExePath, UpdateExeBinary, UpdateData).Start(); 160 | } 161 | } 162 | } -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.Framework/UpdateStarter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.IO; 4 | using System.Net; 5 | using System.Net.Sockets; 6 | 7 | namespace leetreveil.AutoUpdate.Framework 8 | { 9 | /// 10 | /// Downloads and starts the update process 11 | /// 12 | public class UpdateStarter 13 | { 14 | private readonly string _updaterExeExeShouldBeCreated; 15 | private readonly byte[] _updateExe; 16 | private readonly byte[] _updateData; 17 | 18 | public UpdateStarter(string pathWhereUpdateExeShouldBeCreated, byte[] updateExe, byte[] updateData) 19 | { 20 | _updaterExeExeShouldBeCreated = pathWhereUpdateExeShouldBeCreated; 21 | _updateExe = updateExe; 22 | _updateData = updateData; 23 | } 24 | 25 | public void Start() 26 | { 27 | ExtractExecutableFromResource(); //take the update executable and extract it to the path where it should be created 28 | 29 | try 30 | { 31 | //TODO: allow custom port or randomise instead of using a default 32 | Process.Start(_updaterExeExeShouldBeCreated, String.Format(@"""{0}""", Process.GetCurrentProcess().MainModule.FileName)); 33 | SendUpdatePackageToUpdateExecutable(_updateData); 34 | } 35 | catch (Exception e) 36 | { 37 | Console.WriteLine(e); 38 | } 39 | } 40 | 41 | private static void SendUpdatePackageToUpdateExecutable(byte[] fileData) 42 | { 43 | var server = new TcpListener(IPAddress.Any, 13001); 44 | server.Start(); 45 | 46 | //wait for the updater to start and attempt to connect 47 | TcpClient client = server.AcceptTcpClient(); 48 | 49 | using (NetworkStream stream = client.GetStream()) 50 | { 51 | var fileDataLength = BitConverter.GetBytes(fileData.Length); 52 | //send the size of the update package as the first 4 bytes 53 | stream.Write(fileDataLength, 0, 4); 54 | //send the rest of the file 55 | stream.Write(fileData, 0, fileData.Length); 56 | } 57 | 58 | // Shutdown connection and stop listening 59 | client.Close(); 60 | server.Stop(); 61 | } 62 | 63 | private void ExtractExecutableFromResource() 64 | { 65 | //store the updater temporarily in the appdata folder 66 | using (var writer = new BinaryWriter(File.Open(_updaterExeExeShouldBeCreated, FileMode.Create))) 67 | writer.Write(_updateExe); 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.Framework/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.Framework/leetreveil.AutoUpdate.Framework.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {5C07EBDF-D43F-4BE9-B560-D7A443C0EDCE} 9 | Library 10 | Properties 11 | leetreveil.AutoUpdate.Framework 12 | leetreveil.AutoUpdate.Framework 13 | v2.0 14 | 512 15 | 16 | 17 | 3.5 18 | 19 | 20 | 21 | 22 | true 23 | full 24 | false 25 | bin\Debug\ 26 | DEBUG;TRACE 27 | prompt 28 | 4 29 | 30 | 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 63 | -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.SampleApp/App.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.SampleApp/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace leetreveil.AutoUpdate.SampleApp 4 | { 5 | /// 6 | /// Interaction logic for App.xaml 7 | /// 8 | public partial class App : Application 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.SampleApp/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.SampleApp/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Windows; 4 | using leetreveil.AutoUpdate.Framework; 5 | using Path=System.IO.Path; 6 | 7 | namespace leetreveil.AutoUpdate.SampleApp 8 | { 9 | /// 10 | /// Interaction logic for MainWindow.xaml 11 | /// 12 | public partial class MainWindow : Window 13 | { 14 | public string AppVersion { get { return Assembly.GetExecutingAssembly().GetName().Version.ToString(); } } 15 | private readonly string updaterPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), 16 | "ltupdater.exe"); 17 | 18 | public MainWindow() 19 | { 20 | InitializeComponent(); 21 | this.DataContext = this; 22 | } 23 | 24 | private void Window_Loaded(object sender, RoutedEventArgs e) 25 | { 26 | UpdateManager updManager = UpdateManager.Instance; 27 | 28 | //update configuration 29 | updManager.UpdateExePath = updaterPath; 30 | updManager.AppFeedUrl = "sampleappupdatefeed.xml"; 31 | updManager.UpdateExeBinary = Properties.Resources.ltupdater; 32 | 33 | //always clean up at the beginning of the exe because we cant do it at the end 34 | updManager.CleanUp(); 35 | 36 | if (updManager.CheckForUpdate()) 37 | new UpdateWindow(updManager).Show(); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.SampleApp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("leetreveil.AutoUpdate.SampleApp")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("leetreveil.AutoUpdate.SampleApp")] 15 | [assembly: AssemblyCopyright("Copyright © 2010")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.SampleApp/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.1 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace leetreveil.AutoUpdate.SampleApp.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("leetreveil.AutoUpdate.SampleApp.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | internal static byte[] ltupdater { 64 | get { 65 | object obj = ResourceManager.GetObject("ltupdater", resourceCulture); 66 | return ((byte[])(obj)); 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.SampleApp/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\Resources\ltupdater.exe;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 123 | 124 | -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.SampleApp/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.1 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace leetreveil.AutoUpdate.SampleApp.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.SampleApp/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.SampleApp/Resources/ltupdater.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leetreveil/.NET-Auto-Update/fbec9ece6d8685cbf45cbb435144fe584bc3ee01/src/app/leetreveil.AutoUpdate.SampleApp/Resources/ltupdater.exe -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.SampleApp/Resources/updater.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leetreveil/.NET-Auto-Update/fbec9ece6d8685cbf45cbb435144fe584bc3ee01/src/app/leetreveil.AutoUpdate.SampleApp/Resources/updater.exe -------------------------------------------------------------------------------- /src/app/leetreveil.AutoUpdate.SampleApp/UpdateWindow.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | An update for SampleApp is available. It is reccomended that you install it as soon as possible. 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |