Merge branch 'add-mod-build-config' into develop
This commit is contained in:
commit
d0dd2f7ba7
|
@ -0,0 +1,36 @@
|
|||
**SMAPI** is an [open-source](LICENSE.md) modding API for [Stardew Valley](http://stardewvalley.net/)
|
||||
that lets you play the game with mods. It's safely installed alongside the game's executable, and
|
||||
doesn't change any of your game files. It serves six main purposes:
|
||||
|
||||
1. **Load mods into the game.**
|
||||
_SMAPI loads mods when the game is starting up so they can interact with it. (Code mods aren't
|
||||
possible without SMAPI to load them.)_
|
||||
|
||||
2. **Provide APIs and events for mods.**
|
||||
_SMAPI provides low-level APIs and events which let mods interact with the game in ways they
|
||||
otherwise couldn't._
|
||||
|
||||
3. **Rewrite mods for crossplatform compatibility.**
|
||||
_SMAPI rewrites mods' compiled code before loading them so they work on Linux/Mac/Windows
|
||||
without the mods needing to handle differences between the Linux/Mac and Windows versions of the
|
||||
game._
|
||||
|
||||
4. **Rewrite mods to update them.**
|
||||
_SMAPI detects when a mod accesses part of the game that changed in a recent update which
|
||||
affects many mods, and rewrites the mod so it's compatible._
|
||||
|
||||
5. **Intercept errors.**
|
||||
_SMAPI intercepts errors that happen in the game, displays the error details in the console
|
||||
window, and in most cases automatically recovers the game. This prevents mods from accidentally
|
||||
crashing the game, and makes it possible to troubleshoot errors in the game itself that would
|
||||
otherwise show a generic 'program has stopped working' type of message._
|
||||
|
||||
6. **Provide update checks.**
|
||||
_SMAPI automatically checks for new versions of your installed mods, and notifies you when any
|
||||
are available._
|
||||
|
||||
## Documentation
|
||||
* [For players & mod creators](http://stardewvalleywiki.com/Modding:Index)
|
||||
* [Release notes](release-notes.md)
|
||||
* [Technical docs](technical-docs.md)
|
||||
* [Chat on Discord](https://discord.gg/KCJHWhX) with SMAPI developers and other modders
|
Binary file not shown.
Before Width: | Height: | Size: 246 KiB |
|
@ -1,61 +1,19 @@
|
|||
![](docs/imgs/SMAPI.png)
|
||||
← [README](README.md)
|
||||
|
||||
This file provides more technical documentation about SMAPI. If you only want to use or create
|
||||
mods, this section isn't relevant to you; see the main README to use or create mods.
|
||||
|
||||
## Contents
|
||||
* [What is SMAPI?](#what-is-smapi)
|
||||
* **[For players](#for-players)**
|
||||
* **[For mod developers](#for-mod-developers)**
|
||||
* [For SMAPI developers](#for-smapi-developers)
|
||||
* [Development](#development)
|
||||
* [Compiling from source](#compiling-from-source)
|
||||
* [Debugging a local build](#debugging-a-local-build)
|
||||
* [Preparing a release](#preparing-a-release)
|
||||
* [Advanced usage](#advanced-usage)
|
||||
* [Customisation](#customisation)
|
||||
* [Configuration file](#configuration-file)
|
||||
* [Command-line arguments](#command-line-arguments)
|
||||
* [Compile flags](#compile-flags)
|
||||
|
||||
## What is SMAPI?
|
||||
**SMAPI** is an [open-source](LICENSE) modding API for [Stardew Valley](http://stardewvalley.net/)
|
||||
that lets you play the game with mods. It's safely installed alongside the game's executable, and
|
||||
doesn't change any of your game files. It serves five main purposes:
|
||||
|
||||
1. **Load mods into the game.**
|
||||
_SMAPI loads mods when the game is starting up so they can interact with it. (Code mods aren't
|
||||
possible without SMAPI to load them.)_
|
||||
|
||||
2. **Provide APIs and events for mods.**
|
||||
_SMAPI provides low-level APIs and events which let mods interact with the game in ways they
|
||||
otherwise couldn't._
|
||||
|
||||
3. **Rewrite mods for crossplatform compatibility.**
|
||||
_SMAPI rewrites mods' compiled code before loading them so they work on Linux/Mac/Windows
|
||||
without the mods needing to handle differences between the Linux/Mac and Windows versions of the
|
||||
game._
|
||||
|
||||
4. **Rewrite mods to update them.**
|
||||
_SMAPI detects when a mod accesses part of the game that changed in a recent update which
|
||||
affects many mods, and rewrites the mod so it's compatible._
|
||||
|
||||
5. **Intercept errors.**
|
||||
_SMAPI intercepts errors that happen in the game, displays the error details in the console
|
||||
window, and in most cases automatically recovers the game. This prevents mods from accidentally
|
||||
crashing the game, and makes it possible to troubleshoot errors in the game itself that would
|
||||
otherwise show a generic 'program has stopped working' type of message._
|
||||
|
||||
## For players
|
||||
* [Intro & FAQs](http://stardewvalleywiki.com/Modding:Player_FAQs)
|
||||
* [Installing SMAPI](http://stardewvalleywiki.com/Modding:Installing_SMAPI)
|
||||
* [Release notes](release-notes.md#release-notes)
|
||||
* Need help? Come [chat on Discord](https://discord.gg/KCJHWhX) or [post in the support forums](http://community.playstarbound.com/threads/smapi-stardew-modding-api.108375/).
|
||||
_Please don't submit issues on GitHub for support questions._
|
||||
|
||||
## For mod developers
|
||||
* [Modding documentation](http://stardewvalleywiki.com/Modding:Index)
|
||||
* [Release notes](release-notes.md#release-notes)
|
||||
* [Chat on Discord](https://discord.gg/KCJHWhX) with SMAPI developers and other modders
|
||||
|
||||
## For SMAPI developers
|
||||
_This section is about compiling SMAPI itself from source. If you don't know what that means, this
|
||||
section isn't relevant to you; see the previous sections to use or create mods._
|
||||
|
||||
## Development
|
||||
### Compiling from source
|
||||
Using an official SMAPI release is recommended for most users.
|
||||
|
||||
|
@ -139,7 +97,7 @@ on the wiki for the first-time setup.
|
|||
* delete `internal/Windows/StardewModdingAPI.xml`.
|
||||
7. Compress the two folders into `SMAPI <version>.zip` and `SMAPI <version> for developers.zip`.
|
||||
|
||||
## Advanced usage
|
||||
## Customisation
|
||||
### Configuration file
|
||||
You can customise the SMAPI behaviour by editing the `StardewModdingAPI.config.json` file in your
|
||||
game folder.
|
||||
|
@ -177,4 +135,3 @@ SMAPI uses a small number of conditional compilation constants, which you can se
|
|||
flag | purpose
|
||||
---- | -------
|
||||
`SMAPI_FOR_WINDOWS` | Indicates that SMAPI is being compiled on Windows for players on Windows. Set automatically in `crossplatform.targets`.
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
**Stardew.ModBuildConfig** is an open-source NuGet package which automates the build configuration
|
||||
for [Stardew Valley](http://stardewvalley.net/) [SMAPI](https://github.com/Pathoschild/SMAPI) mods.
|
||||
|
||||
The package...
|
||||
|
||||
* lets you write your mod once, and compile it on any computer. It detects the current platform
|
||||
(Linux, Mac, or Windows) and game install path, and injects the right references automatically.
|
||||
* configures Visual Studio so you can debug into the mod code when the game is running (_Windows
|
||||
only_).
|
||||
* packages the mod automatically into the game's mod folder when you build the code (_optional_).
|
||||
|
||||
## Contents
|
||||
* [Install](#install)
|
||||
* [Simplify mod development](#simplify-mod-development)
|
||||
* [Troubleshoot](#troubleshoot)
|
||||
* [Versions](#versions)
|
||||
|
||||
## Install
|
||||
**When creating a new mod:**
|
||||
|
||||
1. Create an empty library project.
|
||||
2. Reference the [`Pathoschild.Stardew.ModBuildConfig` NuGet package](https://www.nuget.org/packages/Pathoschild.Stardew.ModBuildConfig).
|
||||
3. [Write your code](http://canimod.com/guides/creating-a-smapi-mod).
|
||||
4. Compile on any platform.
|
||||
|
||||
**When migrating an existing mod:**
|
||||
|
||||
1. Remove any project references to `Microsoft.Xna.*`, `MonoGame`, Stardew Valley,
|
||||
`StardewModdingAPI`, and `xTile`.
|
||||
2. Reference the [`Pathoschild.Stardew.ModBuildConfig` NuGet package](https://www.nuget.org/packages/Pathoschild.Stardew.ModBuildConfig).
|
||||
3. Compile on any platform.
|
||||
|
||||
## Simplify mod development
|
||||
### Package your mod into the game folder automatically
|
||||
You can copy your mod files into the `Mods` folder automatically each time you build, so you don't
|
||||
need to do it manually:
|
||||
|
||||
1. Edit your mod's `.csproj` file.
|
||||
2. Add this block above the first `</PropertyGroup>` line:
|
||||
|
||||
```xml
|
||||
<DeployModFolderName>$(MSBuildProjectName)</DeployModFolderName>
|
||||
```
|
||||
|
||||
That's it! Each time you build, the files in `<game path>\Mods\<mod name>` will be updated with
|
||||
your `manifest.json`, build output, and any `i18n` files.
|
||||
|
||||
Notes:
|
||||
* To add custom files, just [add them to the build output](https://stackoverflow.com/a/10828462/262123).
|
||||
* To customise the folder name, just replace `$(MSBuildProjectName)` with the folder name you want.
|
||||
* If your project references another mod, make sure the reference is [_not_ marked 'copy local'](https://msdn.microsoft.com/en-us/library/t1zz5y8c(v=vs.100).aspx).
|
||||
|
||||
### Debug into the mod code (Windows-only)
|
||||
Stepping into your mod code when the game is running is straightforward, since this package injects
|
||||
the configuration automatically. To do it:
|
||||
|
||||
1. [Package your mod into the game folder automatically](#package-your-mod-into-the-game-folder-automatically).
|
||||
2. Launch the project with debugging in Visual Studio or MonoDevelop.
|
||||
|
||||
This will deploy your mod files into the game folder, launch SMAPI, and attach a debugger
|
||||
automatically. Now you can step through your code, set breakpoints, etc.
|
||||
|
||||
### Create release zips automatically (Windows-only)
|
||||
You can create the mod package automatically when you build:
|
||||
|
||||
1. Edit your mod's `.csproj` file.
|
||||
2. Add this block above the first `</PropertyGroup>` line:
|
||||
|
||||
```xml
|
||||
<DeployModZipTo>$(SolutionDir)\_releases</DeployModZipTo>
|
||||
```
|
||||
|
||||
That's it! Each time you build, the mod files will be zipped into `_releases\<mod name>.zip`. (You
|
||||
can change the value to save the zips somewhere else.)
|
||||
|
||||
## Troubleshoot
|
||||
### "Failed to find the game install path"
|
||||
That error means the package couldn't figure out where the game is installed. You need to specify
|
||||
the game location yourself. There's two ways to do that:
|
||||
|
||||
* **Option 1: set the path globally.**
|
||||
_This will apply to every project that uses version 1.5+ of package._
|
||||
|
||||
1. Get the full folder path containing the Stardew Valley executable.
|
||||
2. Create this file path:
|
||||
|
||||
platform | path
|
||||
--------- | ----
|
||||
Linux/Mac | `~/stardewvalley.targets`
|
||||
Windows | `%USERPROFILE%\stardewvalley.targets`
|
||||
|
||||
3. Save the file with this content:
|
||||
|
||||
```xml
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<GamePath>PATH_HERE</GamePath>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
```
|
||||
|
||||
4. Replace `PATH_HERE` with your custom game install path.
|
||||
|
||||
* **Option 2: set the path in the project file.**
|
||||
_(You'll need to do it for every project that uses the package.)_
|
||||
1. Get the folder path containing the Stardew Valley `.exe` file.
|
||||
2. Add this to your `.csproj` file under the `<Project` line:
|
||||
|
||||
```xml
|
||||
<PropertyGroup>
|
||||
<GamePath>PATH_HERE</GamePath>
|
||||
</PropertyGroup>
|
||||
```
|
||||
|
||||
3. Replace `PATH_HERE` with your custom game install path.
|
||||
|
||||
The configuration will check your custom path first, then fall back to the default paths (so it'll
|
||||
still compile on a different computer).
|
||||
|
||||
## Versions
|
||||
See [release notes](release-notes.md).
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
|
@ -0,0 +1,273 @@
|
|||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<!--*********************************************
|
||||
** Define build tasks
|
||||
**********************************************-->
|
||||
<!--######
|
||||
## create a release zip file for a mod (CodeTaskFactory only available on Windows?)
|
||||
#######-->
|
||||
<UsingTask TaskName="CreateModReleaseZip" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" Condition="'$(OS)' == 'Windows_NT'">
|
||||
<ParameterGroup>
|
||||
<ModName ParameterType="System.String" Required="true" />
|
||||
<Files ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
|
||||
<OutputFolderPath ParameterType="System.String" Required="true" />
|
||||
</ParameterGroup>
|
||||
<Task>
|
||||
<Reference Include="System.IO" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Web.Extensions"/>
|
||||
<Code Type="Class" Language="cs">
|
||||
<![CDATA[
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Web.Script.Serialization;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
/// <summary>A build task which packs mod files into a conventional release zip.</summary>
|
||||
public class CreateModReleaseZip : Task, ITask
|
||||
{
|
||||
/*********
|
||||
** Accessors
|
||||
*********/
|
||||
/// <summary>The mod files to pack.</summary>
|
||||
public ITaskItem[] Files { get; set; }
|
||||
|
||||
/// <summary>The name of the mod.</param>
|
||||
public string ModName { get; set; }
|
||||
|
||||
/// <summary>The absolute or relative path to the folder which should contain the generated zip file.</summary>
|
||||
public string OutputFolderPath { get; set; }
|
||||
|
||||
|
||||
/*********
|
||||
** Public methods
|
||||
*********/
|
||||
public override bool Execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
// create output path if needed
|
||||
Directory.CreateDirectory(OutputFolderPath);
|
||||
|
||||
// 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);
|
||||
if (File.Exists(zipPath))
|
||||
File.Delete(zipPath);
|
||||
|
||||
// create zip file
|
||||
using (Stream zipStream = new FileStream(zipPath, FileMode.Create, FileAccess.Write))
|
||||
using (ZipArchive archive = new ZipArchive(zipStream, ZipArchiveMode.Create))
|
||||
{
|
||||
foreach (ITaskItem file in Files)
|
||||
{
|
||||
// get file info
|
||||
string filePath = file.ItemSpec;
|
||||
string entryName = ModName + '/' + file.GetMetadata("RecursiveDir") + file.GetMetadata("Filename") + file.GetMetadata("Extension");
|
||||
if (new FileInfo(filePath).Directory.Name.Equals("i18n", StringComparison.InvariantCultureIgnoreCase))
|
||||
entryName = Path.Combine("i18n", entryName);
|
||||
|
||||
// add to zip
|
||||
using (Stream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
|
||||
using (Stream fileStreamInZip = archive.CreateEntry(entryName).Open())
|
||||
{
|
||||
fileStream.CopyTo(fileStreamInZip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.LogErrorFromException(ex);
|
||||
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>
|
||||
</Task>
|
||||
</UsingTask>
|
||||
|
||||
|
||||
<!--*********************************************
|
||||
** Find the basic mod metadata
|
||||
**********************************************-->
|
||||
<!--######
|
||||
## import developer's custom settings (if any)
|
||||
#######-->
|
||||
<Import Condition="$(OS) != 'Windows_NT' AND Exists('$(HOME)\stardewvalley.targets')" Project="$(HOME)\stardewvalley.targets" />
|
||||
<Import Condition="$(OS) == 'Windows_NT' AND Exists('$(USERPROFILE)\stardewvalley.targets')" Project="$(USERPROFILE)\stardewvalley.targets" />
|
||||
|
||||
<!--######
|
||||
## find platform + game path
|
||||
#######-->
|
||||
<Choose>
|
||||
<When Condition="$(OS) == 'Unix' OR $(OS) == 'OSX'">
|
||||
<PropertyGroup>
|
||||
<!-- Linux -->
|
||||
<GamePath Condition="!Exists('$(GamePath)')">$(HOME)/GOG Games/Stardew Valley/game</GamePath>
|
||||
<GamePath Condition="!Exists('$(GamePath)')">$(HOME)/.local/share/Steam/steamapps/common/Stardew Valley</GamePath>
|
||||
|
||||
<!-- Mac (may be 'Unix' or 'OSX') -->
|
||||
<GamePath Condition="!Exists('$(GamePath)')">/Applications/Stardew Valley.app/Contents/MacOS</GamePath>
|
||||
<GamePath Condition="!Exists('$(GamePath)')">$(HOME)/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS</GamePath>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<When Condition="$(OS) == 'Windows_NT'">
|
||||
<PropertyGroup>
|
||||
<GamePath Condition="!Exists('$(GamePath)')">C:\Program Files (x86)\GalaxyClient\Games\Stardew Valley</GamePath>
|
||||
<GamePath Condition="!Exists('$(GamePath)')">C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley</GamePath>
|
||||
<GamePath Condition="!Exists('$(GamePath)')">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\GOG.com\Games\1453375253', 'PATH', null, RegistryView.Registry32))</GamePath>
|
||||
<GamePath Condition="!Exists('$(GamePath)')">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 413150', 'InstallLocation', null, RegistryView.Registry64, RegistryView.Registry32))</GamePath>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
</Choose>
|
||||
|
||||
|
||||
<!--*********************************************
|
||||
** Inject the assembly references and debugging configuration
|
||||
**********************************************-->
|
||||
<Choose>
|
||||
<When Condition="$(OS) == 'Windows_NT'">
|
||||
<!-- references -->
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Xna.Framework.Xact, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="Stardew Valley">
|
||||
<HintPath>$(GamePath)\Stardew Valley.exe</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="StardewModdingAPI">
|
||||
<HintPath>$(GamePath)\StardewModdingAPI.exe</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="xTile, Version=2.0.4.0, Culture=neutral, processorArchitecture=x86">
|
||||
<HintPath>$(GamePath)\xTile.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- launch game for debugging -->
|
||||
<PropertyGroup>
|
||||
<StartAction>Program</StartAction>
|
||||
<StartProgram>$(GamePath)\StardewModdingAPI.exe</StartProgram>
|
||||
<StartWorkingDirectory>$(GamePath)</StartWorkingDirectory>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<!-- references -->
|
||||
<ItemGroup>
|
||||
<Reference Include="MonoGame.Framework">
|
||||
<HintPath>$(GamePath)\MonoGame.Framework.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="StardewValley">
|
||||
<HintPath>$(GamePath)\StardewValley.exe</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="StardewModdingAPI">
|
||||
<HintPath>$(GamePath)\StardewModdingAPI.exe</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="xTile">
|
||||
<HintPath>$(GamePath)\xTile.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
||||
|
||||
<!--*********************************************
|
||||
** Perform build logic
|
||||
**********************************************-->
|
||||
<!--######
|
||||
## validate metadata before build
|
||||
#######-->
|
||||
<Target Name="BeforeBuild">
|
||||
<!-- show error for unknown platform -->
|
||||
<Error Condition="'$(OS)' != 'OSX' AND '$(OS)' != 'Unix' AND '$(OS)' != 'Windows_NT'" Text="The build config package doesn't recognise OS type '$(OS)'." />
|
||||
|
||||
<!-- if game path is invalid, show one user-friendly error instead of a slew of reference errors -->
|
||||
<Error Condition="!Exists('$(GamePath)')" Text="Failed to find the game install path. See https://github.com/Pathoschild/Stardew.ModBuildConfig#troubleshoot for help." />
|
||||
<Error Condition="'$(OS)' == 'Windows_NT' AND !Exists('$(GamePath)\Stardew Valley.exe')" Text="Found a game folder at $(GamePath), but it doesn't contain Stardew Valley. You should delete this folder if it's empty." />
|
||||
<Error Condition="'$(OS)' != 'Windows_NT' AND !Exists('$(GamePath)\StardewValley.exe')" Text="Found a game folder at $(GamePath), but it doesn't contain Stardew Valley. You should delete this folder if it's empty." />
|
||||
<Error Condition="!Exists('$(GamePath)\StardewModdingAPI.exe')" Text="Found a game folder at $(GamePath), but it doesn't contain SMAPI." />
|
||||
</Target>
|
||||
|
||||
<!--######
|
||||
## Deploy files after build
|
||||
#######-->
|
||||
<Target Name="AfterBuild" Condition="'$(DeployModFolderName)' != '' OR '$(DeployModZipTo)' != ''">
|
||||
<!--collect file paths-->
|
||||
<PropertyGroup>
|
||||
<ModDeployPath>$(GamePath)\Mods\$(DeployModFolderName)</ModDeployPath>
|
||||
<DeployModZipTo Condition="'$(OS)' != 'Windows_NT'"><!--disable on Linux/Mac where CodeTaskFactory doesn't seem to be available--></DeployModZipTo>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<BuildFiles Include="$(TargetDir)\**\*.*" Exclude="$(TargetDir)\manifest.json;$(TargetDir)\i18n\**\*.*" />
|
||||
|
||||
<BuildFiles Include="$(ProjectDir)\manifest.json" Condition="'@(BuildFiles)' != ''" />
|
||||
<BuildFiles Include="$(TargetDir)\manifest.json" Condition="'@(BuildFiles)' != '' AND !EXISTS('$(ProjectDir)\manifest.json')" />
|
||||
|
||||
<I18nFiles Include="$(ProjectDir)\i18n\*.json" Condition="'@(BuildFiles)' != ''" />
|
||||
<I18nFiles Include="$(TargetDir)\i18n\*.json" Condition="'@(BuildFiles)' != '' AND !EXISTS('$(ProjectDir)\i18n')" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--validate paths-->
|
||||
<Error Text="Could not deploy mod automatically because no build output was found." Condition="'@(BuildFiles)' == ''" />
|
||||
<Error Text="Could not deploy mod automatically because no manifest.json was found in the project or build output." Condition="!Exists('$(TargetDir)\manifest.json') AND !Exists('$(ProjectDir)\manifest.json')" />
|
||||
|
||||
<!-- copy mod files into mod folder if <DeployModFolderName> property is set -->
|
||||
<Message Text="Deploying mod to $(ModDeployPath)..." Importance="high" Condition="'$(DeployModFolderName)' != ''" />
|
||||
<Copy SourceFiles="@(BuildFiles)" DestinationFolder="$(ModDeployPath)\%(RecursiveDir)" SkipUnchangedFiles="true" Condition="'$(DeployModFolderName)' != ''" />
|
||||
<Copy SourceFiles="@(I18nFiles)" DestinationFolder="$(ModDeployPath)\i18n" SkipUnchangedFiles="true" Condition="'$(DeployModFolderName)' != ''" />
|
||||
|
||||
<!-- create release zip if <DeployModZipTo> property is set -->
|
||||
<Message Text="Generating mod release at $(DeployModZipTo)\$(MSBuildProjectName).zip..." Importance="high" Condition="'$(DeployModZipTo)' != ''" />
|
||||
<CreateModReleaseZip ModName="$(MSBuildProjectName)" Files="@(BuildFiles);@(I18nFiles)" OutputFolderPath="$(DeployModZipTo)" Condition="'$(DeployModZipTo)' != ''" />
|
||||
</Target>
|
||||
</Project>
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>Pathoschild.Stardew.ModBuildConfig</id>
|
||||
<version>1.7.1</version>
|
||||
<title>MSBuild config for Stardew Valley mods</title>
|
||||
<authors>Pathoschild</authors>
|
||||
<owners>Pathoschild</owners>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<licenseUrl>https://github.com/Pathoschild/Stardew.ModBuildConfig/blob/1.7.1/LICENSE.txt</licenseUrl>
|
||||
<projectUrl>https://github.com/Pathoschild/Stardew.ModBuildConfig#readme</projectUrl>
|
||||
<iconUrl>https://raw.githubusercontent.com/Pathoschild/Stardew.ModBuildConfig/1.7.1/assets/nuget-icon.png</iconUrl>
|
||||
<description>Automates the build configuration for crossplatform Stardew Valley SMAPI mods.</description>
|
||||
<releaseNotes>
|
||||
1.7 added an option to create release zips on build and added a reference to XNA's XACT library for audio-related mods.
|
||||
1.7.1 fixed an issue where i18n folders were flattened, and ensures that the manifest/i18n files in the project take precedence over those in the build output if both are present.</releaseNotes>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="build/smapi.targets" target="build/Pathoschild.Stardew.ModBuildConfig.targets" />
|
||||
<file src="readme.md" />
|
||||
</files>
|
||||
</package>
|
|
@ -0,0 +1,28 @@
|
|||
## Release notes
|
||||
### 1.6
|
||||
* Added support for deploying mod files into `Mods` automatically.
|
||||
* Added a build error if a game folder is found, but doesn't contain Stardew Valley or SMAPI.
|
||||
|
||||
### 1.5
|
||||
* Added support for setting a custom game path globally.
|
||||
* Added default GOG path on Mac.
|
||||
|
||||
### 1.4
|
||||
* Fixed detection of non-default game paths on 32-bit Windows.
|
||||
* Removed support for SilVerPLuM (discontinued).
|
||||
* Removed support for overriding the target platform (no longer needed since SMAPI crossplatforms mods automatically).
|
||||
|
||||
### 1.3
|
||||
* Added support for non-default game paths on Windows.
|
||||
|
||||
### 1.2
|
||||
* Exclude game binaries from mod build output.
|
||||
|
||||
### 1.1
|
||||
* Added support for overriding the target platform.
|
||||
|
||||
### 1.0
|
||||
* Initial release.
|
||||
* Added support for detecting the game path automatically.
|
||||
* Added support for injecting XNA/MonoGame references automatically based on the OS.
|
||||
* Added support for mod builders like SilVerPLuM.
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
|
@ -33,12 +33,12 @@
|
|||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GlobalAssemblyInfo.cs">
|
||||
<Compile Include="..\..\build\GlobalAssemblyInfo.cs">
|
||||
<Link>Properties\GlobalAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SpriteBatchMethods.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\common.targets" />
|
||||
<Import Project="..\..\build\common.targets" />
|
||||
</Project>
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
|
@ -36,7 +36,7 @@
|
|||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GlobalAssemblyInfo.cs">
|
||||
<Compile Include="..\..\build\GlobalAssemblyInfo.cs">
|
||||
<Link>Properties\GlobalAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Enums\ScriptAction.cs" />
|
||||
|
@ -51,6 +51,6 @@
|
|||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\common.targets" />
|
||||
<Import Project="$(SolutionDir)\prepare-install-package.targets" />
|
||||
<Import Project="..\..\build\common.targets" />
|
||||
<Import Project="..\..\build\prepare-install-package.targets" />
|
||||
</Project>
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
|
@ -45,7 +45,7 @@
|
|||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GlobalAssemblyInfo.cs">
|
||||
<Compile Include="..\..\build\GlobalAssemblyInfo.cs">
|
||||
<Link>Properties\GlobalAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Utilities\SemanticVersionTests.cs" />
|
||||
|
@ -59,11 +59,11 @@
|
|||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\StardewModdingAPI\StardewModdingAPI.csproj">
|
||||
<ProjectReference Include="..\SMAPI\StardewModdingAPI.csproj">
|
||||
<Project>{f1a573b0-f436-472c-ae29-0b91ea6b9f8f}</Project>
|
||||
<Name>StardewModdingAPI</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\common.targets" />
|
||||
<Import Project="..\..\build\common.targets" />
|
||||
</Project>
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
|
@ -6,7 +6,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GlobalAssemblyInfo.cs" Link="Properties\GlobalAssemblyInfo.cs" />
|
||||
<Compile Include="..\..\build\GlobalAssemblyInfo.cs" Link="Properties\GlobalAssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -21,6 +21,6 @@
|
|||
<ItemGroup>
|
||||
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\StardewModdingAPI.Models\StardewModdingAPI.Models.projitems" Label="Shared" />
|
||||
<Import Project="..\SMAPI.Models\StardewModdingAPI.Models.projitems" Label="Shared" />
|
||||
|
||||
</Project>
|
|
@ -5,42 +5,50 @@ VisualStudioVersion = 15.0.26730.16
|
|||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrainerMod", "TrainerMod\TrainerMod.csproj", "{28480467-1A48-46A7-99F8-236D95225359}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewModdingAPI", "StardewModdingAPI\StardewModdingAPI.csproj", "{F1A573B0-F436-472C-AE29-0B91EA6B9F8F}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewModdingAPI", "SMAPI\StardewModdingAPI.csproj", "{F1A573B0-F436-472C-AE29-0B91EA6B9F8F}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "metadata", "metadata", "{86C452BE-D2D8-45B4-B63F-E329EB06CEDA}"
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".root", ".root", "{86C452BE-D2D8-45B4-B63F-E329EB06CEDA}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
..\.editorconfig = ..\.editorconfig
|
||||
..\.gitattributes = ..\.gitattributes
|
||||
..\.gitignore = ..\.gitignore
|
||||
common.targets = common.targets
|
||||
..\CONTRIBUTING.md = ..\CONTRIBUTING.md
|
||||
GlobalAssemblyInfo.cs = GlobalAssemblyInfo.cs
|
||||
..\LICENSE = ..\LICENSE
|
||||
prepare-install-package.targets = prepare-install-package.targets
|
||||
..\README.md = ..\README.md
|
||||
..\release-notes.md = ..\release-notes.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewModdingAPI.Installer", "StardewModdingAPI.Installer\StardewModdingAPI.Installer.csproj", "{443DDF81-6AAF-420A-A610-3459F37E5575}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewModdingAPI.Installer", "SMAPI.Installer\StardewModdingAPI.Installer.csproj", "{443DDF81-6AAF-420A-A610-3459F37E5575}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{28480467-1A48-46A7-99F8-236D95225359} = {28480467-1A48-46A7-99F8-236D95225359}
|
||||
{F1A573B0-F436-472C-AE29-0B91EA6B9F8F} = {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewModdingAPI.AssemblyRewriters", "StardewModdingAPI.AssemblyRewriters\StardewModdingAPI.AssemblyRewriters.csproj", "{10DB0676-9FC1-4771-A2C8-E2519F091E49}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewModdingAPI.AssemblyRewriters", "SMAPI.AssemblyRewriters\StardewModdingAPI.AssemblyRewriters.csproj", "{10DB0676-9FC1-4771-A2C8-E2519F091E49}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewModdingAPI.Tests", "StardewModdingAPI.Tests\StardewModdingAPI.Tests.csproj", "{36CCB19E-92EB-48C7-9615-98EEFD45109B}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewModdingAPI.Tests", "SMAPI.Tests\StardewModdingAPI.Tests.csproj", "{36CCB19E-92EB-48C7-9615-98EEFD45109B}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StardewModdingAPI.Web", "StardewModdingAPI.Web\StardewModdingAPI.Web.csproj", "{A308F679-51A3-4006-92D5-BAEC7EBD01A1}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StardewModdingAPI.Web", "SMAPI.Web\StardewModdingAPI.Web.csproj", "{A308F679-51A3-4006-92D5-BAEC7EBD01A1}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Internal", "Internal", "{82D22ED7-A0A7-4D64-8E92-4B6A5E74ED11}"
|
||||
EndProject
|
||||
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "StardewModdingAPI.Models", "StardewModdingAPI.Models\StardewModdingAPI.Models.shproj", "{2AA02FB6-FF03-41CF-A215-2EE60AB4F5DC}"
|
||||
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "StardewModdingAPI.Models", "SMAPI.Models\StardewModdingAPI.Models.shproj", "{2AA02FB6-FF03-41CF-A215-2EE60AB4F5DC}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{EB35A917-67B9-4EFA-8DFC-4FB49B3949BB}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
..\docs\CONTRIBUTING.md = ..\docs\CONTRIBUTING.md
|
||||
..\docs\LICENSE.md = ..\docs\LICENSE.md
|
||||
..\docs\README.md = ..\docs\README.md
|
||||
..\docs\release-notes.md = ..\docs\release-notes.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{09CF91E5-5BAB-4650-A200-E5EA9A633046}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
..\build\common.targets = ..\build\common.targets
|
||||
..\build\GlobalAssemblyInfo.cs = ..\build\GlobalAssemblyInfo.cs
|
||||
..\build\prepare-install-package.targets = ..\build\prepare-install-package.targets
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
StardewModdingAPI.Models\StardewModdingAPI.Models.projitems*{2aa02fb6-ff03-41cf-a215-2ee60ab4f5dc}*SharedItemsImports = 13
|
||||
StardewModdingAPI.Models\StardewModdingAPI.Models.projitems*{f1a573b0-f436-472c-ae29-0b91ea6b9f8f}*SharedItemsImports = 4
|
||||
SMAPI.Models\StardewModdingAPI.Models.projitems*{2aa02fb6-ff03-41cf-a215-2ee60ab4f5dc}*SharedItemsImports = 13
|
||||
SMAPI.Models\StardewModdingAPI.Models.projitems*{f1a573b0-f436-472c-ae29-0b91ea6b9f8f}*SharedItemsImports = 4
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -121,6 +129,8 @@ Global
|
|||
{10DB0676-9FC1-4771-A2C8-E2519F091E49} = {82D22ED7-A0A7-4D64-8E92-4B6A5E74ED11}
|
||||
{36CCB19E-92EB-48C7-9615-98EEFD45109B} = {82D22ED7-A0A7-4D64-8E92-4B6A5E74ED11}
|
||||
{2AA02FB6-FF03-41CF-A215-2EE60AB4F5DC} = {82D22ED7-A0A7-4D64-8E92-4B6A5E74ED11}
|
||||
{EB35A917-67B9-4EFA-8DFC-4FB49B3949BB} = {86C452BE-D2D8-45B4-B63F-E329EB06CEDA}
|
||||
{09CF91E5-5BAB-4650-A200-E5EA9A633046} = {86C452BE-D2D8-45B4-B63F-E329EB06CEDA}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {70143042-A862-47A8-A677-7C819DDC90DC}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue