From 2216e37726874af6ab164dbbaef454eb0f2218d0 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 6 Mar 2022 19:55:32 -0500 Subject: rework launch script argument parsing (#832) This commit... * replaces the internal `--no-reopen-terminal` arg with a documented `--use-current-shell` arg that works on Linux too; * replaces the new SKIP_TERMINAL environment variable with the existing SMAPI_NO_TERMINAL one; * moves argument parsing out of the 'initial setup' section (so it's easier for players to edit if needed); * simplfies argument parsing (no need to support short opt names or add arguments for the default behavior); * fixes arguments not parsed after the first unrecognized argument, so `--unknown --no-terminal` would still open a terminal. --- docs/technical/smapi.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'docs/technical') diff --git a/docs/technical/smapi.md b/docs/technical/smapi.md index d9aad875..7da1e0f1 100644 --- a/docs/technical/smapi.md +++ b/docs/technical/smapi.md @@ -38,18 +38,20 @@ or testing and may change without warning. On Linux/macOS, see _environment vari argument | purpose -------- | ------- -`--no-terminal` | SMAPI won't write anything to the console window. (Messages will still be written to the log file.) +`--no-terminal` | The SMAPI launcher won't try to open a terminal window, and SMAPI won't log anything to the console. (Messages will still be written to the log file.) +`--use-current-shell` | The SMAPI launcher won't try to open a terminal window, but SMAPI will still log to the console. (Messages will still be written to the log file.) `--mods-path` | The path to search for mods, if not the standard `Mods` folder. This can be a path relative to the game folder (like `--mods-path "Mods (test)"`) or an absolute path. ### Environment variables -The above SMAPI arguments don't work on Linux/macOS due to the way the game launcher works. You can -set temporary environment variables instead. For example: +The above SMAPI arguments may not work on Linux/macOS due to the way the game launcher works. You +can set temporary environment variables instead. For example: > SMAPI_MODS_PATH="Mods (multiplayer)" /path/to/StardewValley environment variable | purpose -------------------- | ------- -`SMAPI_NO_TERMINAL` | Equivalent to `--no-terminal` above. `SMAPI_MODS_PATH` | Equivalent to `--mods-path` above. +`SMAPI_NO_TERMINAL` | Equivalent to `--no-terminal` above. +`SMAPI_USE_CURRENT_SHELL` | Equivalent to `--use-current-shell` above. ### Compile flags SMAPI uses a small number of conditional compilation constants, which you can set by editing the -- cgit From b4e979cc991a0c2a45ad986210108edd2d43e43d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 6 Apr 2022 22:46:19 -0400 Subject: fix all warnings to simplify migration to nullable annotations (#837) --- docs/technical/mod-package.md | 1 + .../Framework/DiagnosticVerifier.Helper.cs | 24 ++++++++--------- .../Framework/DiagnosticVerifier.cs | 30 +++++++++++----------- .../AnalyzerReleases.Shipped.md | 7 +++++ .../SMAPI.ModBuildConfig.Analyzer.csproj | 4 +++ .../SMAPI.ModBuildConfig.csproj | 1 + src/SMAPI.Tests/Core/AssetNameTests.cs | 1 - src/SMAPI/Framework/ContentCoordinator.cs | 2 ++ .../Framework/ContentManagers/IContentManager.cs | 1 + src/SMAPI/Framework/ModHelpers/ModHelper.cs | 10 +++++++- src/SMAPI/Framework/SCore.cs | 4 +++ 11 files changed, 56 insertions(+), 29 deletions(-) create mode 100644 src/SMAPI.ModBuildConfig.Analyzer/AnalyzerReleases.Shipped.md (limited to 'docs/technical') diff --git a/docs/technical/mod-package.md b/docs/technical/mod-package.md index 5e408168..4c31f69b 100644 --- a/docs/technical/mod-package.md +++ b/docs/technical/mod-package.md @@ -414,6 +414,7 @@ when you compile it. ## Release notes ## Upcoming release * Added detection for Xbox app game folders. +* Internal refactoring. ## 4.0.0 Released 30 November 2021. diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Framework/DiagnosticVerifier.Helper.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Framework/DiagnosticVerifier.Helper.cs index 8d72fea1..68a892a9 100644 --- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Framework/DiagnosticVerifier.Helper.cs +++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Framework/DiagnosticVerifier.Helper.cs @@ -53,17 +53,17 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework protected static Diagnostic[] GetSortedDiagnosticsFromDocuments(DiagnosticAnalyzer analyzer, Document[] documents) { var projects = new HashSet(); - foreach (var document in documents) + foreach (Document document in documents) { projects.Add(document.Project); } var diagnostics = new List(); - foreach (var project in projects) + foreach (Project project in projects) { - var compilationWithAnalyzers = project.GetCompilationAsync().Result.WithAnalyzers(ImmutableArray.Create(analyzer)); + CompilationWithAnalyzers compilationWithAnalyzers = project.GetCompilationAsync().Result.WithAnalyzers(ImmutableArray.Create(analyzer)); var diags = compilationWithAnalyzers.GetAnalyzerDiagnosticsAsync().Result; - foreach (var diag in diags) + foreach (Diagnostic diag in diags) { if (diag.Location == Location.None || diag.Location.IsInMetadata) { @@ -73,8 +73,8 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework { for (int i = 0; i < documents.Length; i++) { - var document = documents[i]; - var tree = document.GetSyntaxTreeAsync().Result; + Document document = documents[i]; + SyntaxTree tree = document.GetSyntaxTreeAsync().Result; if (tree == diag.Location.SourceTree) { diagnostics.Add(diag); @@ -115,7 +115,7 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework throw new ArgumentException("Unsupported Language"); } - var project = CreateProject(sources, language); + Project project = CreateProject(sources, language); var documents = project.Documents.ToArray(); if (sources.Length != documents.Length) @@ -148,9 +148,9 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework string fileNamePrefix = DefaultFilePathPrefix; string fileExt = language == LanguageNames.CSharp ? CSharpDefaultFileExt : VisualBasicDefaultExt; - var projectId = ProjectId.CreateNewId(debugName: TestProjectName); + ProjectId projectId = ProjectId.CreateNewId(debugName: TestProjectName); - var solution = new AdhocWorkspace() + Solution solution = new AdhocWorkspace() .CurrentSolution .AddProject(projectId, TestProjectName, TestProjectName, language) .AddMetadataReference(projectId, DiagnosticVerifier.SelfReference) @@ -160,10 +160,10 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework .AddMetadataReference(projectId, CodeAnalysisReference); int count = 0; - foreach (var source in sources) + foreach (string source in sources) { - var newFileName = fileNamePrefix + count + "." + fileExt; - var documentId = DocumentId.CreateNewId(projectId, debugName: newFileName); + string newFileName = fileNamePrefix + count + "." + fileExt; + DocumentId documentId = DocumentId.CreateNewId(projectId, debugName: newFileName); solution = solution.AddDocument(documentId, newFileName, SourceText.From(source)); count++; } diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Framework/DiagnosticVerifier.cs b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Framework/DiagnosticVerifier.cs index 09d3a3f8..4170042d 100644 --- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/Framework/DiagnosticVerifier.cs +++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/Framework/DiagnosticVerifier.cs @@ -43,7 +43,7 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework /// DiagnosticResults that should appear after the analyzer is run on the source protected void VerifyCSharpDiagnostic(string source, params DiagnosticResult[] expected) { - VerifyDiagnostics(new[] { source }, LanguageNames.CSharp, GetCSharpDiagnosticAnalyzer(), expected); + this.VerifyDiagnostics(new[] { source }, LanguageNames.CSharp, this.GetCSharpDiagnosticAnalyzer(), expected); } /// @@ -54,7 +54,7 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework /// DiagnosticResults that should appear after the analyzer is run on the sources protected void VerifyCSharpDiagnostic(string[] sources, params DiagnosticResult[] expected) { - VerifyDiagnostics(sources, LanguageNames.CSharp, GetCSharpDiagnosticAnalyzer(), expected); + this.VerifyDiagnostics(sources, LanguageNames.CSharp, this.GetCSharpDiagnosticAnalyzer(), expected); } /// @@ -67,8 +67,8 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework /// DiagnosticResults that should appear after the analyzer is run on the sources private void VerifyDiagnostics(string[] sources, string language, DiagnosticAnalyzer analyzer, params DiagnosticResult[] expected) { - var diagnostics = GetSortedDiagnostics(sources, language, analyzer); - VerifyDiagnosticResults(diagnostics, analyzer, expected); + var diagnostics = DiagnosticVerifier.GetSortedDiagnostics(sources, language, analyzer); + DiagnosticVerifier.VerifyDiagnosticResults(diagnostics, analyzer, expected); } #endregion @@ -88,7 +88,7 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework if (expectedCount != actualCount) { - string diagnosticsOutput = actualResults.Any() ? FormatDiagnostics(analyzer, actualResults.ToArray()) : " NONE."; + string diagnosticsOutput = actualResults.Any() ? DiagnosticVerifier.FormatDiagnostics(analyzer, actualResults.ToArray()) : " NONE."; Assert.IsTrue(false, string.Format("Mismatch between number of diagnostics returned, expected \"{0}\" actual \"{1}\"\r\n\r\nDiagnostics:\r\n{2}\r\n", expectedCount, actualCount, diagnosticsOutput)); @@ -105,12 +105,12 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework { Assert.IsTrue(false, string.Format("Expected:\nA project diagnostic with No location\nActual:\n{0}", - FormatDiagnostics(analyzer, actual))); + DiagnosticVerifier.FormatDiagnostics(analyzer, actual))); } } else { - VerifyDiagnosticLocation(analyzer, actual, actual.Location, expected.Locations.First()); + DiagnosticVerifier.VerifyDiagnosticLocation(analyzer, actual, actual.Location, expected.Locations.First()); var additionalLocations = actual.AdditionalLocations.ToArray(); if (additionalLocations.Length != expected.Locations.Length - 1) @@ -118,12 +118,12 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework Assert.IsTrue(false, string.Format("Expected {0} additional locations but got {1} for Diagnostic:\r\n {2}\r\n", expected.Locations.Length - 1, additionalLocations.Length, - FormatDiagnostics(analyzer, actual))); + DiagnosticVerifier.FormatDiagnostics(analyzer, actual))); } for (int j = 0; j < additionalLocations.Length; ++j) { - VerifyDiagnosticLocation(analyzer, actual, additionalLocations[j], expected.Locations[j + 1]); + DiagnosticVerifier.VerifyDiagnosticLocation(analyzer, actual, additionalLocations[j], expected.Locations[j + 1]); } } @@ -131,21 +131,21 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework { Assert.IsTrue(false, string.Format("Expected diagnostic id to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", - expected.Id, actual.Id, FormatDiagnostics(analyzer, actual))); + expected.Id, actual.Id, DiagnosticVerifier.FormatDiagnostics(analyzer, actual))); } if (actual.Severity != expected.Severity) { Assert.IsTrue(false, string.Format("Expected diagnostic severity to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", - expected.Severity, actual.Severity, FormatDiagnostics(analyzer, actual))); + expected.Severity, actual.Severity, DiagnosticVerifier.FormatDiagnostics(analyzer, actual))); } if (actual.GetMessage() != expected.Message) { Assert.IsTrue(false, string.Format("Expected diagnostic message to be \"{0}\" was \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", - expected.Message, actual.GetMessage(), FormatDiagnostics(analyzer, actual))); + expected.Message, actual.GetMessage(), DiagnosticVerifier.FormatDiagnostics(analyzer, actual))); } } } @@ -163,7 +163,7 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework Assert.IsTrue(actualSpan.Path == expected.Path || (actualSpan.Path != null && actualSpan.Path.Contains("Test0.") && expected.Path.Contains("Test.")), string.Format("Expected diagnostic to be in file \"{0}\" was actually in file \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", - expected.Path, actualSpan.Path, FormatDiagnostics(analyzer, diagnostic))); + expected.Path, actualSpan.Path, DiagnosticVerifier.FormatDiagnostics(analyzer, diagnostic))); var actualLinePosition = actualSpan.StartLinePosition; @@ -174,7 +174,7 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework { Assert.IsTrue(false, string.Format("Expected diagnostic to be on line \"{0}\" was actually on line \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", - expected.Line, actualLinePosition.Line + 1, FormatDiagnostics(analyzer, diagnostic))); + expected.Line, actualLinePosition.Line + 1, DiagnosticVerifier.FormatDiagnostics(analyzer, diagnostic))); } } @@ -185,7 +185,7 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework { Assert.IsTrue(false, string.Format("Expected diagnostic to start at column \"{0}\" was actually at column \"{1}\"\r\n\r\nDiagnostic:\r\n {2}\r\n", - expected.Column, actualLinePosition.Character + 1, FormatDiagnostics(analyzer, diagnostic))); + expected.Column, actualLinePosition.Character + 1, DiagnosticVerifier.FormatDiagnostics(analyzer, diagnostic))); } } } diff --git a/src/SMAPI.ModBuildConfig.Analyzer/AnalyzerReleases.Shipped.md b/src/SMAPI.ModBuildConfig.Analyzer/AnalyzerReleases.Shipped.md new file mode 100644 index 00000000..9a46676d --- /dev/null +++ b/src/SMAPI.ModBuildConfig.Analyzer/AnalyzerReleases.Shipped.md @@ -0,0 +1,7 @@ +## Release 2.1.0 +### New Rules +Rule ID | Category | Severity | Notes +------------------------- | ------------------ | -------- | ------------------------------------------------------------ +AvoidImplicitNetFieldCast | SMAPI.CommonErrors | Warning | See [documentation](https://smapi.io/package/code-warnings). +AvoidNetField | SMAPI.CommonErrors | Warning | See [documentation](https://smapi.io/package/code-warnings). +AvoidObsoleteField | SMAPI.CommonErrors | Warning | See [documentation](https://smapi.io/package/code-warnings). diff --git a/src/SMAPI.ModBuildConfig.Analyzer/SMAPI.ModBuildConfig.Analyzer.csproj b/src/SMAPI.ModBuildConfig.Analyzer/SMAPI.ModBuildConfig.Analyzer.csproj index 3fadc37a..7ac3277e 100644 --- a/src/SMAPI.ModBuildConfig.Analyzer/SMAPI.ModBuildConfig.Analyzer.csproj +++ b/src/SMAPI.ModBuildConfig.Analyzer/SMAPI.ModBuildConfig.Analyzer.csproj @@ -12,6 +12,10 @@ + + + + diff --git a/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj b/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj index 0bc8c45e..82eac7f6 100644 --- a/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj +++ b/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj @@ -5,6 +5,7 @@ netstandard2.0 latest true + true Pathoschild.Stardew.ModBuildConfig diff --git a/src/SMAPI.Tests/Core/AssetNameTests.cs b/src/SMAPI.Tests/Core/AssetNameTests.cs index b7e34191..ef8a08ef 100644 --- a/src/SMAPI.Tests/Core/AssetNameTests.cs +++ b/src/SMAPI.Tests/Core/AssetNameTests.cs @@ -34,7 +34,6 @@ namespace SMAPI.Tests.Core name = PathUtilities.NormalizeAssetName(name); // act - string calledWithLocale = null; IAssetName assetName = AssetName.Parse(name, parseLocale: _ => expectedLanguageCode); // assert diff --git a/src/SMAPI/Framework/ContentCoordinator.cs b/src/SMAPI/Framework/ContentCoordinator.cs index bfde649a..81820b05 100644 --- a/src/SMAPI/Framework/ContentCoordinator.cs +++ b/src/SMAPI/Framework/ContentCoordinator.cs @@ -610,6 +610,7 @@ namespace StardewModdingAPI.Framework yield return group; // legacy load operations +#pragma warning disable CS0612, CS0618 // deprecated code foreach (ModLinked loader in this.Loaders) { // check if loader applies @@ -695,6 +696,7 @@ namespace StardewModdingAPI.Framework } ); } +#pragma warning restore CS0612, CS0618 } /// Get an asset info compatible with legacy and instances, which always expect the base name. diff --git a/src/SMAPI/Framework/ContentManagers/IContentManager.cs b/src/SMAPI/Framework/ContentManagers/IContentManager.cs index c4625761..c8b2ae64 100644 --- a/src/SMAPI/Framework/ContentManagers/IContentManager.cs +++ b/src/SMAPI/Framework/ContentManagers/IContentManager.cs @@ -38,6 +38,7 @@ namespace StardewModdingAPI.Framework.ContentManagers /// Load an asset through the content pipeline, using a localized variant of the if available. /// The type of asset to load. /// The asset name relative to the loader root directory. + /// The language for which to load the asset. /// Whether to read/write the loaded asset to the asset cache. T LoadLocalized(IAssetName assetName, LocalizedContentManager.LanguageCode language, bool useCache); diff --git a/src/SMAPI/Framework/ModHelpers/ModHelper.cs b/src/SMAPI/Framework/ModHelpers/ModHelper.cs index 2a8aeb3a..3cfe52bf 100644 --- a/src/SMAPI/Framework/ModHelpers/ModHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/ModHelper.cs @@ -95,7 +95,13 @@ namespace StardewModdingAPI.Framework.ModHelpers /// An API for reading translations stored in the mod's i18n folder. /// An argument is null or empty. /// The path does not exist on disk. - public ModHelper(string modID, string modDirectory, Func currentInputState, IModEvents events, ContentHelper contentHelper, IGameContentHelper gameContentHelper, IModContentHelper modContentHelper, IContentPackHelper contentPackHelper, ICommandHelper commandHelper, IDataHelper dataHelper, IModRegistry modRegistry, IReflectionHelper reflectionHelper, IMultiplayerHelper multiplayer, ITranslationHelper translationHelper) + public ModHelper( + string modID, string modDirectory, Func currentInputState, IModEvents events, +#pragma warning disable CS0612 // deprecated code + ContentHelper contentHelper, +#pragma warning restore CS0612 + IGameContentHelper gameContentHelper, IModContentHelper modContentHelper, IContentPackHelper contentPackHelper, ICommandHelper commandHelper, IDataHelper dataHelper, IModRegistry modRegistry, IReflectionHelper reflectionHelper, IMultiplayerHelper multiplayer, ITranslationHelper translationHelper + ) : base(modID) { // validate directory @@ -106,7 +112,9 @@ namespace StardewModdingAPI.Framework.ModHelpers // initialize this.DirectoryPath = modDirectory; +#pragma warning disable CS0612 // deprecated code this.ContentImpl = contentHelper ?? throw new ArgumentNullException(nameof(contentHelper)); +#pragma warning restore CS0612 this.GameContent = gameContentHelper ?? throw new ArgumentNullException(nameof(gameContentHelper)); this.ModContent = modContentHelper ?? throw new ArgumentNullException(nameof(modContentHelper)); this.ContentPacks = contentPackHelper ?? throw new ArgumentNullException(nameof(contentPackHelper)); diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index 8a5c10f6..6ca463a2 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -1593,6 +1593,7 @@ namespace StardewModdingAPI.Framework // initialize loaded non-content-pack mods this.Monitor.Log("Launching mods...", LogLevel.Debug); +#pragma warning disable CS0612, CS0618 // deprecated code foreach (IModMetadata metadata in loadedMods) { // add interceptors @@ -1628,6 +1629,7 @@ namespace StardewModdingAPI.Framework content.ObservableAssetEditors.CollectionChanged += (_, e) => this.OnAssetInterceptorsChanged(metadata, e.NewItems?.Cast(), e.OldItems?.Cast(), this.ContentCore.Editors); content.ObservableAssetLoaders.CollectionChanged += (_, e) => this.OnAssetInterceptorsChanged(metadata, e.NewItems?.Cast(), e.OldItems?.Cast(), this.ContentCore.Loaders); } +#pragma warning restore CS0612, CS0618 // call entry method try @@ -1847,7 +1849,9 @@ namespace StardewModdingAPI.Framework IModEvents events = new ModEvents(mod, this.EventManager); ICommandHelper commandHelper = new CommandHelper(mod, this.CommandManager); CaseInsensitivePathCache relativePathCache = this.ContentCore.GetCaseInsensitivePathCache(mod.DirectoryPath); +#pragma warning disable CS0612 // deprecated code ContentHelper contentHelper = new(contentCore, mod.DirectoryPath, manifest.UniqueID, mod.DisplayName, monitor); +#pragma warning restore CS0612 GameContentHelper gameContentHelper = new(contentCore, manifest.UniqueID, mod.DisplayName, monitor); IModContentHelper modContentHelper = new ModContentHelper(contentCore, mod.DirectoryPath, manifest.UniqueID, mod.DisplayName, gameContentHelper.GetUnderlyingContentManager(), relativePathCache); IContentPackHelper contentPackHelper = new ContentPackHelper(manifest.UniqueID, new Lazy(GetContentPacks), CreateFakeContentPack); -- cgit From 6b05296e71c32abd158f354eeeaf1e135e72e6e2 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 7 Apr 2022 01:51:50 -0400 Subject: migrate mod build package to .NET 5 to allow full nullable annotations (#837) --- docs/technical/mod-package.md | 10 ++++++ .../SMAPI.ModBuildConfig.Analyzer.csproj | 2 +- .../SMAPI.ModBuildConfig.csproj | 2 +- .../SMAPI.Toolkit.CoreInterfaces.csproj | 2 +- src/SMAPI.Toolkit/SMAPI.Toolkit.csproj | 2 +- src/SMAPI.Toolkit/SemanticVersion.cs | 14 ++------- src/SMAPI.Toolkit/Serialization/Models/Manifest.cs | 2 -- .../Serialization/Models/ManifestContentPackFor.cs | 2 -- .../Serialization/Models/ManifestDependency.cs | 2 -- src/SMAPI.Toolkit/Utilities/PathUtilities.cs | 36 ---------------------- 10 files changed, 16 insertions(+), 58 deletions(-) (limited to 'docs/technical') 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 ../). -- cgit From 238045ba9c5937f684cad3c55a8f9b9c2733e45f Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 7 Apr 2022 22:19:48 -0400 Subject: reverse mod build package migration to .NET 5 (#837) The migrated package didn't work consistently in VIsual Studio, so this suppresses nullable annotations in .NET Standard instead. --- build/common.targets | 5 ++- docs/technical/mod-package.md | 10 ------ .../SMAPI.ModBuildConfig.Analyzer.csproj | 2 +- .../SMAPI.ModBuildConfig.csproj | 2 +- .../SMAPI.Toolkit.CoreInterfaces.csproj | 2 +- .../Framework/SemanticVersionReader.cs | 7 +++- .../Framework/UpdateData/UpdateKey.cs | 2 ++ src/SMAPI.Toolkit/SMAPI.Toolkit.csproj | 2 +- src/SMAPI.Toolkit/SemanticVersion.cs | 14 ++++++-- src/SMAPI.Toolkit/Serialization/JsonHelper.cs | 7 +++- src/SMAPI.Toolkit/Serialization/Models/Manifest.cs | 2 ++ .../Serialization/Models/ManifestContentPackFor.cs | 2 ++ .../Serialization/Models/ManifestDependency.cs | 2 ++ src/SMAPI.Toolkit/Utilities/PathUtilities.cs | 42 +++++++++++++++++++++- 14 files changed, 81 insertions(+), 20 deletions(-) (limited to 'docs/technical') diff --git a/build/common.targets b/build/common.targets index 258b48f2..c227190a 100644 --- a/build/common.targets +++ b/build/common.targets @@ -5,7 +5,10 @@ SMAPI latest $(AssemblySearchPaths);{GAC} - enable + + + enable + $(NoWarn);CS8632 $(DefineConstants);SMAPI_FOR_WINDOWS diff --git a/docs/technical/mod-package.md b/docs/technical/mod-package.md index 6123b28f..4c31f69b 100644 --- a/docs/technical/mod-package.md +++ b/docs/technical/mod-package.md @@ -413,19 +413,9 @@ 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 69fd3dbd..7ac3277e 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 - net5.0 + netstandard2.0 false bin latest diff --git a/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj b/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj index 8e70293e..82eac7f6 100644 --- a/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj +++ b/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj @@ -2,7 +2,7 @@ StardewModdingAPI.ModBuildConfig - net5.0 + netstandard2.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 d69d53d5..4c92b4db 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 + net5.0; netstandard2.0 true diff --git a/src/SMAPI.Toolkit/Framework/SemanticVersionReader.cs b/src/SMAPI.Toolkit/Framework/SemanticVersionReader.cs index 836b1134..939be771 100644 --- a/src/SMAPI.Toolkit/Framework/SemanticVersionReader.cs +++ b/src/SMAPI.Toolkit/Framework/SemanticVersionReader.cs @@ -105,7 +105,12 @@ namespace StardewModdingAPI.Toolkit.Framework /// The raw characters to parse. /// The index of the next character to read. /// The parsed tag. - private static bool TryParseTag(char[] raw, ref int index, [NotNullWhen(true)] out string? tag) + private static bool TryParseTag(char[] raw, ref int index, +#if NET5_0_OR_GREATER + [NotNullWhen(true)] +#endif + out string? tag + ) { // read tag length int length = 0; diff --git a/src/SMAPI.Toolkit/Framework/UpdateData/UpdateKey.cs b/src/SMAPI.Toolkit/Framework/UpdateData/UpdateKey.cs index d40d8f2b..4c9ca2ff 100644 --- a/src/SMAPI.Toolkit/Framework/UpdateData/UpdateKey.cs +++ b/src/SMAPI.Toolkit/Framework/UpdateData/UpdateKey.cs @@ -16,7 +16,9 @@ namespace StardewModdingAPI.Toolkit.Framework.UpdateData public ModSiteKey Site { get; } /// The mod ID within the repository. +#if NET5_0_OR_GREATER [MemberNotNullWhen(true, nameof(LooksValid))] +#endif public string? ID { get; } /// If specified, a substring in download names/descriptions to match. diff --git a/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj b/src/SMAPI.Toolkit/SMAPI.Toolkit.csproj index 6a8c4c43..ec27bf79 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 + net5.0; netstandard2.0 true diff --git a/src/SMAPI.Toolkit/SemanticVersion.cs b/src/SMAPI.Toolkit/SemanticVersion.cs index cbdd7a85..2cb27e11 100644 --- a/src/SMAPI.Toolkit/SemanticVersion.cs +++ b/src/SMAPI.Toolkit/SemanticVersion.cs @@ -198,7 +198,12 @@ namespace StardewModdingAPI.Toolkit /// The version string. /// The parsed representation. /// Returns whether parsing the version succeeded. - public static bool TryParse(string? version, [NotNullWhen(true)] out ISemanticVersion? parsed) + public static bool TryParse(string? version, +#if NET5_0_OR_GREATER + [NotNullWhen(true)] +#endif + out ISemanticVersion? parsed + ) { return SemanticVersion.TryParse(version, allowNonStandard: false, out parsed); } @@ -208,7 +213,12 @@ 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, [NotNullWhen(true)] out ISemanticVersion? parsed) + public static bool TryParse(string? version, bool allowNonStandard, +#if NET5_0_OR_GREATER + [NotNullWhen(true)] +#endif + out ISemanticVersion? parsed + ) { if (version == null) { diff --git a/src/SMAPI.Toolkit/Serialization/JsonHelper.cs b/src/SMAPI.Toolkit/Serialization/JsonHelper.cs index 7d1804e5..3c9308f2 100644 --- a/src/SMAPI.Toolkit/Serialization/JsonHelper.cs +++ b/src/SMAPI.Toolkit/Serialization/JsonHelper.cs @@ -37,7 +37,12 @@ namespace StardewModdingAPI.Toolkit.Serialization /// Returns false if the file doesn't exist, else true. /// The given is empty or invalid. /// The file contains invalid JSON. - public bool ReadJsonFileIfExists(string fullPath, [NotNullWhen(true)] out TModel? result) + public bool ReadJsonFileIfExists(string fullPath, +#if NET5_0_OR_GREATER + [NotNullWhen(true)] +#endif + out TModel? result + ) { // validate if (string.IsNullOrWhiteSpace(fullPath)) diff --git a/src/SMAPI.Toolkit/Serialization/Models/Manifest.cs b/src/SMAPI.Toolkit/Serialization/Models/Manifest.cs index 3ab5edfb..01010602 100644 --- a/src/SMAPI.Toolkit/Serialization/Models/Manifest.cs +++ b/src/SMAPI.Toolkit/Serialization/Models/Manifest.cs @@ -115,7 +115,9 @@ 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 dcdbcf74..f7dc8aa8 100644 --- a/src/SMAPI.Toolkit/Serialization/Models/ManifestContentPackFor.cs +++ b/src/SMAPI.Toolkit/Serialization/Models/ManifestContentPackFor.cs @@ -33,7 +33,9 @@ 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 5d1b73b1..fa254ea7 100644 --- a/src/SMAPI.Toolkit/Serialization/Models/ManifestDependency.cs +++ b/src/SMAPI.Toolkit/Serialization/Models/ManifestDependency.cs @@ -54,7 +54,9 @@ 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 9b7a78a0..136279f2 100644 --- a/src/SMAPI.Toolkit/Utilities/PathUtilities.cs +++ b/src/SMAPI.Toolkit/Utilities/PathUtilities.cs @@ -50,7 +50,9 @@ namespace StardewModdingAPI.Toolkit.Utilities /// Normalize an asset name to match how MonoGame's content APIs would normalize and cache it. /// The asset name to normalize. [Pure] +#if NET5_0_OR_GREATER [return: NotNullIfNotNull("assetName")] +#endif public static string? NormalizeAssetName(string? assetName) { assetName = assetName?.Trim(); @@ -64,7 +66,9 @@ namespace StardewModdingAPI.Toolkit.Utilities /// The file path to normalize. /// This should only be used for file paths. For asset names, use instead. [Pure] +#if NET5_0_OR_GREATER [return: NotNullIfNotNull("path")] +#endif public static string? NormalizePath(string? path) { path = path?.Trim(); @@ -89,7 +93,7 @@ namespace StardewModdingAPI.Toolkit.Utilities } // keep trailing separator - if ((!hasRoot || segments.Any()) && PathUtilities.PossiblePathSeparators.Contains(path[^1])) + if ((!hasRoot || segments.Any()) && PathUtilities.PossiblePathSeparators.Contains(path[path.Length - 1])) newPath += PathUtilities.PreferredPathSeparator; return newPath; @@ -101,7 +105,43 @@ 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 ../). -- cgit From 288ef5dc0715339a3a0bf89975a6db7ab7408e2b Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 9 Apr 2022 12:03:30 -0400 Subject: add environment variable form of new CLI args, update docs --- docs/release-notes.md | 2 +- docs/technical/smapi.md | 4 +++- src/SMAPI/Program.cs | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) (limited to 'docs/technical') diff --git a/docs/release-notes.md b/docs/release-notes.md index bb30f31a..9fc0d432 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -20,7 +20,6 @@ * Added `data-*` attributes to the log parser page for external tools. * Fixed JSON validator showing incorrect error for update keys without a subkey. - ### For mod authors This is a big release that includes the new APIs planned for SMAPI 4.0.0, alongside the old ones. @@ -40,6 +39,7 @@ the C# mod that loads them is updated. _This adds support for many previously unsupported cases: proxied interfaces in return values or input arguments, proxied enums if their values match, generic methods, and more. Existing mod APIs should work fine as-is._ * Mod files loaded through SMAPI APIs (including `helper.Content.Load`) are now case-insensitive, even on Linux. * Other improvements: + * Added [command-line arguments](technical/smapi.md#command-line-arguments) to toggle developer mode (thanks to Tondorian!). * Added `IContentPack.ModContent` property. * Added `Constants.ContentPath`. * Added `IAssetName` fields to the info received by `IAssetEditor` and `IAssetLoader` methods. diff --git a/docs/technical/smapi.md b/docs/technical/smapi.md index 7da1e0f1..e117db2f 100644 --- a/docs/technical/smapi.md +++ b/docs/technical/smapi.md @@ -33,11 +33,12 @@ argument | purpose `--uninstall` | Preselects the uninstall action, skipping the prompt asking what the user wants to do. `--game-path "path"` | Specifies the full path to the folder containing the Stardew Valley executable, skipping automatic detection and any prompt to choose a path. If the path is not valid, the installer displays an error. -SMAPI itself recognises two arguments **on Windows only**, but these are intended for internal use +SMAPI itself recognises five arguments **on Windows only**, but these are intended for internal use or testing and may change without warning. On Linux/macOS, see _environment variables_ below. argument | purpose -------- | ------- +`--developer-mode`
`--developer-mode-off` | Enable or disable features intended for mod developers. Currently this only makes `TRACE`-level messages appear in the console. `--no-terminal` | The SMAPI launcher won't try to open a terminal window, and SMAPI won't log anything to the console. (Messages will still be written to the log file.) `--use-current-shell` | The SMAPI launcher won't try to open a terminal window, but SMAPI will still log to the console. (Messages will still be written to the log file.) `--mods-path` | The path to search for mods, if not the standard `Mods` folder. This can be a path relative to the game folder (like `--mods-path "Mods (test)"`) or an absolute path. @@ -49,6 +50,7 @@ can set temporary environment variables instead. For example: environment variable | purpose -------------------- | ------- +`SMAPI_DEVELOPER_MODE` | Equivalent to `--developer-mode` and `--developer-mode-off` above. The value must be `true` or `false`. `SMAPI_MODS_PATH` | Equivalent to `--mods-path` above. `SMAPI_NO_TERMINAL` | Equivalent to `--no-terminal` above. `SMAPI_USE_CURRENT_SHELL` | Equivalent to `--use-current-shell` above. diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs index 0c9c2d87..b2e213fe 100644 --- a/src/SMAPI/Program.cs +++ b/src/SMAPI/Program.cs @@ -200,6 +200,12 @@ namespace StardewModdingAPI // get from environment variables if (string.IsNullOrWhiteSpace(rawModsPath)) rawModsPath = Environment.GetEnvironmentVariable("SMAPI_MODS_PATH"); + if (developerMode is null) + { + string rawDeveloperMode = Environment.GetEnvironmentVariable("SMAPI_DEVELOPER_MODE"); + if (rawDeveloperMode != null) + developerMode = bool.Parse(rawDeveloperMode); + } // normalize modsPath = !string.IsNullOrWhiteSpace(rawModsPath) -- cgit From eb125f1994c605704be384ffdcf4da64b88d9405 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 14 Apr 2022 18:14:08 -0400 Subject: fix assembly version conflict error in mod build package --- docs/technical/mod-package.md | 1 + src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'docs/technical') diff --git a/docs/technical/mod-package.md b/docs/technical/mod-package.md index 4c31f69b..b29f3f72 100644 --- a/docs/technical/mod-package.md +++ b/docs/technical/mod-package.md @@ -414,6 +414,7 @@ when you compile it. ## Release notes ## Upcoming release * Added detection for Xbox app game folders. +* Fixed "_conflicts between different versions of Microsoft.Win32.Registry_" warnings in recent SMAPI versions. * Internal refactoring. ## 4.0.0 diff --git a/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj b/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj index 82eac7f6..09792d3c 100644 --- a/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj +++ b/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj @@ -25,6 +25,12 @@ + + + -- cgit From 43c875c4c225ad248790c29f3abcb787cbbd2d7f Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 14 Apr 2022 19:21:18 -0400 Subject: prepare mod build package 4.0.1 for release --- docs/technical/mod-package.md | 4 +++- src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'docs/technical') diff --git a/docs/technical/mod-package.md b/docs/technical/mod-package.md index b29f3f72..c632af84 100644 --- a/docs/technical/mod-package.md +++ b/docs/technical/mod-package.md @@ -412,7 +412,9 @@ The NuGet package is generated automatically in `StardewModdingAPI.ModBuildConfi when you compile it. ## Release notes -## Upcoming release +## 4.0.1 +Released 14 April 2022. + * Added detection for Xbox app game folders. * Fixed "_conflicts between different versions of Microsoft.Win32.Registry_" warnings in recent SMAPI versions. * Internal refactoring. diff --git a/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj b/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj index 09792d3c..c5790186 100644 --- a/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj +++ b/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj @@ -10,7 +10,7 @@ Pathoschild.Stardew.ModBuildConfig Build package for SMAPI mods - 4.0.0 + 4.0.1 Pathoschild Automates the build configuration for crossplatform Stardew Valley SMAPI mods. For SMAPI 3.13.0 or later. MIT -- cgit From 9939061615c41fabca004bf8f5b6f2b018a40b06 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 19 Apr 2022 19:26:12 -0400 Subject: fix typo --- docs/technical/smapi.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/technical') diff --git a/docs/technical/smapi.md b/docs/technical/smapi.md index e117db2f..789ea20b 100644 --- a/docs/technical/smapi.md +++ b/docs/technical/smapi.md @@ -83,7 +83,7 @@ folder before compiling. ## Prepare a release ### On any platform **⚠ Ideally we'd have one set of instructions for all platforms. The instructions in this section -will produce a fully functional release for all supported platfrms, _except_ that the application +will produce a fully functional release for all supported platforms, _except_ that the application icon for SMAPI on Windows will disappear due to [.NET runtime bug 3828](https://github.com/dotnet/runtime/issues/3828). Until that's fixed, see the _[on Windows](#on-windows)_ section below to create a build that retains the icon.** -- cgit From f507bd0f9cebe68fa2adf176740a0d00b3e6f884 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 29 Apr 2022 22:55:12 -0400 Subject: set SMAPI version from main build script --- build/unix/prepare-install-package.sh | 21 ++++++++++++++------- build/windows/prepare-install-package.ps1 | 20 ++++++++++++++------ docs/technical/smapi.md | 22 ++++++++++------------ 3 files changed, 38 insertions(+), 25 deletions(-) (limited to 'docs/technical') diff --git a/build/unix/prepare-install-package.sh b/build/unix/prepare-install-package.sh index 9dd24b82..e9b413b4 100755 --- a/build/unix/prepare-install-package.sh +++ b/build/unix/prepare-install-package.sh @@ -28,6 +28,20 @@ declare -A msBuildPlatformNames=(["linux"]="Unix" ["macOS"]="OSX" ["windows"]="W cd "`dirname "$0"`/../.." +########## +## Set version +########## +# get version number +version="$1" +if [ $# -eq 0 ]; then + echo "SMAPI release version (like '4.0.0'):" + read version +fi + +# set version +. ${0%/*}/set-smapi-version.sh "$version" + + ########## ## Clear old build files ########## @@ -190,13 +204,6 @@ done ########## ## Create release zips ########## -# get version number -version="$1" -if [ $# -eq 0 ]; then - echo "SMAPI release version (like '4.0.0'):" - read version -fi - # rename folders mv "$packagePath" "bin/SMAPI $version installer" mv "$packageDevPath" "bin/SMAPI $version installer for developers" diff --git a/build/windows/prepare-install-package.ps1 b/build/windows/prepare-install-package.ps1 index b6a23124..5a1e0bcc 100644 --- a/build/windows/prepare-install-package.ps1 +++ b/build/windows/prepare-install-package.ps1 @@ -12,6 +12,20 @@ . "$PSScriptRoot\lib\in-place-regex.ps1" + +########## +## Set version +########## +# get version number +$version = $args[0] +if (!$version) { + $version = Read-Host "SMAPI release version (like '4.0.0')" +} + +# set version +. "$PSScriptRoot/set-smapi-version.ps1" "$version" + + ########## ## Constants ########## @@ -197,12 +211,6 @@ foreach ($folder in $folders) { ########### ### Create release zips ########### -# get version number -$version = $args[0] -if (!$version) { - $version = Read-Host "SMAPI release version (like '4.0.0')" -} - # rename folders mv "$packagePath" "bin/SMAPI $version installer" mv "$packageDevPath" "bin/SMAPI $version installer for developers" diff --git a/docs/technical/smapi.md b/docs/technical/smapi.md index 789ea20b..4d75aef2 100644 --- a/docs/technical/smapi.md +++ b/docs/technical/smapi.md @@ -120,8 +120,10 @@ Windows](#on-windows)_ section below to create a build that retains the icon.** 2. Launch the game through the Steam UI. ### Prepare the release -1. Run `build/unix/set-smapi-version.sh` to set the SMAPI version. Make sure you use a [semantic - version](https://semver.org). Recommended format: +1. Run `build/unix/prepare-install-package.sh VERSION_HERE` to create the release package in the + root `bin` folder. + + Make sure you use a [semantic version](https://semver.org). Recommended format: build type | format | example :--------- | :----------------------- | :------ @@ -129,9 +131,6 @@ Windows](#on-windows)_ section below to create a build that retains the icon.** prerelease | `-beta.` | `4.0.0-beta.20251230` release | `` | `4.0.0` -2. Run `build/unix/prepare-install-package.sh` to create the release package in the root `bin` - folder. - ### On Windows #### First-time setup 1. Set up Windows Subsystem for Linux (WSL): @@ -147,8 +146,10 @@ Windows](#on-windows)_ section below to create a build that retains the icon.** ``` ### Prepare the release -1. Run `build/windows/set-smapi-version.ps1` in PowerShell to set the SMAPI version. Make sure you - use a [semantic version](https://semver.org). Recommended format: +1. Run `build/windows/prepare-install-package.ps1 VERSION_HERE` in PowerShell to create the release + package folders in the root `bin` folder. + + Make sure you use a [semantic version](https://semver.org). Recommended format: build type | format | example :--------- | :----------------------- | :------ @@ -156,12 +157,9 @@ Windows](#on-windows)_ section below to create a build that retains the icon.** prerelease | `-beta.` | `4.0.0-beta.20251230` release | `` | `4.0.0` -2. Run `build/windows/prepare-install-package.ps1` in PowerShell to create the release package - folders in the root `bin` folder. - -3. Launch WSL and run this script: +2. Launch WSL and run this script: ```bash - # edit to match the build created in steps 1-2 + # edit to match the build created in steps 1 # In WSL, `/mnt/c/example` accesses `C:\example` on the Windows filesystem. version="4.0.0" binFolder="/mnt/e/source/_Stardew/SMAPI/bin" -- cgit From 0e4aa65708df7ca4096b9019428d9fccabd37384 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 1 May 2022 17:33:41 -0400 Subject: fix crossplatform build scripts --- build/unix/prepare-install-package.sh | 22 ++++------- build/windows/prepare-install-package.ps1 | 66 +++++++++++++++++++------------ docs/technical/smapi.md | 3 ++ 3 files changed, 51 insertions(+), 40 deletions(-) (limited to 'docs/technical') diff --git a/build/unix/prepare-install-package.sh b/build/unix/prepare-install-package.sh index e9b413b4..9b195f37 100755 --- a/build/unix/prepare-install-package.sh +++ b/build/unix/prepare-install-package.sh @@ -9,7 +9,7 @@ ########## -## Constants +## Fetch values ########## # paths gamePath="/home/pathoschild/Stardew Valley" @@ -21,25 +21,18 @@ folders=("linux" "macOS" "windows") declare -A runtimes=(["linux"]="linux-x64" ["macOS"]="osx-x64" ["windows"]="win-x64") declare -A msBuildPlatformNames=(["linux"]="Unix" ["macOS"]="OSX" ["windows"]="Windows_NT") - -########## -## Move to SMAPI root -########## -cd "`dirname "$0"`/../.." - - -########## -## Set version -########## -# get version number +# version number version="$1" if [ $# -eq 0 ]; then echo "SMAPI release version (like '4.0.0'):" read version fi -# set version -. ${0%/*}/set-smapi-version.sh "$version" + +########## +## Move to SMAPI root +########## +cd "`dirname "$0"`/../.." ########## @@ -56,6 +49,7 @@ echo "" ########## ## Compile files ########## +. ${0%/*}/set-smapi-version.sh "$version" for folder in ${folders[@]}; do runtime=${runtimes[$folder]} msbuildPlatformName=${msBuildPlatformNames[$folder]} diff --git a/build/windows/prepare-install-package.ps1 b/build/windows/prepare-install-package.ps1 index 5a1e0bcc..5e116019 100644 --- a/build/windows/prepare-install-package.ps1 +++ b/build/windows/prepare-install-package.ps1 @@ -1,33 +1,19 @@ # # # This is the PowerShell equivalent of ../unix/prepare-install-package.sh, *except* that it doesn't -# set Linux permissions, create the install.dat files, or create the final zip. Due to limitations -# in PowerShell, the final changes are handled by the windows/finalize-install-package.sh file in -# WSL. +# set Linux permissions, create the install.dat files, or create the final zip (unless you specify +# --windows-only). Due to limitations in PowerShell, the final changes are handled by the +# windows/finalize-install-package.sh file in WSL. # # When making changes, make sure to update ../unix/prepare-install-package.ps1 too. # # - -. "$PSScriptRoot\lib\in-place-regex.ps1" +. "$PSScriptRoot/lib/in-place-regex.ps1" ########## -## Set version -########## -# get version number -$version = $args[0] -if (!$version) { - $version = Read-Host "SMAPI release version (like '4.0.0')" -} - -# set version -. "$PSScriptRoot/set-smapi-version.ps1" "$version" - - -########## -## Constants +## Fetch values ########## # paths $gamePath = "C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley" @@ -39,6 +25,23 @@ $folders = "linux", "macOS", "windows" $runtimes = @{ linux = "linux-x64"; macOS = "osx-x64"; windows = "win-x64" } $msBuildPlatformNames = @{ linux = "Unix"; macOS = "OSX"; windows = "Windows_NT" } +# version number +$version = $args[0] +if (!$version) { + $version = Read-Host "SMAPI release version (like '4.0.0')" +} + +# Windows-only build +$windowsOnly = $false +foreach ($arg in $args) { + if ($arg -eq "--windows-only") { + $windowsOnly = $true + $folders = "windows" + $runtimes = @{ windows = "win-x64" } + $msBuildPlatformNames = @{ windows = "Windows_NT" } + } +} + ########## ## Move to SMAPI root @@ -62,7 +65,8 @@ echo "" ########## ## Compile files ########## -ForEach ($folder in $folders) { +. "$PSScriptRoot/set-smapi-version.ps1" "$version" +foreach ($folder in $folders) { $runtime = $runtimes[$folder] $msbuildPlatformName = $msBuildPlatformNames[$folder] @@ -106,6 +110,10 @@ foreach ($folder in $folders) { # copy base installer files foreach ($name in @("install on Linux.sh", "install on macOS.command", "install on Windows.bat", "README.txt")) { + if ($windowsOnly -and ($name -eq "install on Linux.sh" -or $name -eq "install on macOS.command")) { + continue; + } + cp "$installAssets/$name" "$packagePath" } @@ -199,11 +207,14 @@ foreach ($folder in $folders) { In-Place-Regex -Path "$packagePath/internal/$folder/bundle/smapi-internal/config.json" -Search "`"DeveloperMode`": true" -Replace "`"DeveloperMode`": false" # convert bundle folder into final 'install.dat' files - foreach ($path in @("$packagePath/internal/$folder", "$packageDevPath/internal/$folder")) + if ($windowsOnly) { - Compress-Archive -Path "$path/bundle/*" -CompressionLevel Optimal -DestinationPath "$path/install.zip" - mv "$path/install.zip" "$path/install.dat" - rm -Recurse -Force "$path/bundle" + foreach ($path in @("$packagePath/internal/$folder", "$packageDevPath/internal/$folder")) + { + Compress-Archive -Path "$path/bundle/*" -CompressionLevel Optimal -DestinationPath "$path/install.zip" + mv "$path/install.zip" "$path/install.dat" + rm -Recurse -Force "$path/bundle" + } } } @@ -216,8 +227,11 @@ mv "$packagePath" "bin/SMAPI $version installer" mv "$packageDevPath" "bin/SMAPI $version installer for developers" # package files -Compress-Archive -Path "bin/SMAPI $version installer" -DestinationPath "bin/SMAPI $version installer.zip" -CompressionLevel Optimal -Compress-Archive -Path "bin/SMAPI $version installer for developers" -DestinationPath "bin/SMAPI $version installer for developers.zip" -CompressionLevel Optimal +if ($windowsOnly) +{ + Compress-Archive -Path "bin/SMAPI $version installer" -DestinationPath "bin/SMAPI $version installer.zip" -CompressionLevel Optimal + Compress-Archive -Path "bin/SMAPI $version installer for developers" -DestinationPath "bin/SMAPI $version installer for developers.zip" -CompressionLevel Optimal +} echo "" echo "Done! See docs/technical/smapi.md to create the release zips." diff --git a/docs/technical/smapi.md b/docs/technical/smapi.md index 4d75aef2..44b6e49f 100644 --- a/docs/technical/smapi.md +++ b/docs/technical/smapi.md @@ -166,5 +166,8 @@ Windows](#on-windows)_ section below to create a build that retains the icon.** build/windows/finalize-install-package.sh "$version" "$binFolder" ``` +Note: to prepare a test Windows-only build, you can pass `--windows-only` in the first step and +skip the second one. + ## Release notes See [release notes](../release-notes.md). -- cgit