ApplicationsC# /CSharpCoding

AutoUpgrade 0.5.1 released [C#]

AutoUpgrade 0.5.1

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 separately thread and be signalled when the actually upgrade is possible to perform.

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).

There are two xml files that should be used as configuration files. The one used with the AutoUpdate.exe, with name “AutoUpdate.xml”, located at the same path. And the second “update.xml” (in this example below it is called “OrdinaryApp.xml”) that is on a public server for the application to read, and look for new upgrades and where to find the upgrade files.

Below are some small example, but otherwise take a look at the example code provided with the source.

Example of AutoUpgrade.xml

[sourcecode language=”csharp”]


true
http://www.lightsoft.se
http://www.lightsoft.se/_software_updates/OrdinaryApp.xml

[/sourcecode]

Example of OrdinaryApp.xml (on server)

[sourcecode language=”csharp”]


1.0.3.0
http://www.lightsoft.se/_software_updates/UpdateTestApp/OrdinaryApp.zip
http://www.lightsoft.se/_software_updates/UpdateTestApp/OrdinaryApp.msi

[/sourcecode]

Small example of code

[sourcecode language=”csharp”]
public void checkForUpgrades(){
// Send the callers Version to the AutoUpgrader, it is used to check for upgrades.
AutoUpgrader au = new AutoUpgrader(Assembly.GetExecutingAssembly().GetName().Version);
// Check if there are upgrades against the xml file on the public server
if (au.existsUpgrades()){
// Listening on events when downloading files are done.
AutoUpgrader.PossibleToUpgradeEvent += new AutoUpgrader.PossibleToUpgrade(PossibleToUpgradeEvent);
// Start downloading file
au.startDownloadUpgrades();
}
}
private void PossibleToUpgradeEvent()
{
Console.Out.WriteLine(“PossibleToUpgradeEvent”);

// We should trigger a process with the AutoUpgrade.exe
ProcessStartInfo upgradeProcess = new ProcessStartInfo(“AutoUpgrade.exe”);
// Need to give argument of what the Main programfile is to execute after upgrade, will restart the main app when finished upgrading.
upgradeProcess.Arguments = getExecutorExeFile();
upgradeProcess.WorkingDirectory = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
// Start AutoUpgrade.exe
Process.Start(upgradeProcess);
Environment.Exit(0);
}

// Get the OrdinaryApp.exe file
public string getExecutorExeFile()
{
return System.IO.Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().Location);
}

[/sourcecode]

It is possible to listener to events from the AutoUpgrade.exe when using it as a instance
[sourcecode language=”csharp”]
AutoUpgrader.NewVersionToDownloadEvent += new AutoUpgrader.NewVersionToDownload(NewVersionToDownloadEvent);
AutoUpgrader.PossibleToUpgradeEvent += new AutoUpgrader.PossibleToUpgrade(PossibleToUpgradeEvent);
[/sourcecode]

Download app: AutoUpgrade_delivery_0.5.1
Download Src: AutoUpgrade_src_0.5.1

Leave a Reply

Your email address will not be published. Required fields are marked *