From ec0eb59871767e4b753d1731bee860ec31cb13e2 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 21 Dec 2023 18:28:24 +0100 Subject: [PATCH] some more cleanup and path char inconsistency fixes --- Contentless/Program.cs | 16 +++++----------- Test/Content/Content.mgcb | 2 +- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Contentless/Program.cs b/Contentless/Program.cs index 5bd33c3..d8a48e5 100644 --- a/Contentless/Program.cs +++ b/Contentless/Program.cs @@ -77,7 +77,7 @@ public static class Program { changed = true; } else { if (config.LogSkipped) - Console.WriteLine($"Skipping reference {fullLibraryPath} which already matched"); + Console.WriteLine($"Skipping reference replacement for {fullLibraryPath} which already matched"); } referencesSyncs.Add(libraryName); } @@ -92,9 +92,9 @@ public static class Program { // find place where I can add new reference for (var i = 0; i < content.Count; i++) { var line = content[i]; - if (line.StartsWith(referenceHeader)) + if (line.StartsWith(referenceHeader)) { referencesLastIndex = i + 1; - else if (line.StartsWith("/importer:") || line.StartsWith("/processor:") || line.StartsWith("/build:") || line.Contains("-- Content --")) { + } else if (line.StartsWith("/importer:") || line.StartsWith("/processor:") || line.StartsWith("/build:") || line.Contains("-- Content --")) { if (referencesLastIndex == 0) referencesLastIndex = i; break; @@ -122,7 +122,7 @@ public static class Program { // is the file the content or config file? if (file.Name == contentFile.Name || file.Name == configFile.Name) continue; - var relative = Program.GetRelativePath(contentFile.DirectoryName, file.FullName).Replace("\\", "/"); + var relative = Path.GetRelativePath(contentFile.DirectoryName, file.FullName).Replace('\\', '/'); // is the file in an excluded directory? if (excluded.Any(e => e.IsMatch(relative))) { @@ -225,7 +225,7 @@ public static class Program { } private static string CalculateFullPathToLibrary(string packageFolder, string libraryName, string referencesVersion) { - return Path.Combine(packageFolder, libraryName.ToLower(), referencesVersion, "tools", libraryName + ".dll"); + return Path.Combine(packageFolder, libraryName.ToLowerInvariant(), referencesVersion, "tools", libraryName + ".dll").Replace('\\', '/'); } private static (List, List) GetContentData() { @@ -306,12 +306,6 @@ public static class Program { Console.WriteLine($"Adding file {relative} with the Copy build action"); } - private static string GetRelativePath(string relativeTo, string path) { - if (!relativeTo.EndsWith(Path.DirectorySeparatorChar.ToString())) - relativeTo += Path.DirectorySeparatorChar; - return path.Replace(relativeTo, ""); - } - private static Regex MakeFileRegex(string s) { return new Regex(s.Replace(".", "[.]").Replace("*", ".*").Replace("?", ".")); } diff --git a/Test/Content/Content.mgcb b/Test/Content/Content.mgcb index 262bcce..0d36b02 100644 --- a/Test/Content/Content.mgcb +++ b/Test/Content/Content.mgcb @@ -10,7 +10,7 @@ #-------------------------------- References --------------------------------# -/reference:C:\Users\me\.nuget\packages\monogame.extended.content.pipeline\3.8.0\tools\MonoGame.Extended.Content.Pipeline.dll +/reference:C:/Users/me/.nuget/packages/monogame.extended.content.pipeline/3.8.0/tools/MonoGame.Extended.Content.Pipeline.dll #---------------------------------- Content ---------------------------------# #begin Json/Copy.json