diff --git a/Synthesis.Bethesda.Execution/Patchers/Git/ModifyProject/SwapToProperNetVersion.cs b/Synthesis.Bethesda.Execution/Patchers/Git/ModifyProject/SwapToProperNetVersion.cs index ab225b89..77918337 100644 --- a/Synthesis.Bethesda.Execution/Patchers/Git/ModifyProject/SwapToProperNetVersion.cs +++ b/Synthesis.Bethesda.Execution/Patchers/Git/ModifyProject/SwapToProperNetVersion.cs @@ -1,4 +1,5 @@ -using System.Xml.Linq; +using System.Globalization; +using System.Xml.Linq; using NuGet.Versioning; using Serilog; using Synthesis.Bethesda.Execution.Versioning; @@ -15,6 +16,7 @@ public class SwapToProperNetVersion : ISwapToProperNetVersion private readonly ILogger _logger; private const int NetNum = 8; private readonly Version Net8Version = new Version(0, 45); + private readonly CultureInfo Culture = new CultureInfo("en"); public SwapToProperNetVersion(ILogger logger) { @@ -46,18 +48,30 @@ private void ProcessLegacy(XElement elem) } } - private void ProcessNet8(XElement elem, Version targetMutagenVersion) + private bool NeedsUpgrade(string elem) { - if (!elem.Value.StartsWith("net")) + if (elem.StartsWith("netcoreapp", StringComparison.OrdinalIgnoreCase)) + { + return true; + } + if (!elem.StartsWith("net", StringComparison.OrdinalIgnoreCase)) { - throw new ArgumentException($"Could not process version: {elem.Value}"); + throw new ArgumentException($"Could not process version: {elem}"); } - if (double.TryParse(elem.Value.Substring(3), out var netNum) + if (double.TryParse(elem.Substring(3), Culture, out var netNum) && netNum > NetNum) { - return; + _logger.Information($"Already net{netNum}. No need to upgrade"); + return false; } + + return true; + } + + private void ProcessNet8(XElement elem, Version targetMutagenVersion) + { + if (!NeedsUpgrade(elem.Value)) return; _logger.Information("Swapping to net8.0"); elem.Value = $"net{NetNum}.0";