summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-07 01:51:50 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-07 01:51:50 -0400
commit6b05296e71c32abd158f354eeeaf1e135e72e6e2 (patch)
tree417ee622b7cf56bc98f6a55ddb7ab63f414c25e4
parente58e8a22836081ec4baffa5a9b4b093a329f3d88 (diff)
downloadSMAPI-6b05296e71c32abd158f354eeeaf1e135e72e6e2.tar.gz
SMAPI-6b05296e71c32abd158f354eeeaf1e135e72e6e2.tar.bz2
SMAPI-6b05296e71c32abd158f354eeeaf1e135e72e6e2.zip
migrate mod build package to .NET 5 to allow full nullable annotations (#837)
-rw-r--r--docs/technical/mod-package.md10
-rw-r--r--src/SMAPI.ModBuildConfig.Analyzer/SMAPI.ModBuildConfig.Analyzer.csproj2
-rw-r--r--src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj2
-rw-r--r--src/SMAPI.Toolkit.CoreInterfaces/SMAPI.Toolkit.CoreInterfaces.csproj2
-rw-r--r--src/SMAPI.Toolkit/SMAPI.Toolkit.csproj2
-rw-r--r--src/SMAPI.Toolkit/SemanticVersion.cs14
-rw-r--r--src/SMAPI.Toolkit/Serialization/Models/Manifest.cs2
-rw-r--r--src/SMAPI.Toolkit/Serialization/Models/ManifestContentPackFor.cs2
-rw-r--r--src/SMAPI.Toolkit/Serialization/Models/ManifestDependency.cs2
-rw-r--r--src/SMAPI.Toolkit/Utilities/PathUtilities.cs36
10 files changed, 16 insertions, 58 deletions
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 @@
<PropertyGroup>
<RootNamespace>StardewModdingAPI.ModBuildConfig.Analyzer</RootNamespace>
<Version>3.0.0</Version>
- <TargetFramework>netstandard2.0</TargetFramework>
+ <TargetFramework>net5.0</TargetFramework>
<IncludeBuildOutput>false</IncludeBuildOutput>
<OutputPath>bin</OutputPath>
<LangVersion>latest</LangVersion>
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 @@
<PropertyGroup>
<!--build-->
<RootNamespace>StardewModdingAPI.ModBuildConfig</RootNamespace>
- <TargetFramework>netstandard2.0</TargetFramework>
+ <TargetFramework>net5.0</TargetFramework>
<LangVersion>latest</LangVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
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 @@
<PropertyGroup>
<RootNamespace>StardewModdingAPI</RootNamespace>
<Description>Provides toolkit interfaces which are available to SMAPI mods.</Description>
- <TargetFrameworks>net5.0; netstandard2.0</TargetFrameworks>
+ <TargetFrameworks>net5.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
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 @@
<PropertyGroup>
<RootNamespace>StardewModdingAPI.Toolkit</RootNamespace>
<Description>A library which encapsulates mod-handling logic for mod managers and tools. Not intended for use by mods.</Description>
- <TargetFrameworks>net5.0; netstandard2.0</TargetFrameworks>
+ <TargetFrameworks>net5.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
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
/// <param name="version">The version string.</param>
/// <param name="parsed">The parsed representation.</param>
/// <returns>Returns whether parsing the version succeeded.</returns>
- 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
/// <param name="allowNonStandard">Whether to allow non-standard extensions to semantic versioning.</param>
/// <param name="parsed">The parsed representation.</param>
/// <returns>Returns whether parsing the version succeeded.</returns>
- 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
*********/
/// <summary>Normalize whitespace in a raw string.</summary>
/// <param name="input">The input to strip.</param>
-#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
*********/
/// <summary>Normalize whitespace in a raw string.</summary>
/// <param name="input">The input to strip.</param>
-#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
*********/
/// <summary>Normalize whitespace in a raw string.</summary>
/// <param name="input">The input to strip.</param>
-#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
}
/// <summary>Get whether a path is relative and doesn't try to climb out of its containing folder (e.g. doesn't contain <c>../</c>).</summary>