-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Steve Shortt edited this page Oct 7, 2017
·
3 revisions
class Program
{
static Updater _updater = null;
static void Main(string[] args)
{
_updater = new Updater( new UpdaterSettings()
{
DownloadFolder = "patches",
RuntimeExe = "myexe.exe",
ServiceName = "W32Time",
StartProcessAfterInstall = true,
UpdateConfigUri = "http://foo.bar/updates/updateconfig.xml",
WaitForExitMillseconds = 30000
} );
_updater.PropertyChanged += new PropertyChangedEventHandler( updater_PropertyChanged );
_updater.InitializePatchStatus();
bool runUpdate = false;
if( _updater.Status.PatchIsValid )
if( !_updater.Status.PatchIsMandatory )
{
Console.Write( "An update is available and ready to install. Would you like to install now? " );
char response = Convert.ToChar( Console.Read() );
runUpdate = response == 'y';
}
else
runUpdate = true;
if( runUpdate )
Task.Run( () =>
{
_updater.InstallExistingPatches( _updater.Status.ExeInfo.Name, _updater.Status.ExeInfo.FolderPath );
} ).Wait();
Console.WriteLine( "Update complete." );
}
static void updater_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if( e.PropertyName == "LogMessage" )
Console.WriteLine( "{0}\t{1}", _updater.LogMessage.TimeStamp, _updater.LogMessage.Message );
}
}
<UpdateConfig>
<CurrentVersion>10.2.3.4</CurrentVersion>
<IsMandatory>false</IsMandatory>
<LastMandatoryVersion>1.2.3.0</LastMandatoryVersion>
<PatchUri>http://foo.bar/updates/v10.2.3.4.zip</PatchUri>
<PatchSizeBytes>8675309</PatchSizeBytes>
</UpdateConfig>