mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Implement check for updates
This commit is contained in:
@@ -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();
|
||||
|
||||
2127
src/Update/SimpleJson/SimpleJson.cs
Normal file
2127
src/Update/SimpleJson/SimpleJson.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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" />
|
||||
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user