public void Install(PackageStatusContext context) { var farmhandBinary = Path.Combine(InstallationContext.OutputPath, "Stardew Farmhand.exe"); var temporaryDirectory = Path.Combine(InstallationContext.OutputPath, "FarmhandInstallTemp"); var workingDirectory = Path.Combine(temporaryDirectory, "WorkingDirectory"); var binDirectory = Path.Combine(temporaryDirectory, "Bin"); context.SetState(10, "Cleaning Output Directory"); DirectoryUtility.EnsureDirectoryExists(InstallationContext.OutputPath); DirectoryUtility.CleanDirectory(InstallationContext.OutputPath); DirectoryUtility.EnsureDirectoryExists(temporaryDirectory); context.SetState(25, "Extracting Package File"); PackageManager.ExtractPackageFile(PackageFile, temporaryDirectory); context.SetState(40, "Copying Stardew Valley Files"); DirectoryUtility.CopyAll(InstallationContext.StardewPath, InstallationContext.OutputPath, ".*\\.exe"); context.SetState(50, "Copying SMAPI Files"); DirectoryUtility.CopyAll(workingDirectory, InstallationContext.OutputPath); StardewPatcher.Patch(farmhandBinary, binDirectory, true, context); context.SetState(100, "Deleting Temporary Directory"); Directory.Delete(temporaryDirectory, true); }
private void EditSolution(PackageStatusContext context) { var solution = Path.Combine(InstallationContext.OutputPath, "Farmhand.sln"); var text = File.ReadAllText(solution); var projects = Regex.Matches(text, ProjectBlockMatch).Cast <Match>().ToList(); context.SetState(20, "Removing Projects From Solution"); Match modTemplateProject = null; var linesToCull = new List <string>(); foreach (var project in projects) { if (!project.Value.Contains("\"Mods\"") && !project.Value.Contains("FarmhandDebugger")) { if (InstallationContext.AddNewModFromTemplate) { if (project.Value.Contains("ModTemplate")) { modTemplateProject = project; continue; } } text = text.Replace(project.Value, string.Empty); linesToCull.Add(Regex.Match(project.Value, ProjectIdMatch).Value); } } foreach (var lineToCull in linesToCull) { text = Regex.Replace(text, ".*{" + lineToCull + "}.*\n", string.Empty); } if (InstallationContext.AddNewModFromTemplate) { context.SetState(30, "Adding new blank mod"); if (modTemplateProject == null) { throw new Exception( "ModTemplate was not included in the solution! Development mod will not be generated"); } var modTemplateLine = modTemplateProject.Value; modTemplateLine = modTemplateLine.Substring(0, modTemplateLine.IndexOf("ProjectSection", StringComparison.Ordinal)); var nextModEntry = modTemplateLine.Replace( "ModTemplate", InstallationContext.ModSettings.NameNoSpace); text = text.Replace(modTemplateLine, nextModEntry); ModTemplateUtility.PatchTemplateMod(); } context.SetState(40, "Writing Modified Solution"); File.WriteAllText(solution, text); }
public void Install(PackageStatusContext context) { context.SetState(10, "Cleaning Output Directory"); DirectoryUtility.EnsureDirectoryExists(InstallationContext.OutputPath); DirectoryUtility.CleanDirectory(InstallationContext.OutputPath); context.SetState(25, "Extracting Package File"); PackageManager.ExtractPackageFile(PackageFile, InstallationContext.OutputPath); context.SetState(40, "Copying Stardew Valley Files"); var output = Path.Combine(InstallationContext.OutputPath, "Staging"); DirectoryUtility.CopyAll(InstallationContext.StardewPath, output); this.EditSolution(context); }
public void Install(PackageStatusContext context) { var workingDir = Path.Combine(InstallationContext.OutputPath, "WorkingDirectory"); var farmhandBinary = Path.Combine(workingDir, "Stardew Farmhand.exe"); var assemblyDirectory = Path.Combine(InstallationContext.OutputPath, "Bin"); context.SetState(10, "Cleaning Output Directory"); DirectoryUtility.EnsureDirectoryExists(InstallationContext.OutputPath); DirectoryUtility.CleanDirectory(InstallationContext.OutputPath); PackageManager.ExtractPackageFile(PackageFile, InstallationContext.OutputPath); this.EditSolution(context); context.SetState(50, "Copying SMAPI Files"); DirectoryUtility.CopyAll(InstallationContext.StardewPath, workingDir, ".*\\.exe"); StardewPatcher.Patch(farmhandBinary, assemblyDirectory, true, context); }