diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-11-10 23:27:38 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-11-10 23:27:38 -0500 |
commit | 6ee0d2f93d5d06556915f41e29621c59d9e9e551 (patch) | |
tree | 874dc8805175b1a48bf8211a9fc91c98a42d3fe7 /src | |
parent | 346fddda670704c1458e42104ee7405fc1de7ccc (diff) | |
download | SMAPI-6ee0d2f93d5d06556915f41e29621c59d9e9e551.tar.gz SMAPI-6ee0d2f93d5d06556915f41e29621c59d9e9e551.tar.bz2 SMAPI-6ee0d2f93d5d06556915f41e29621c59d9e9e551.zip |
don't validate manifest if we're not deploying or zipping the mod
That would break cases like unit test projects, which don't have a manifest.json file.
Diffstat (limited to 'src')
-rw-r--r-- | src/SMAPI.ModBuildConfig/DeployModTask.cs | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/src/SMAPI.ModBuildConfig/DeployModTask.cs b/src/SMAPI.ModBuildConfig/DeployModTask.cs index 70761a2f..1581b282 100644 --- a/src/SMAPI.ModBuildConfig/DeployModTask.cs +++ b/src/SMAPI.ModBuildConfig/DeployModTask.cs @@ -79,38 +79,44 @@ namespace StardewModdingAPI.ModBuildConfig this.Log.LogMessage(MessageImportance.High, $"[mod build package] Handling build with options {string.Join(", ", properties)}"); } - // check if manifest file exists - FileInfo manifestFile = new(Path.Combine(this.ProjectDir, "manifest.json")); - if (!manifestFile.Exists) - { - this.Log.LogError("[mod build package] The mod does not have a manifest.json file."); - return false; - } + // skip if nothing to do + // (This must be checked before the manifest validation, to allow cases like unit test projects.) + if (!this.EnableModDeploy && !this.EnableModZip) + return true; - // check if the json is valid + // validate the manifest file Manifest manifest; - try { - new JsonHelper().ReadJsonFileIfExists(manifestFile.FullName, out manifest); - } - catch (JsonReaderException ex) - { - // log the inner exception, otherwise the message will be generic - Exception exToShow = ex.InnerException ?? ex; - this.Log.LogError($"[mod build package] Failed to parse manifest.json: {exToShow.Message}"); - return false; - } + // check if manifest file exists + FileInfo manifestFile = new(Path.Combine(this.ProjectDir, "manifest.json")); + if (!manifestFile.Exists) + { + this.Log.LogError("[mod build package] The mod does not have a manifest.json file."); + return false; + } - // validate the manifest's fields - if (!ManifestValidator.TryValidate(manifest, out string error)) - { - this.Log.LogError($"[mod build package] The mod manifest is invalid: {error}"); - return false; - } + // check if the json is valid + try + { + new JsonHelper().ReadJsonFileIfExists(manifestFile.FullName, out manifest); + } + catch (JsonReaderException ex) + { + // log the inner exception, otherwise the message will be generic + Exception exToShow = ex.InnerException ?? ex; + this.Log.LogError($"[mod build package] Failed to parse manifest.json: {exToShow.Message}"); + return false; + } - if (!this.EnableModDeploy && !this.EnableModZip) - return true; // nothing to do + // validate the manifest's fields + if (!ManifestValidator.TryValidate(manifest, out string error)) + { + this.Log.LogError($"[mod build package] The mod manifest is invalid: {error}"); + return false; + } + } + // deploy files try { // parse extra DLLs to bundle |