Implement check for updates

This commit is contained in:
Paul Betts
2014-08-27 14:44:41 -07:00
parent 206cc01f3a
commit 347357290a
4 changed files with 2145 additions and 1 deletions

View File

@@ -59,6 +59,9 @@ namespace Squirrel.Update
case UpdateAction.Uninstall:
Uninstall().Wait();
break;
case UpdateAction.Download:
Console.WriteLine(Download(target).Result);
break;
case UpdateAction.Update:
Update(target).Wait();
break;
@@ -103,6 +106,18 @@ namespace Squirrel.Update
// TODO: Update our installer entry
}
public static async Task<string> Download(string updateUrl, string appName = null)
{
appName = appName ?? getAppNameFromDirectory();
using (var mgr = new UpdateManager(updateUrl, appName, FrameworkVersion.Net45)) {
var updateInfo = await mgr.CheckForUpdate(progress: x => Console.WriteLine(x / 3));
await mgr.DownloadReleases(updateInfo.ReleasesToApply, x => Console.WriteLine(33 + x / 3));
return SimpleJson.SerializeObject(updateInfo);
}
}
public static async Task Uninstall(string appName = null)
{
appName = appName ?? getAppNameFromDirectory();

File diff suppressed because it is too large Load Diff

View File

@@ -7,7 +7,7 @@
<ProjectGuid>{1EEBACBC-6982-4696-BD4E-899ED0AC6CD2}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Update</RootNamespace>
<RootNamespace>Squirrel.Update</RootNamespace>
<AssemblyName>Update</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
@@ -66,6 +66,7 @@
<Compile Include="Mono.Options\Options.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SimpleJson.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />

View File

@@ -4,5 +4,6 @@
<package id="Mono.Cecil" version="0.9.5.4" targetFramework="net45" />
<package id="Mono.Options" version="1.1" targetFramework="net45" />
<package id="NuGet.Core" version="2.8.2" targetFramework="net45" />
<package id="SimpleJson" version="0.38.0" targetFramework="net45" />
<package id="Splat" version="1.4.0" targetFramework="net45" />
</packages>