Merge branch 'develop' into stable
This commit is contained in:
commit
44e91ca5e1
|
@ -356,6 +356,12 @@ That will create a `Pathoschild.Stardew.ModBuildConfig-<version>.nupkg` file in
|
|||
which can be uploaded to NuGet or referenced directly.
|
||||
|
||||
## Release notes
|
||||
### 3.2.1
|
||||
Released 11 September 2020.
|
||||
|
||||
* Added more detailed logging.
|
||||
* Fixed _path's format is not supported_ error when using default `Mods` path in 3.2.
|
||||
|
||||
### 3.2
|
||||
Released 07 September 2020.
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
@ -55,6 +56,14 @@ namespace StardewModdingAPI.ModBuildConfig
|
|||
/// <returns>true if the task successfully executed; otherwise, false.</returns>
|
||||
public override bool Execute()
|
||||
{
|
||||
// log build settings
|
||||
{
|
||||
var properties = this
|
||||
.GetPropertiesToLog()
|
||||
.Select(p => $"{p.Key}: {p.Value}");
|
||||
this.Log.LogMessage(MessageImportance.High, $"[mod build package] Handling build with options {string.Join(", ", properties)}");
|
||||
}
|
||||
|
||||
if (!this.EnableModDeploy && !this.EnableModZip)
|
||||
return true; // nothing to do
|
||||
|
||||
|
@ -70,15 +79,18 @@ namespace StardewModdingAPI.ModBuildConfig
|
|||
if (this.EnableModDeploy)
|
||||
{
|
||||
string outputPath = Path.Combine(this.GameModsDir, this.EscapeInvalidFilenameCharacters(this.ModFolderName));
|
||||
this.Log.LogMessage(MessageImportance.High, $"The mod build package is copying the mod files to {outputPath}...");
|
||||
this.Log.LogMessage(MessageImportance.High, $"[mod build package] Copying the mod files to {outputPath}...");
|
||||
this.CreateModFolder(package.GetFiles(), outputPath);
|
||||
}
|
||||
|
||||
// create release zip
|
||||
if (this.EnableModZip)
|
||||
{
|
||||
this.Log.LogMessage(MessageImportance.High, $"The mod build package is generating a release zip at {this.ModZipPath} for {this.ModFolderName}...");
|
||||
this.CreateReleaseZip(package.GetFiles(), this.ModFolderName, package.GetManifestVersion(), this.ModZipPath);
|
||||
string zipName = this.EscapeInvalidFilenameCharacters($"{this.ModFolderName} {package.GetManifestVersion()}.zip");
|
||||
string zipPath = Path.Combine(this.ModZipPath, zipName);
|
||||
|
||||
this.Log.LogMessage(MessageImportance.High, $"[mod build package] Generating the release zip at {zipPath}...");
|
||||
this.CreateReleaseZip(package.GetFiles(), this.ModFolderName, zipPath);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -90,7 +102,7 @@ namespace StardewModdingAPI.ModBuildConfig
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Log.LogError($"The mod build package failed trying to deploy the mod.\n{ex}");
|
||||
this.Log.LogError($"[mod build package] Failed trying to deploy the mod.\n{ex}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +111,29 @@ namespace StardewModdingAPI.ModBuildConfig
|
|||
/*********
|
||||
** Private methods
|
||||
*********/
|
||||
/// <summary>Get the properties to write to the log.</summary>
|
||||
private IEnumerable<KeyValuePair<string, string>> GetPropertiesToLog()
|
||||
{
|
||||
var properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
|
||||
foreach (PropertyInfo property in properties.OrderBy(p => p.Name))
|
||||
{
|
||||
if (property.Name == nameof(this.IgnoreModFilePatterns) && string.IsNullOrWhiteSpace(this.IgnoreModFilePatterns))
|
||||
continue;
|
||||
|
||||
string name = property.Name;
|
||||
|
||||
string value = property.GetValue(this)?.ToString();
|
||||
if (value == null)
|
||||
value = "null";
|
||||
else if (property.PropertyType == typeof(bool))
|
||||
value = value.ToLower();
|
||||
else
|
||||
value = $"'{value}'";
|
||||
|
||||
yield return new KeyValuePair<string, string>(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Get the custom ignore patterns provided by the user.</summary>
|
||||
private IEnumerable<Regex> GetCustomIgnorePatterns()
|
||||
{
|
||||
|
@ -114,7 +149,7 @@ namespace StardewModdingAPI.ModBuildConfig
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.Log.LogWarning($"Ignored invalid <{nameof(this.IgnoreModFilePatterns)}> pattern {raw}:\n{ex}");
|
||||
this.Log.LogWarning($"[mod build package] Ignored invalid <{nameof(this.IgnoreModFilePatterns)}> pattern {raw}:\n{ex}");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -142,17 +177,14 @@ namespace StardewModdingAPI.ModBuildConfig
|
|||
/// <summary>Create a release zip in the recommended format for uploading to mod sites.</summary>
|
||||
/// <param name="files">The files to include.</param>
|
||||
/// <param name="modName">The name of the mod.</param>
|
||||
/// <param name="modVersion">The mod version string.</param>
|
||||
/// <param name="outputFolderPath">The absolute or relative path to the folder which should contain the generated zip file.</param>
|
||||
private void CreateReleaseZip(IDictionary<string, FileInfo> files, string modName, string modVersion, string outputFolderPath)
|
||||
/// <param name="zipPath">The absolute path to the zip file to create.</param>
|
||||
private void CreateReleaseZip(IDictionary<string, FileInfo> files, string modName, string zipPath)
|
||||
{
|
||||
// get names
|
||||
string zipName = this.EscapeInvalidFilenameCharacters($"{modName} {modVersion}.zip");
|
||||
// get folder name within zip
|
||||
string folderName = this.EscapeInvalidFilenameCharacters(modName);
|
||||
string zipPath = Path.Combine(outputFolderPath, zipName);
|
||||
|
||||
// create zip file
|
||||
Directory.CreateDirectory(outputFolderPath);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(zipPath)!);
|
||||
using Stream zipStream = new FileStream(zipPath, FileMode.Create, FileAccess.Write);
|
||||
using ZipArchive archive = new ZipArchive(zipStream, ZipArchiveMode.Create);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<RootNamespace>StardewModdingAPI.ModBuildConfig</RootNamespace>
|
||||
<Version>3.2.0</Version>
|
||||
<Version>3.2.1</Version>
|
||||
<TargetFramework>net45</TargetFramework>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<!-- set default package options -->
|
||||
<ModFolderName Condition="'$(ModFolderName)' == ''">$(MSBuildProjectName)</ModFolderName>
|
||||
<ModZipPath Condition="'$(ModZipPath)' == ''">$(TargetDir)</ModZipPath>
|
||||
<GameModsPath Condition="'$(GameModsPath)' == ''">$([System.IO.Path]::Combine($(GamePath), 'Mods')</GameModsPath>
|
||||
<GameModsPath Condition="'$(GameModsPath)' == ''">$([System.IO.Path]::Combine($(GamePath), 'Mods'))</GameModsPath>
|
||||
<EnableModDeploy Condition="'$(EnableModDeploy)' == ''">true</EnableModDeploy>
|
||||
<EnableModZip Condition="'$(EnableModZip)' == ''">true</EnableModZip>
|
||||
<EnableHarmony Condition="'$(EnableHarmony)' == ''">false</EnableHarmony>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>Pathoschild.Stardew.ModBuildConfig</id>
|
||||
<version>3.2.0</version>
|
||||
<version>3.2.1</version>
|
||||
<title>Build package for SMAPI mods</title>
|
||||
<authors>Pathoschild</authors>
|
||||
<owners>Pathoschild</owners>
|
||||
|
@ -14,9 +14,9 @@
|
|||
<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 SMAPI 3.0 or later.</description>
|
||||
<releaseNotes>
|
||||
3.2.0:
|
||||
- Added option to change `Mods` folder path.
|
||||
- Rewrote documentation to make it easier to read.
|
||||
3.2.1:
|
||||
- Added more detailed logging.
|
||||
- Fixed "path's format is not supported" error when using default Mods path in 3.2.
|
||||
</releaseNotes>
|
||||
</metadata>
|
||||
<files>
|
||||
|
|
Loading…
Reference in New Issue