summaryrefslogtreecommitdiff
path: root/build/smapi.targets
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-10-07 20:37:29 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-10-07 20:37:29 -0400
commit69ffaf2e8c78d0ac49731e42ece2b7388807998f (patch)
tree459f08b2df56f4d257788463b5fbe508aeeef78a /build/smapi.targets
parent4d32b37790442b8f19379ac89e72f0ecb161b549 (diff)
downloadSMAPI-69ffaf2e8c78d0ac49731e42ece2b7388807998f.tar.gz
SMAPI-69ffaf2e8c78d0ac49731e42ece2b7388807998f.tar.bz2
SMAPI-69ffaf2e8c78d0ac49731e42ece2b7388807998f.zip
move manifest version parsing into method
Diffstat (limited to 'build/smapi.targets')
-rw-r--r--build/smapi.targets47
1 files changed, 27 insertions, 20 deletions
diff --git a/build/smapi.targets b/build/smapi.targets
index 3512d042..a1b6aab3 100644
--- a/build/smapi.targets
+++ b/build/smapi.targets
@@ -51,26 +51,8 @@
// create output path if needed
Directory.CreateDirectory(OutputFolderPath);
- // Get the file JSON string
- string json = "";
- foreach(ITaskItem file in Files)
- {
- if(Path.GetFileName(file.ItemSpec).ToLower() != "manifest.json")
- continue;
- json = File.ReadAllText(file.ItemSpec);
- break;
- }
-
- // Serialize the manifest json into a data object, then get a version object from that.
- IDictionary<string, object> data = (IDictionary<string, object>)new JavaScriptSerializer().DeserializeObject(json);
- IDictionary<string, object> version = (IDictionary<string, object>)data["Version"];
-
- // Store our version numbers for ease of use
- int major = (int)version["MajorVersion"];
- int minor = (int)version["MinorVersion"];
- int patch = (int)version["PatchVersion"];
-
- string fileName = String.Format("{0}-{1}.{2}.{3}.zip", ModName, major, minor, patch);
+ // get zip filename
+ string fileName = string.Format("{0}-{1}.zip", this.ModName, this.GetManifestVersion());
// clear old zip file if present
string zipPath = Path.Combine(OutputFolderPath, fileName);
@@ -106,6 +88,31 @@
return false;
}
}
+
+ /// <summary>Get a semantic version from the mod manifest (if available).</summary>
+ public string GetManifestVersion()
+ {
+ // Get the file JSON string
+ string json = "";
+ foreach(ITaskItem file in Files)
+ {
+ if(Path.GetFileName(file.ItemSpec).ToLower() != "manifest.json")
+ continue;
+ json = File.ReadAllText(file.ItemSpec);
+ break;
+ }
+
+ // Serialize the manifest json into a data object, then get a version object from that.
+ IDictionary<string, object> data = (IDictionary<string, object>)new JavaScriptSerializer().DeserializeObject(json);
+ IDictionary<string, object> version = (IDictionary<string, object>)data["Version"];
+
+ // Store our version numbers for ease of use
+ int major = (int)version["MajorVersion"];
+ int minor = (int)version["MinorVersion"];
+ int patch = (int)version["PatchVersion"];
+
+ return String.Format("{0}.{1}.{2}", major, minor, patch);
+ }
}
]]>
</Code>