summaryrefslogtreecommitdiff
path: root/src/SMAPI.ModBuildConfig/Tasks
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-10-08 02:31:51 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-10-08 02:31:51 -0400
commitef3a89587c5e0506f045f0a44a5b5b6f47bc5b43 (patch)
tree4b2cbae038e769980b6cc57c25700a8ae77d7ca6 /src/SMAPI.ModBuildConfig/Tasks
parentaae482255c76c0e21e63694b28e5e9a350e5190b (diff)
downloadSMAPI-ef3a89587c5e0506f045f0a44a5b5b6f47bc5b43.tar.gz
SMAPI-ef3a89587c5e0506f045f0a44a5b5b6f47bc5b43.tar.bz2
SMAPI-ef3a89587c5e0506f045f0a44a5b5b6f47bc5b43.zip
add support for SMAPI 2.0 version strings in mod release zip code
Diffstat (limited to 'src/SMAPI.ModBuildConfig/Tasks')
-rw-r--r--src/SMAPI.ModBuildConfig/Tasks/CreateModReleaseZip.cs23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/SMAPI.ModBuildConfig/Tasks/CreateModReleaseZip.cs b/src/SMAPI.ModBuildConfig/Tasks/CreateModReleaseZip.cs
index b94b4a01..b9460b39 100644
--- a/src/SMAPI.ModBuildConfig/Tasks/CreateModReleaseZip.cs
+++ b/src/SMAPI.ModBuildConfig/Tasks/CreateModReleaseZip.cs
@@ -106,14 +106,21 @@ namespace StardewModdingAPI.ModBuildConfig.Tasks
throw new InvalidOperationException($"The mod's {this.ManifestFileName} couldn't be parsed. It doesn't seem to be valid JSON.", ex);
}
- // extract version dictionary
- IDictionary<string, object> versionFields = (IDictionary<string, object>)data["Version"];
- 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 SemanticVersionImpl(major, minor, patch, tag).ToString();
+ // get version field
+ object versionObj = data.ContainsKey("Version") ? data["Version"] : null;
+ if (versionObj == null)
+ throw new InvalidOperationException($"The mod's {this.ManifestFileName} 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 SemanticVersionImpl(major, minor, patch, tag).ToString();
+ }
+ return new SemanticVersionImpl(versionObj.ToString()).ToString(); // SMAPI 2.0+
}
/// <summary>Get a case-insensitive dictionary matching the given JSON.</summary>