Skip to content

Commit

Permalink
Added some logging to Net SDK target swapping logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Noggog committed Sep 22, 2024
1 parent de7e150 commit 8c57b65
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Xml.Linq;
using Noggog;
using NuGet.Versioning;
using Serilog;
using Synthesis.Bethesda.Execution.Patchers.Solution;
using Synthesis.Bethesda.Execution.Versioning;

Expand All @@ -21,6 +22,7 @@ public class ModifyRunnerProjects : IModifyRunnerProjects
public static readonly System.Version NewtonSoftRemoveMutaVersion = new(0, 28);
public static readonly System.Version NewtonSoftRemoveSynthVersion = new(0, 17, 5);
public static readonly System.Version NamespaceMutaVersion = new(0, 30, 0);
private readonly ILogger _logger;
private readonly IFileSystem _fileSystem;
private readonly IAvailableProjectsRetriever _availableProjectsRetriever;
private readonly ISwapToProperNetVersion _swapToProperNetVersion;
Expand All @@ -35,6 +37,7 @@ public class ModifyRunnerProjects : IModifyRunnerProjects
private readonly AddAllReleasesToOldVersions _addAllReleasesToOldVersions;

public ModifyRunnerProjects(
ILogger logger,
IFileSystem fileSystem,
IAvailableProjectsRetriever availableProjectsRetriever,
ISwapToProperNetVersion swapToProperNetVersion,
Expand All @@ -48,6 +51,7 @@ public ModifyRunnerProjects(
IRemoveProject removeProject,
AddAllReleasesToOldVersions addAllReleasesToOldVersions)
{
_logger = logger;
_fileSystem = fileSystem;
_availableProjectsRetriever = availableProjectsRetriever;
_swapToProperNetVersion = swapToProperNetVersion;
Expand Down Expand Up @@ -83,6 +87,7 @@ public void Modify(
foreach (var subProj in _availableProjectsRetriever.Get(solutionPath))
{
var proj = Path.Combine(Path.GetDirectoryName(solutionPath)!, subProj);
_logger.Information("Modifying {ProjPath}", proj);
var txt = _fileSystem.File.ReadAllText(proj);
var projXml = XElement.Parse(txt);
_swapDesiredVersions.Swap(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Xml.Linq;
using NuGet.Versioning;
using Serilog;
using Synthesis.Bethesda.Execution.Versioning;

namespace Synthesis.Bethesda.Execution.Patchers.Git.ModifyProject;
Expand All @@ -11,12 +12,19 @@ public interface ISwapToProperNetVersion

public class SwapToProperNetVersion : ISwapToProperNetVersion
{
private readonly ILogger _logger;
private const int NetNum = 8;
private readonly Version Net8Version = new Version(0, 45);

public SwapToProperNetVersion(ILogger logger)
{
_logger = logger;
}

private void ProcessTargetFrameworkNode(XElement elem, Version targetMutagenVersion)
{
if (!elem.Name.LocalName.Equals("TargetFramework")) return;
_logger.Information("Target mutagen version: {Target}", targetMutagenVersion);
if (targetMutagenVersion < Net8Version)
{
ProcessLegacy(elem);
Expand All @@ -27,16 +35,18 @@ private void ProcessTargetFrameworkNode(XElement elem, Version targetMutagenVers
}
}

private static void ProcessLegacy(XElement elem)
private void ProcessLegacy(XElement elem)
{
_logger.Information("Processing as legacy mutagen version");
if (elem.Value.Equals("netcoreapp3.1", StringComparison.Ordinal)
|| elem.Value.StartsWith("net5", StringComparison.Ordinal))
{
_logger.Information("Swapping to net6.0");
elem.Value = "net6.0";
}
}

private static void ProcessNet8(XElement elem, Version targetMutagenVersion)
private void ProcessNet8(XElement elem, Version targetMutagenVersion)
{
if (!elem.Value.StartsWith("net"))
{
Expand All @@ -49,6 +59,7 @@ private static void ProcessNet8(XElement elem, Version targetMutagenVersion)
return;
}

_logger.Information("Swapping to net8.0");
elem.Value = $"net{NetNum}.0";
}

Expand Down

0 comments on commit 8c57b65

Please sign in to comment.