/// <summary> /// Attempt to update BepInEx to the latest version. /// </summary> public static void UpdateBepInEx() { if (!Folders.IsCurrentOutwardPathValid()) { Console.WriteLine("Current Outward folder path not set or invalid! Cannot update BepInEx."); return; } // If an update check hasn't been done this launch, do one now. if (IsBepInExUpdated()) { return; } // If the check we just did failed (no query result), we need to abort. if (string.IsNullOrEmpty(s_latestBepInExVersion)) { return; } try { string releaseURL = $@"https://github.com/BepInEx/BepInEx/releases/latest/download/BepInEx_x64_{s_latestBepInExVersion}.zip"; var tempFile = TemporaryFile.CreateFile(); MefinoGUI.SetProgressMessage($"Downloading BepInEx {s_latestBepInExVersion}"); WebClientManager.DownloadFileAsync(releaseURL, tempFile); while (WebClientManager.IsBusy) { MefinoApp.SendAsyncProgress(WebClientManager.LastDownloadProgress); } MefinoGUI.SetProgressMessage($"Extracting BepInEx {s_latestBepInExVersion}"); ZipHelper.ExtractZip(tempFile, Folders.OUTWARD_FOLDER); Console.WriteLine("Updated BepInEx to version '" + s_latestBepInExVersion + "'"); } catch (Exception ex) { Console.WriteLine("Exception downloading and installing BepInEx!"); Console.WriteLine(ex); } }
public async Task ErrorEnumerationWithResolvedPath() { using (var git = TemporaryFile.CreateDirectory(Path.Combine(Path.GetTempPath(), "git"))) using (var proja = TemporaryFile.CreateDirectory(Path.Combine(git.Path, "proj-a"))) using (var src = TemporaryFile.CreateDirectory(Path.Combine(proja.Path, "src"))) using (var a = TemporaryFile.CreateFile(Path.Combine(src.Path, "a.cpp"))) using (var b = TemporaryFile.CreateFile(Path.Combine(src.Path, "b.cpp"))) { var errors = await Provider.GetErrorsAsync("A", git.Path); var expected = new List <ErrorListItem>() { new ErrorListItem() { ProjectName = "", FileName = a.Path, Line = 181, Message = "This expression casts between two pointer types.", ErrorCode = "QACPP3030", ErrorCodeToolTip = "Get help for 'QACPP3030'", ErrorCategory = "Vulnerability", Severity = __VSERRORCATEGORY.EC_MESSAGE }, new ErrorListItem() { ProjectName = "", FileName = b.Path, Line = 58, Message = "This operation is redundant. The value of the result is always that of the left-hand operand.", ErrorCode = "QACPP2985", ErrorCodeToolTip = "Get help for 'QACPP2985'", ErrorCategory = "Minor Bug", Severity = __VSERRORCATEGORY.EC_ERROR } }; Assert.That(errors, Is.EqualTo(expected).Using(new ErrorListItemComparer())); } }
/// <summary> /// Actually download and install the provided PackageManifest instance, which would presumably be a web manifest. /// </summary> /// <param name="manifest">The PackageManifest to install.</param> /// <returns><see langword="true"/> if successful, otherwise <see langword="false"/></returns> internal static bool DownloadAndInstallPackage(PackageManifest manifest) { try { MefinoGUI.SetProgressBarActive(true); MefinoGUI.DisableSensitiveControls(); var dirPath = $@"{Folders.MEFINO_DISABLED_FOLDER}\{manifest.GUID}"; if (Directory.Exists(dirPath)) { Directory.Delete(dirPath, true); } var tempFile = TemporaryFile.CreateFile(); var zipUrl = $"{manifest.GithubURL}/releases/latest/download/{manifest.DownloadFileName}"; Web.WebClientManager.DownloadFileAsync(zipUrl, tempFile); while (Web.WebClientManager.IsBusy) { Thread.Sleep(20); MefinoApp.SendAsyncProgress(Web.WebClientManager.LastDownloadProgress); } MefinoGUI.SetProgressMessage($"Installing '{manifest.GUID}' (version {manifest.version})"); if (ZipHelper.ExtractZip(tempFile, dirPath)) { var manifestPath = $@"{dirPath}\mefino-manifest.json"; if (File.Exists(manifestPath)) { File.Delete(manifestPath); } File.WriteAllText(manifestPath, manifest.ToJsonObject().ToString(true)); //Console.WriteLine($"Installed package: {manifest.GUID} {manifest.version}"); MefinoGUI.SetProgressBarActive(false); MefinoGUI.ReEnableSensitiveControls(); return(true); } else { throw new Exception("Zip extraction failed!"); } } catch (Exception ex) { MefinoGUI.SetProgressBarActive(false); MefinoGUI.ReEnableSensitiveControls(); Console.WriteLine("Exception isntalling package '" + manifest.GUID + "'"); Console.WriteLine($"{ex.GetType()}: {ex.Message}"); //Mefino.SendAsyncCompletion(false); return(false); } }