Updated ModPreprocessorDefine.csx

This commit is contained in:
MrGadget1024 2023-11-09 06:53:12 -05:00
parent 8ee132b4af
commit 0a53a72e84

View File

@ -7,7 +7,7 @@ using System.Text.RegularExpressions;
void Main() void Main()
{ {
Console.WriteLine("ModPreprocessorDefine Started); Console.WriteLine("ModPreprocessorDefine Started");
// Redirect console output to a file // Redirect console output to a file
var originalConsoleOut = Console.Out; var originalConsoleOut = Console.Out;
@ -21,19 +21,19 @@ void Main()
// Read the contents of the file // Read the contents of the file
string fileContents = File.ReadAllText(filePath); string fileContents = File.ReadAllText(filePath);
Console.WriteLine("ModPreprocessorDefine File read); Console.WriteLine("ModPreprocessorDefine File read");
// Find and remove the first entry ending with "_OR_NEWER" // Find and remove the first entry ending with "_OR_NEWER"
fileContents = RemoveFirstOrNewerEntry(fileContents); fileContents = RemoveFirstOrNewerEntry(fileContents);
Console.WriteLine("ModPreprocessorDefine Old entry removed); Console.WriteLine("ModPreprocessorDefine Old entry removed");
// Find the last entry and capture the version number // Find the last entry and capture the version number
string versionNumber = GetLastVersionNumber(fileContents); string versionNumber = GetLastVersionNumber(fileContents);
Console.WriteLine($"ModPreprocessorDefine current version {versionNumber}); Console.WriteLine($"ModPreprocessorDefine current version {versionNumber}");
// Append a new entry with the correct indentation and next version number // Append a new entry with the correct indentation and next version number
fileContents = AppendNewEntry(fileContents, versionNumber); fileContents = AppendNewEntry(fileContents, versionNumber);
Console.WriteLine("ModPreprocessorDefine New entry appended); Console.WriteLine("ModPreprocessorDefine New entry appended");
// Write the modified contents back to the file // Write the modified contents back to the file
File.WriteAllText(filePath, fileContents); File.WriteAllText(filePath, fileContents);
@ -41,7 +41,7 @@ void Main()
Console.SetOut(originalConsoleOut); Console.SetOut(originalConsoleOut);
} }
Console.WriteLine("ModPreprocessorDefine Finished); Console.WriteLine("ModPreprocessorDefine Finished");
// Print the contents of the redirected file // Print the contents of the redirected file
Console.WriteLine("Console Output:"); Console.WriteLine("Console Output:");