diff --git a/docs/technical/mod-package.md b/docs/technical/mod-package.md index 4c31f69b..6123b28f 100644 --- a/docs/technical/mod-package.md +++ b/docs/technical/mod-package.md @@ -413,9 +413,19 @@ when you compile it. ## Release notes ## Upcoming release +* Migrated from .NET Standard 2.0 to .NET 5.0. * Added detection for Xbox app game folders. * Internal refactoring. +**Troubleshooting:** +Due to the framework change, you might see build errors like _task failed unexpectedly_ that mentions `System.Runtime Version=5.0.0`. If so: + +1. Make sure you have Visual Studio 2022 or later. +2. Exit all instances of Visual Studio. +3. Delete the hidden `.vs` folder in your solution folder. +4. Delete the `bin` and `obj` folders in each project folder. +5. Reopen the solution and rebuild, and now it should work fine. + ## 4.0.0 Released 30 November 2021. diff --git a/src/SMAPI.ModBuildConfig.Analyzer/SMAPI.ModBuildConfig.Analyzer.csproj b/src/SMAPI.ModBuildConfig.Analyzer/SMAPI.ModBuildConfig.Analyzer.csproj index 7ac3277e..69fd3dbd 100644 --- a/src/SMAPI.ModBuildConfig.Analyzer/SMAPI.ModBuildConfig.Analyzer.csproj +++ b/src/SMAPI.ModBuildConfig.Analyzer/SMAPI.ModBuildConfig.Analyzer.csproj @@ -2,7 +2,7 @@ StardewModdingAPI.ModBuildConfig.Analyzer 3.0.0 - netstandard2.0 + net5.0 false bin latest diff --git a/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj b/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj index 82eac7f6..8e70293e 100644 --- a/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj +++ b/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj @@ -2,7 +2,7 @@ StardewModdingAPI.ModBuildConfig - netstandard2.0 + net5.0 latest true true diff --git a/src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj b/src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj index 4c92b4db..d69d53d5 100644 --- a/src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj +++ b/src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj @@ -2,7 +2,7 @@ StardewModdingAPI Provides toolkit interfaces which are available to SMAPI mods. - net5.0; netstandard2.0 + net5.0 true diff --git a/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj b/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj index ec27bf79..6a8c4c43 100644 --- a/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj +++ b/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj @@ -2,7 +2,7 @@ StardewModdingAPI.Toolkit A library which encapsulates mod-handling logic for mod managers and tools. Not intended for use by mods. - net5.0; netstandard2.0 + net5.0 true diff --git a/src/SMAPI.Toolkit/SemanticVersion.cs b/src/SMAPI.Toolkit/SemanticVersion.cs index cea8c447..ca9d15f5 100644 --- a/src/SMAPI.Toolkit/SemanticVersion.cs +++ b/src/SMAPI.Toolkit/SemanticVersion.cs @@ -198,12 +198,7 @@ namespace StardewModdingAPI.Toolkit /// The version string. /// The parsed representation. /// Returns whether parsing the version succeeded. - public static bool TryParse(string? version, -#if NET5_0_OR_GREATER - [NotNullWhen(true)] -#endif - out ISemanticVersion? parsed - ) + public static bool TryParse(string? version, [NotNullWhen(true)] out ISemanticVersion? parsed) { return SemanticVersion.TryParse(version, allowNonStandard: false, out parsed); } @@ -213,12 +208,7 @@ namespace StardewModdingAPI.Toolkit /// Whether to allow non-standard extensions to semantic versioning. /// The parsed representation. /// Returns whether parsing the version succeeded. - public static bool TryParse(string? version, bool allowNonStandard, -#if NET5_0_OR_GREATER - [NotNullWhen(true)] -#endif - out ISemanticVersion? parsed - ) + public static bool TryParse(string? version, bool allowNonStandard, [NotNullWhen(true)] out ISemanticVersion? parsed) { if (version == null) { diff --git a/src/SMAPI.Toolkit/Serialization/Models/Manifest.cs b/src/SMAPI.Toolkit/Serialization/Models/Manifest.cs index 01010602..3ab5edfb 100644 --- a/src/SMAPI.Toolkit/Serialization/Models/Manifest.cs +++ b/src/SMAPI.Toolkit/Serialization/Models/Manifest.cs @@ -115,9 +115,7 @@ namespace StardewModdingAPI.Toolkit.Serialization.Models *********/ /// Normalize whitespace in a raw string. /// The input to strip. -#if NET5_0_OR_GREATER [return: NotNullIfNotNull("input")] -#endif private string? NormalizeWhitespace(string? input) { return input diff --git a/src/SMAPI.Toolkit/Serialization/Models/ManifestContentPackFor.cs b/src/SMAPI.Toolkit/Serialization/Models/ManifestContentPackFor.cs index f7dc8aa8..dcdbcf74 100644 --- a/src/SMAPI.Toolkit/Serialization/Models/ManifestContentPackFor.cs +++ b/src/SMAPI.Toolkit/Serialization/Models/ManifestContentPackFor.cs @@ -33,9 +33,7 @@ namespace StardewModdingAPI.Toolkit.Serialization.Models *********/ /// Normalize whitespace in a raw string. /// The input to strip. -#if NET5_0_OR_GREATER [return: NotNullIfNotNull("input")] -#endif private string? NormalizeWhitespace(string? input) { return input?.Trim(); diff --git a/src/SMAPI.Toolkit/Serialization/Models/ManifestDependency.cs b/src/SMAPI.Toolkit/Serialization/Models/ManifestDependency.cs index e7acf71d..64725818 100644 --- a/src/SMAPI.Toolkit/Serialization/Models/ManifestDependency.cs +++ b/src/SMAPI.Toolkit/Serialization/Models/ManifestDependency.cs @@ -54,9 +54,7 @@ namespace StardewModdingAPI.Toolkit.Serialization.Models *********/ /// Normalize whitespace in a raw string. /// The input to strip. -#if NET5_0_OR_GREATER [return: NotNullIfNotNull("input")] -#endif private string? NormalizeWhitespace(string? input) { return input?.Trim(); diff --git a/src/SMAPI.Toolkit/Utilities/PathUtilities.cs b/src/SMAPI.Toolkit/Utilities/PathUtilities.cs index 9a0e2ea7..d035d4cd 100644 --- a/src/SMAPI.Toolkit/Utilities/PathUtilities.cs +++ b/src/SMAPI.Toolkit/Utilities/PathUtilities.cs @@ -92,43 +92,7 @@ namespace StardewModdingAPI.Toolkit.Utilities [Pure] public static string GetRelativePath(string sourceDir, string targetPath) { -#if NET5_0 return Path.GetRelativePath(sourceDir, targetPath); -#else - // NOTE: - // this is a heuristic implementation that works in the cases SMAPI needs it for, but it - // doesn't handle all edge cases (e.g. case-sensitivity on Linux, or traversing between - // UNC paths on Windows). SMAPI and mods will use the more robust .NET 5 version anyway - // though, this is only for compatibility with the mod build package. - - // convert to URIs - Uri from = new(sourceDir.TrimEnd(PathUtilities.PossiblePathSeparators) + "/"); - Uri to = new(targetPath.TrimEnd(PathUtilities.PossiblePathSeparators) + "/"); - if (from.Scheme != to.Scheme) - throw new InvalidOperationException($"Can't get path for '{targetPath}' relative to '{sourceDir}'."); - - // get relative path - string rawUrl = Uri.UnescapeDataString(from.MakeRelativeUri(to).ToString()); - if (rawUrl.StartsWith("file://")) - rawUrl = PathUtilities.WindowsUncRoot + rawUrl.Substring("file://".Length); - string relative = PathUtilities.NormalizePath(rawUrl); - - // normalize - if (relative == "") - relative = "."; - else - { - // trim trailing slash from URL - if (relative.EndsWith(PathUtilities.PreferredPathSeparator.ToString())) - relative = relative.Substring(0, relative.Length - 1); - - // fix root - if (relative.StartsWith("file:") && !targetPath.Contains("file:")) - relative = relative.Substring("file:".Length); - } - - return relative; -#endif } /// Get whether a path is relative and doesn't try to climb out of its containing folder (e.g. doesn't contain ../).