summaryrefslogtreecommitdiff
path: root/src/SMAPI.ModBuildConfig/DeployModTask.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-09-16 22:47:05 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-11-28 00:01:49 -0500
commitf5807e22be157d908e3b8c65f19acaa16c3588e7 (patch)
tree7e2cf5c5fb4e775dc602c63f563940921b51878c /src/SMAPI.ModBuildConfig/DeployModTask.cs
parentbf10aeef0afae20e1d79f0772ba41a38fcb572ae (diff)
downloadSMAPI-f5807e22be157d908e3b8c65f19acaa16c3588e7.tar.gz
SMAPI-f5807e22be157d908e3b8c65f19acaa16c3588e7.tar.bz2
SMAPI-f5807e22be157d908e3b8c65f19acaa16c3588e7.zip
add BundleExtraAssemblies package option for new .NET 5 reference model
Diffstat (limited to 'src/SMAPI.ModBuildConfig/DeployModTask.cs')
-rw-r--r--src/SMAPI.ModBuildConfig/DeployModTask.cs34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/SMAPI.ModBuildConfig/DeployModTask.cs b/src/SMAPI.ModBuildConfig/DeployModTask.cs
index 0c64aed3..140933bd 100644
--- a/src/SMAPI.ModBuildConfig/DeployModTask.cs
+++ b/src/SMAPI.ModBuildConfig/DeployModTask.cs
@@ -18,6 +18,10 @@ namespace StardewModdingAPI.ModBuildConfig
/*********
** Accessors
*********/
+ /// <summary>The name (without extension or path) of the current mod's DLL.</summary>
+ [Required]
+ public string ModDllName { get; set; }
+
/// <summary>The name of the mod folder.</summary>
[Required]
public string ModFolderName { get; set; }
@@ -52,6 +56,9 @@ namespace StardewModdingAPI.ModBuildConfig
/// <summary>A comma-separated list of relative file paths to ignore when deploying or zipping the mod.</summary>
public string IgnoreModFilePaths { get; set; }
+ /// <summary>A comma-separated list of <see cref="ExtraAssemblyTypes"/> values which indicate which extra DLLs to bundle.</summary>
+ public string BundleExtraAssemblies { get; set; }
+
/*********
** Public methods
@@ -73,12 +80,15 @@ namespace StardewModdingAPI.ModBuildConfig
try
{
+ // parse extra DLLs to bundle
+ ExtraAssemblyTypes bundleAssemblyTypes = this.GetExtraAssembliesToBundleOption();
+
// parse ignore patterns
string[] ignoreFilePaths = this.GetCustomIgnoreFilePaths().ToArray();
Regex[] ignoreFilePatterns = this.GetCustomIgnorePatterns().ToArray();
// get mod info
- ModFileManager package = new ModFileManager(this.ProjectDir, this.TargetDir, ignoreFilePaths, ignoreFilePatterns, validateRequiredModFiles: this.EnableModDeploy || this.EnableModZip);
+ ModFileManager package = new ModFileManager(this.ProjectDir, this.TargetDir, ignoreFilePaths, ignoreFilePatterns, bundleAssemblyTypes, this.ModDllName, validateRequiredModFiles: this.EnableModDeploy || this.EnableModZip);
// deploy mod files
if (this.EnableModDeploy)
@@ -139,6 +149,28 @@ namespace StardewModdingAPI.ModBuildConfig
}
}
+ /// <summary>Parse the extra assembly types which should be bundled with the mod.</summary>
+ private ExtraAssemblyTypes GetExtraAssembliesToBundleOption()
+ {
+ ExtraAssemblyTypes flags = ExtraAssemblyTypes.None;
+
+ if (!string.IsNullOrWhiteSpace(this.BundleExtraAssemblies))
+ {
+ foreach (string raw in this.BundleExtraAssemblies.Split(','))
+ {
+ if (!Enum.TryParse(raw, out ExtraAssemblyTypes type))
+ {
+ this.Log.LogWarning($"[mod build package] Ignored invalid <{nameof(this.BundleExtraAssemblies)}> value '{raw}', expected one of '{string.Join("', '", Enum.GetNames(typeof(ExtraAssemblyTypes)))}'.");
+ continue;
+ }
+
+ flags |= type;
+ }
+ }
+
+ return flags;
+ }
+
/// <summary>Get the custom ignore patterns provided by the user.</summary>
private IEnumerable<Regex> GetCustomIgnorePatterns()
{