Updated ModPreprocessorDefine.csx

This commit is contained in:
MrGadget1024 2023-11-09 07:22:00 -05:00
parent 08aa2a9167
commit 5ae11f2cc7

View File

@ -8,6 +8,7 @@ using System.Text.RegularExpressions;
void Main()
{
Console.WriteLine("ModPreprocessorDefine Started");
Console.Out.Flush();
// Redirect console output to a file
var originalConsoleOut = Console.Out;
@ -23,6 +24,7 @@ void Main()
// Print some debug information
Console.WriteLine($"Working Directory: {Environment.CurrentDirectory}");
Console.WriteLine($"Output File Path: {outputPath}");
Console.Out.Flush();
// Define the path to the PreprocessorDefine.cs file
string filePath = "Assets/Mirror/CompilerSymbols/PreprocessorDefine.cs";
@ -30,18 +32,22 @@ void Main()
// Read the contents of the file
string fileContents = File.ReadAllText(filePath);
Console.WriteLine("ModPreprocessorDefine File read");
Console.Out.Flush();
// Find and remove the first entry ending with "_OR_NEWER"
fileContents = RemoveFirstOrNewerEntry(fileContents);
Console.WriteLine("ModPreprocessorDefine Old entry removed");
Console.Out.Flush();
// Find the last entry and capture the version number
string versionNumber = GetLastVersionNumber(fileContents);
Console.WriteLine($"ModPreprocessorDefine current version {versionNumber}");
Console.Out.Flush();
// Append a new entry with the correct indentation and next version number
fileContents = AppendNewEntry(fileContents, versionNumber);
Console.WriteLine("ModPreprocessorDefine New entry appended");
Console.Out.Flush();
// Write the modified contents back to the file
File.WriteAllText(filePath, fileContents);
@ -54,6 +60,7 @@ void Main()
// Print the contents of the redirected file
Console.WriteLine("Console Output:");
Console.WriteLine(File.ReadAllText("console_output.txt"));
Console.Out.Flush();
}
string RemoveFirstOrNewerEntry(string input)