diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2018-11-19 13:48:19 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2018-11-19 13:48:19 -0500 |
commit | 593723b7940ba72a786fc4c7366c56f9813d977b (patch) | |
tree | 4d23fbef5bc5a20115f10ca04ae3379df78cc8e1 /src/SMAPI.ModBuildConfig | |
parent | 4f28ea33bd7cc65485402c5e85259083e86b49e1 (diff) | |
parent | 3dc27a5681dcfc4ae30e95570d9966f2e14a4dd7 (diff) | |
download | SMAPI-593723b7940ba72a786fc4c7366c56f9813d977b.tar.gz SMAPI-593723b7940ba72a786fc4c7366c56f9813d977b.tar.bz2 SMAPI-593723b7940ba72a786fc4c7366c56f9813d977b.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI.ModBuildConfig')
5 files changed, 23 insertions, 65 deletions
diff --git a/src/SMAPI.ModBuildConfig/Framework/ModFileManager.cs b/src/SMAPI.ModBuildConfig/Framework/ModFileManager.cs index f4738d71..7ff66695 100644 --- a/src/SMAPI.ModBuildConfig/Framework/ModFileManager.cs +++ b/src/SMAPI.ModBuildConfig/Framework/ModFileManager.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; -using System.Web.Script.Serialization; -using StardewModdingAPI.Toolkit; +using StardewModdingAPI.Toolkit.Serialisation; +using StardewModdingAPI.Toolkit.Serialisation.Models; namespace StardewModdingAPI.ModBuildConfig.Framework { @@ -107,41 +107,10 @@ namespace StardewModdingAPI.ModBuildConfig.Framework /// <exception cref="UserErrorException">The manifest is missing or invalid.</exception> public string GetManifestVersion() { - // get manifest file - if (!this.Files.TryGetValue(this.ManifestFileName, out FileInfo manifestFile)) + if (!this.Files.TryGetValue(this.ManifestFileName, out FileInfo manifestFile) || !new JsonHelper().ReadJsonFileIfExists(manifestFile.FullName, out Manifest manifest)) throw new InvalidOperationException($"The mod does not have a {this.ManifestFileName} file."); // shouldn't happen since we validate in constructor - // read content - string json = File.ReadAllText(manifestFile.FullName); - if (string.IsNullOrWhiteSpace(json)) - throw new UserErrorException("The mod's manifest must not be empty."); - - // parse JSON - IDictionary<string, object> data; - try - { - data = this.Parse(json); - } - catch (Exception ex) - { - throw new UserErrorException($"The mod's manifest couldn't be parsed. It doesn't seem to be valid JSON.\n{ex}"); - } - - // get version field - object versionObj = data.ContainsKey("Version") ? data["Version"] : null; - if (versionObj == null) - throw new UserErrorException("The mod's manifest must have a version field."); - - // get version string - if (versionObj is IDictionary<string, object> versionFields) // SMAPI 1.x - { - int major = versionFields.ContainsKey("MajorVersion") ? (int)versionFields["MajorVersion"] : 0; - int minor = versionFields.ContainsKey("MinorVersion") ? (int)versionFields["MinorVersion"] : 0; - int patch = versionFields.ContainsKey("PatchVersion") ? (int)versionFields["PatchVersion"] : 0; - string tag = versionFields.ContainsKey("Build") ? (string)versionFields["Build"] : null; - return new SemanticVersion(major, minor, patch, tag).ToString(); - } - return new SemanticVersion(versionObj.ToString()).ToString(); // SMAPI 2.0+ + return manifest.Version.ToString(); } @@ -174,24 +143,6 @@ namespace StardewModdingAPI.ModBuildConfig.Framework || ignoreFilePatterns.Any(p => p.IsMatch(relativePath)); } - /// <summary>Get a case-insensitive dictionary matching the given JSON.</summary> - /// <param name="json">The JSON to parse.</param> - private IDictionary<string, object> Parse(string json) - { - IDictionary<string, object> MakeCaseInsensitive(IDictionary<string, object> dict) - { - foreach (var field in dict.ToArray()) - { - if (field.Value is IDictionary<string, object> value) - dict[field.Key] = MakeCaseInsensitive(value); - } - return new Dictionary<string, object>(dict, StringComparer.InvariantCultureIgnoreCase); - } - - IDictionary<string, object> data = (IDictionary<string, object>)new JavaScriptSerializer().DeserializeObject(json); - return MakeCaseInsensitive(data); - } - /// <summary>Get whether a string is equal to another case-insensitively.</summary> /// <param name="str">The string value.</param> /// <param name="other">The string to compare with.</param> diff --git a/src/SMAPI.ModBuildConfig/Properties/AssemblyInfo.cs b/src/SMAPI.ModBuildConfig/Properties/AssemblyInfo.cs index d6f8dd7f..e051bfbd 100644 --- a/src/SMAPI.ModBuildConfig/Properties/AssemblyInfo.cs +++ b/src/SMAPI.ModBuildConfig/Properties/AssemblyInfo.cs @@ -2,5 +2,5 @@ using System.Reflection; [assembly: AssemblyTitle("SMAPI.ModBuildConfig")] [assembly: AssemblyDescription("")] -[assembly: AssemblyVersion("2.1.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0")] +[assembly: AssemblyFileVersion("2.2.0")] diff --git a/src/SMAPI.ModBuildConfig/StardewModdingAPI.ModBuildConfig.csproj b/src/SMAPI.ModBuildConfig/StardewModdingAPI.ModBuildConfig.csproj index 6a52daac..f068b480 100644 --- a/src/SMAPI.ModBuildConfig/StardewModdingAPI.ModBuildConfig.csproj +++ b/src/SMAPI.ModBuildConfig/StardewModdingAPI.ModBuildConfig.csproj @@ -56,6 +56,10 @@ <Content Include="assets\nuget-icon.png" /> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\StardewModdingAPI.Toolkit.CoreInterfaces\StardewModdingAPI.Toolkit.CoreInterfaces.csproj"> + <Project>{d5cfd923-37f1-4bc3-9be8-e506e202ac28}</Project> + <Name>StardewModdingAPI.Toolkit.CoreInterfaces</Name> + </ProjectReference> <ProjectReference Include="..\StardewModdingAPI.Toolkit\StardewModdingAPI.Toolkit.csproj"> <Project>{ea5cfd2e-9453-4d29-b80f-8e0ea23f4ac6}</Project> <Name>StardewModdingAPI.Toolkit</Name> diff --git a/src/SMAPI.ModBuildConfig/build/smapi.targets b/src/SMAPI.ModBuildConfig/build/smapi.targets index d1c8a4eb..e6c3fa57 100644 --- a/src/SMAPI.ModBuildConfig/build/smapi.targets +++ b/src/SMAPI.ModBuildConfig/build/smapi.targets @@ -42,6 +42,10 @@ <When Condition="$(OS) == 'Windows_NT'"> <PropertyGroup> <!-- default paths --> + <GamePath Condition="!Exists('$(GamePath)')">C:\Program Files\GalaxyClient\Games\Stardew Valley</GamePath> + <GamePath Condition="!Exists('$(GamePath)')">C:\Program Files\GOG Galaxy\Games\Stardew Valley</GamePath> + <GamePath Condition="!Exists('$(GamePath)')">C:\Program Files\Steam\steamapps\common\Stardew Valley</GamePath> + <GamePath Condition="!Exists('$(GamePath)')">C:\Program Files (x86)\GalaxyClient\Games\Stardew Valley</GamePath> <GamePath Condition="!Exists('$(GamePath)')">C:\Program Files (x86)\GOG Galaxy\Games\Stardew Valley</GamePath> <GamePath Condition="!Exists('$(GamePath)')">C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley</GamePath> @@ -97,7 +101,8 @@ <Private Condition="$(CopyModReferencesToBuildOutput)">true</Private> </Reference> <Reference Include="StardewModdingAPI.Toolkit.CoreInterfaces"> - <HintPath>$(GamePath)\StardewModdingAPI.Toolkit.CoreInterfaces.dll</HintPath> + <HintPath>$(GamePath)\smapi-internal\StardewModdingAPI.Toolkit.CoreInterfaces.dll</HintPath> + <HintPath Condition="!Exists('$(GamePath)\smapi-internal')">$(GamePath)\StardewModdingAPI.Toolkit.CoreInterfaces.dll</HintPath> <Private>false</Private> <Private Condition="$(CopyModReferencesToBuildOutput)">true</Private> </Reference> @@ -136,7 +141,8 @@ <Private Condition="$(CopyModReferencesToBuildOutput)">true</Private> </Reference> <Reference Include="StardewModdingAPI.Toolkit.CoreInterfaces"> - <HintPath>$(GamePath)\StardewModdingAPI.Toolkit.CoreInterfaces.dll</HintPath> + <HintPath>$(GamePath)\smapi-internal\StardewModdingAPI.Toolkit.CoreInterfaces.dll</HintPath> + <HintPath Condition="!Exists('$(GamePath)\smapi-internal')">$(GamePath)\StardewModdingAPI.Toolkit.CoreInterfaces.dll</HintPath> <Private>false</Private> <Private Condition="$(CopyModReferencesToBuildOutput)">true</Private> </Reference> diff --git a/src/SMAPI.ModBuildConfig/package.nuspec b/src/SMAPI.ModBuildConfig/package.nuspec index 3d6f2598..21693828 100644 --- a/src/SMAPI.ModBuildConfig/package.nuspec +++ b/src/SMAPI.ModBuildConfig/package.nuspec @@ -2,7 +2,7 @@ <package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd"> <metadata> <id>Pathoschild.Stardew.ModBuildConfig</id> - <version>2.1.0</version> + <version>2.2</version> <title>Build package for SMAPI mods</title> <authors>Pathoschild</authors> <owners>Pathoschild</owners> @@ -12,13 +12,10 @@ <iconUrl>https://raw.githubusercontent.com/Pathoschild/SMAPI/develop/src/SMAPI.ModBuildConfig/assets/nuget-icon.png</iconUrl> <description>Automates the build configuration for crossplatform Stardew Valley SMAPI mods. For Stardew Valley 1.3 or later.</description> <releaseNotes> - 2.1: - - Added support for Stardew Valley 1.3. - - Added support for non-mod projects. - - Added C# analyzers to warn about implicit conversions of Netcode fields in Stardew Valley 1.3. - - Added option to ignore files by regex pattern. - - Added reference to new SMAPI DLL. - - Fixed some game paths not detected by NuGet package. + 2.2: + - Added support for SMAPI 2.8+ (still compatible with earlier versions). + - Added default game paths for 32-bit Windows. + - Fixed valid manifests marked invalid in some cases. </releaseNotes> </metadata> </package> |