Add auto update to linux and macos

This commit is contained in:
Mbucari 2023-02-13 22:25:44 -07:00 committed by Michael Bucari-Tovo
parent 952eee6d32
commit dc7c03661d
26 changed files with 631 additions and 99 deletions

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
@ -35,8 +36,31 @@ namespace WindowsConfigApp
public void DeleteFolderIcon(string directory)
=> new DirectoryInfo(directory)?.DeleteIcon();
public bool CanUpdate => true;
public void InstallUpdate(string updateBundle)
{
var thisExe = Environment.ProcessPath;
var thisDir = Path.GetDirectoryName(thisExe);
var zipExtractor = Path.Combine(Path.GetTempPath(), "ZipExtractor.exe");
public void CopyTextToClipboard(string text)
=> Clipboard.SetText(text);
File.Copy("ZipExtractor.exe", zipExtractor, overwrite: true);
RunAsRoot(zipExtractor, $"--input \"{updateBundle}\" --output \"{thisDir}\" --executable \"{thisExe}\"");
}
public Process RunAsRoot(string exe, string args)
{
var psi = new ProcessStartInfo()
{
FileName = exe,
UseShellExecute = true,
Verb = "runas",
WindowStyle = ProcessWindowStyle.Normal,
CreateNoWindow = true,
Arguments = args
};
return Process.Start(psi);
}
}
}

View file

@ -40,4 +40,10 @@
<ProjectReference Include="..\..\AppScaffolding\AppScaffolding.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="ZipExtractor.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

Binary file not shown.