internal override void Compile(ElobuddyAddon addon) { var logFileName = string.Format("compile_log_{0}.txt", addon.GetUniqueName()); var logFile = Path.Combine(Settings.Instance.Directories.TempDirectory, logFileName); var compileResult = ProjectCompiler.Compile(addon.ProjectFilePath, logFile); File.Delete(logFile); if (!compileResult.BuildSuccessful) { addon.SetState(AddonState.CompilingError); var logFileSavePath = Path.Combine(Settings.Instance.Directories.LogsDirectory, logFileName); File.WriteAllBytes(logFileSavePath, compileResult.LogFile); Log.Instance.DoLog(string.Format("Failed to compile project: \"{0}\". Build log file saved to \"{1}\".", addon.ProjectFilePath, logFileSavePath), Log.LogType.Error); } else { addon.SetState(AddonState.Ready); addon.Type = compileResult.Type; if (!addon.IsLocal) { var split = addon.Url.Split('/'); addon.Author = split.Length > 3 ? split[3] : ""; } var exePath = addon.GetOutputFilePath(); var pdpPath = Path.Combine(Path.GetDirectoryName(exePath), compileResult.PdbFileName ?? ""); FileHelper.SafeWriteAllBytes(exePath, compileResult.OutputFile); if (Settings.Instance.DeveloperMode && compileResult.PdbFile != null) { FileHelper.SafeWriteAllBytes(pdpPath, compileResult.PdbFile); } else if (File.Exists(pdpPath)) { try { File.Delete(pdpPath); } catch { // ignored } } addon.Version = FileVersionInfo.GetVersionInfo(exePath).FileVersion; Log.Instance.DoLog(string.Format("Successfully compiled project: \"{0}\".", addon.ProjectFilePath)); } }
internal override void Compile(ElobuddyAddon addon) { SignedAddonHeader header; byte[] assembly; if (Verify(File.ReadAllBytes(addon.ProjectFilePath), out header, out assembly)) { // buddy check addon.IsBuddyAddon = header.Data.CData[0] != 0; addon.Type = header.Data.IsLibrary ? AddonType.Library : AddonType.Executable; addon.Author = header.Data.Author; addon.Version = header.Data.Version; FileHelper.SafeWriteAllBytes(addon.GetOutputFilePath(), assembly); addon.SetState(AddonState.Ready); } else { Log.Instance.DoLog(string.Format("Failed to install signed addon: \"{0}\". The addon is not properly signed!", addon.ProjectFilePath), Log.LogType.Error); addon.SetState(AddonState.CompilingError); } }