async Task <CoreUpdaterInfo> CheckForUpdatesAsync(string jsonUrl) { var appInfo = await DownloadJsonAsync(jsonUrl); // Deserialize CoreUpdaterInfo = CoreUpdaterInfo.ReadString(appInfo); return(CoreUpdaterInfo); }
public void StartUpdater(CoreUpdaterInfo coreUpdaterInfo, ExecutionType executonType = ExecutionType.Default) { var assemblyName = Path.GetFileName(Assembly.GetEntryAssembly().Location); var srcDir = Path.GetFullPath(coreUpdaterInfo.GetNewVersionDir()); var dstDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var processId = Process.GetCurrentProcess().Id.ToString(); StartUpdater(assemblyName, srcDir, dstDir, processId, executonType); }
void CopyFiles(string srcDir, string dstDir, CoreUpdaterInfo srcAppinfo) { foreach (var file in srcAppinfo.Files) { File.Copy($@"{srcDir}\{file.Name}", $@"{dstDir}\{file.Name}", true); logger?.LogDebug($@"[Copy] {srcDir}\{file.Name}"); } File.Copy($@"{srcDir}\{CoreUpdaterInfoFileName}", $@"{dstDir}\{CoreUpdaterInfoFileName}", true); logger?.LogDebug($@"[Copy] {srcDir}\{CoreUpdaterInfoFileName}"); }
void DeleteFiles(string dir, CoreUpdaterInfo appinfo) { // Delete file in current dir. foreach (var file in appinfo.Files) { File.Delete($@"{dir}\{file.Name}"); logger?.LogDebug($@"[Delete] {dir}\{file.Name}"); } File.Delete($@"{dir}\{CoreUpdaterInfoFileName}"); logger?.LogDebug($@"[Delete] {dir}\{CoreUpdaterInfoFileName}"); }
/// <summary> /// Download zip from GitHub, and extract it /// </summary> /// <param name="zipFileName"></param> /// <param name="outputDir"></param> /// <returns></returns> public override async Task <CoreUpdaterInfo> PrepareForUpdatesAsync(string outputDir, string zipFileName) { var tag = await GetLatestReleaseTagAsync(); var jsonUrl = GetAssetUrl(tag, CoreUpdaterInfoFileName); var zipUrl = GetAssetUrl(tag, zipFileName); var appInfo = await CheckForUpdatesAsync(jsonUrl); var outputPath = $@"{outputDir}\{zipFileName}"; await DownloadZipAsync(zipUrl, outputPath); Zip.ExtractEntries(outputPath, appInfo.GetNewVersionDir()); // Delete downloaded zip file. File.Delete(outputPath); return(CoreUpdaterInfo.ReadFile($@"{appInfo.GetNewVersionDir()}\{CoreUpdaterInfoFileName}")); }
public override async Task <CoreUpdaterInfo> PrepareForUpdatesAsync(string outputDir, CoreUpdaterInfo coreUpdaterInfo) { return(await PrepareForUpdatesAsync(outputDir, coreUpdaterInfo.Name + ".zip")); }
public abstract Task <CoreUpdaterInfo> PrepareForUpdatesAsync(string outputDir, CoreUpdaterInfo coreUpdaterInfo);