{"id":504,"date":"2009-12-30T22:20:29","date_gmt":"2009-12-30T21:20:29","guid":{"rendered":"http:\/\/www.lightsoft.se\/?p=504"},"modified":"2009-12-30T22:21:08","modified_gmt":"2009-12-30T21:21:08","slug":"autoupgrade-0-5-1-c","status":"publish","type":"post","link":"https:\/\/www.lightsoftai.com\/?p=504","title":{"rendered":"AutoUpgrade 0.5.1 released [C#]"},"content":{"rendered":"<div class=\"right\"><a href=\"http:\/\/www.lightsoft.se\/_lightsoft\/wp-content\/uploads\/2009\/12\/Upgrade_delivery_0.5.1.zip\" count=\"1\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.lightsoft.se\/_lightsoft\/wp-content\/uploads\/2009\/12\/download-button-150x150.jpg\" alt=\"AutoUpgrade 0.5.1\" title=\"AutoUpgrade 0.5.1\" width=\"100\" height=\"100\" class=\"alignleft size-thumbnail wp-image-397\" \/><\/a><\/div>\n<p><span style=\"color: #339966;\"><strong>Version:<\/strong> <span style=\"color: #000000;\">0.5.1<\/span><br \/>\n<span style=\"color: #339966;\"><strong>License:<\/strong> <span style=\"color: #000000;\">CC<\/span><\/span><br \/>\n<span style=\"color: #339966;\"><strong>Requirements:<\/strong><span style=\"color: #000000;\"> Win (With mono possible for Linux aswell)<\/span><\/span><br \/>\n<span style=\"color: #339966;\"><strong>Limitations:<\/strong> <span style=\"color: #000000;\">CC License (Free of use\/change for personal use)<\/span><\/span><br \/>\n<span style=\"color: #339966;\"><strong>Code:<\/strong><span style=\"color: #000000;\"> Csharp<\/span><\/span><\/span><br \/>\n<a href=\"http:\/\/creativecommons.org\/about\/licenses\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.lightsoft.se\/_lightsoft\/wp-content\/uploads\/2009\/12\/by-nc-sa_resize.png\" alt=\"\" title=\"by-nc-sa_resize\" width=\"121\" height=\"42\" class=\"alignnone size-full wp-image-427\" \/><\/a><\/p>\n<h4>AutoUpgrade<\/h4>\n<hr>\n<p>With this project, that is mearged with the main application that should be released, it will be possible to check if new upgrades are available. Upgrades will be download on a separately thread and be signalled when the actually upgrade is possible to perform.<\/p>\n<p>When upgrade should be done with the new files, the main application should call the AutoUpdate.exe file as process and then self shutdown, and the files in the compressed file will be extract over the ordinary files. After the decompressing the main applications .exe file will be executed again (sent as parameter).<\/p>\n<p>There are two xml files that should be used as configuration files. The one used with the AutoUpdate.exe, with name &#8220;AutoUpdate.xml&#8221;, located at the same path. And the second &#8220;update.xml&#8221; (in this example below it is called &#8220;OrdinaryApp.xml&#8221;) that is on a public server for the application to read, and look for new upgrades and where to find the upgrade files.<\/p>\n<p>Below are some small example, but otherwise take a look at the example code provided with the source.<br \/>\n<!--more--><br \/>\n<\/p>\n<h4>Example of AutoUpgrade.xml<\/h4>\n<p>[sourcecode language=&#8221;csharp&#8221;]<br \/>\n<?xml version=\"1.0\" encoding=\"utf-8\"?><br \/>\n<xml><br \/>\n  <upgrade>true<\/upgrade><br \/>\n  <homepage>http:\/\/www.lightsoft.se<\/homepage><br \/>\n  <upgradexml>http:\/\/www.lightsoft.se\/_software_updates\/OrdinaryApp.xml<\/upgradexml><br \/>\n<\/xml><br \/>\n[\/sourcecode]<\/p>\n<p><\/p>\n<h4>Example of OrdinaryApp.xml (on server)<\/h4>\n<p>[sourcecode language=&#8221;csharp&#8221;]<br \/>\n<?xml version=\"1.0\" encoding=\"utf-8\" ?><br \/>\n<xml><br \/>\n  <version>1.0.3.0<\/version><br \/>\n  <urlupdate>http:\/\/www.lightsoft.se\/_software_updates\/UpdateTestApp\/OrdinaryApp.zip<\/urlupdate><br \/>\n  <urlinstall>http:\/\/www.lightsoft.se\/_software_updates\/UpdateTestApp\/OrdinaryApp.msi<\/urlinstall><br \/>\n<\/xml><br \/>\n[\/sourcecode]<\/p>\n<p><\/p>\n<h4>Small example of code<\/h4>\n<p>[sourcecode language=&#8221;csharp&#8221;]<br \/>\npublic void checkForUpgrades(){<br \/>\n  \/\/ Send the callers Version to the AutoUpgrader, it is used to check for upgrades.<br \/>\n  AutoUpgrader au = new AutoUpgrader(Assembly.GetExecutingAssembly().GetName().Version);<br \/>\n  \/\/ Check if there are upgrades against the xml file on the public server<br \/>\n  if (au.existsUpgrades()){<br \/>\n    \/\/ Listening on events when downloading files are done.<br \/>\n    AutoUpgrader.PossibleToUpgradeEvent += new AutoUpgrader.PossibleToUpgrade(PossibleToUpgradeEvent);<br \/>\n    \/\/ Start downloading file<br \/>\n    au.startDownloadUpgrades();<br \/>\n  }<br \/>\n}<br \/>\nprivate void PossibleToUpgradeEvent()<br \/>\n{<br \/>\n  Console.Out.WriteLine(&#8220;PossibleToUpgradeEvent&#8221;);<\/p>\n<p>  \/\/ We should trigger a process with the AutoUpgrade.exe<br \/>\n  ProcessStartInfo upgradeProcess = new ProcessStartInfo(&#8220;AutoUpgrade.exe&#8221;);<br \/>\n  \/\/ Need to give argument of what the Main programfile is to execute after upgrade, will restart the main app when finished upgrading.<br \/>\n  upgradeProcess.Arguments = getExecutorExeFile();<br \/>\n  upgradeProcess.WorkingDirectory = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);<br \/>\n  \/\/ Start AutoUpgrade.exe<br \/>\n  Process.Start(upgradeProcess);<br \/>\n  Environment.Exit(0);<br \/>\n}<\/p>\n<p>\/\/ Get the OrdinaryApp.exe file<br \/>\npublic string getExecutorExeFile()<br \/>\n{<br \/>\n  return System.IO.Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().Location);<br \/>\n}<\/p>\n<p>[\/sourcecode]<\/p>\n<p>\nIt is possible to listener to events from the AutoUpgrade.exe when using it as a instance<br \/>\n[sourcecode language=&#8221;csharp&#8221;]<br \/>\n  AutoUpgrader.NewVersionToDownloadEvent += new AutoUpgrader.NewVersionToDownload(NewVersionToDownloadEvent);<br \/>\n  AutoUpgrader.PossibleToUpgradeEvent += new AutoUpgrader.PossibleToUpgrade(PossibleToUpgradeEvent);<br \/>\n[\/sourcecode]<br \/>\n<\/p>\n<p><strong>Download app: <\/strong><a href=\"http:\/\/www.lightsoft.se\/_lightsoft\/wp-content\/uploads\/2009\/12\/Upgrade_delivery_0.5.1.zip\" count=\"1\">AutoUpgrade_delivery_0.5.1<\/a><br \/>\n<strong>Download Src: <\/strong><a href=\"http:\/\/www.lightsoft.se\/_lightsoft\/wp-content\/uploads\/2009\/12\/Upgrade_src_0.5.1.zip\" count=\"1\">AutoUpgrade_src_0.5.1<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Version: 0.5.1 License: CC Requirements: Win (With mono possible for Linux aswell) Limitations: CC License (Free of use\/change for personal use) Code: Csharp AutoUpgrade With this project, that is mearged with the main application that should be released, it will be possible to check if new upgrades are available. Upgrades will be download on a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6,5],"tags":[45,32,33,44],"class_list":["post-504","post","type-post","status-publish","format-standard","hentry","category-applications","category-c-csharp","category-coding","tag-development","tag-download","tag-free-software","tag-upgrade"],"_links":{"self":[{"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=\/wp\/v2\/posts\/504","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=504"}],"version-history":[{"count":6,"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=\/wp\/v2\/posts\/504\/revisions"}],"predecessor-version":[{"id":510,"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=\/wp\/v2\/posts\/504\/revisions\/510"}],"wp:attachment":[{"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lightsoftai.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}