-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
76 lines (61 loc) · 1.87 KB
/
Program.cs
File metadata and controls
76 lines (61 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
using System.Linq;
using System.Reflection;
using NuGet;
using Squirrel;
namespace SquirrelTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Squirrel Tester v.{0}", Assembly.GetExecutingAssembly().GetName().Version.Major);
Update();
Console.WriteLine("Press any key to exit...");
Console.ReadLine();
}
private static void Update()
{
SemanticVersion newVersion = null;
var updated = false;
using (var mgr = new UpdateManager("C:\\Projects\\SquirrelTest\\Releases"))
{
var updateInfo = mgr.CheckForUpdate().Result;
var currentVersion = updateInfo.CurrentlyInstalledVersion.Version;
Console.WriteLine("Current version: {0}", currentVersion);
if (updateInfo.ReleasesToApply.Any())
{
newVersion = updateInfo.FutureReleaseEntry.Version;
Console.WriteLine("New version: {0}", newVersion);
Console.Write("New version available. Install? (y/n) ");
if (Console.ReadKey().Key == ConsoleKey.Y)
{
Console.WriteLine();
Console.WriteLine("Beginning to download...");
mgr.DownloadReleases(updateInfo.ReleasesToApply).Wait();
Console.WriteLine("... done downloading.");
Console.WriteLine("Beginning to apply release...");
mgr.ApplyReleases(updateInfo).Wait();
Console.WriteLine("... done applying.");
Console.WriteLine("Creating uninstaller...");
mgr.CreateUninstallerRegistryEntry().Wait();
Console.WriteLine("... done creating uninstaller.");
updated = true;
}
}
}
if (updated && newVersion != null)
{
Console.WriteLine();
Console.Write("Version {0} is now applied. Restart application? (y/n)",
newVersion);
if (Console.ReadKey().Key == ConsoleKey.Y)
{
Console.WriteLine();
Console.WriteLine("Initiating restart...");
UpdateManager.RestartApp();
}
}
}
}
}