summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md5
-rw-r--r--src/StardewModdingAPI/StardewModdingAPI.csproj20
2 files changed, 20 insertions, 5 deletions
diff --git a/README.md b/README.md
index 425946f9..de77f10f 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,11 @@ SMAPI uses build configuration derived from the [crosswiki mod config](https://g
to detect your current OS automatically and load the correct references. Compile output will be
placed in a `bin` directory at the root of the git repository.
+### Debugging a local build
+Rebuilding the solution in debug mode will copy the SMAPI files into your game directory. Starting
+the `StardewModdingAPI` project with debugging will launch SMAPI with the debugger attached, so you
+can intercept errors and step through the code being executed.
+
### Preparing a release
To prepare a crossplatform SMAPI release, you'll need to compile it on two platforms. See
_[crossplatforming a SMAPI mod](http://canimod.com/guides/crossplatforming-a-smapi-mod#preparing-a-mod-release)_
diff --git a/src/StardewModdingAPI/StardewModdingAPI.csproj b/src/StardewModdingAPI/StardewModdingAPI.csproj
index bbb41ee3..4fdd2ff6 100644
--- a/src/StardewModdingAPI/StardewModdingAPI.csproj
+++ b/src/StardewModdingAPI/StardewModdingAPI.csproj
@@ -80,9 +80,6 @@
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
- <StartupObject>StardewModdingAPI.Program</StartupObject>
- </PropertyGroup>
- <PropertyGroup>
<!-- Linux paths -->
<GamePath Condition="!Exists('$(GamePath)')">$(HOME)/GOG Games/Stardew Valley/game</GamePath>
<GamePath Condition="!Exists('$(GamePath)')">$(HOME)/.local/share/Steam/steamapps/common/Stardew Valley</GamePath>
@@ -252,15 +249,28 @@
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
- <Import Project="..\packages\Fody.1.29.4\build\dotnet\Fody.targets" Condition="$(OS) == 'WINDOWS_NT' AND Exists('..\packages\Fody.1.29.4\build\dotnet\Fody.targets')" />
+ <!-- merge Json.NET into the assembly (only in release mode to allow debugging, and only for Windows since Costura isn't crossplatform) -->
+ <Import Project="..\packages\Fody.1.29.4\build\dotnet\Fody.targets" Condition="$(Configuration) != 'Debug' AND $(OS) == 'WINDOWS_NT' AND Exists('..\packages\Fody.1.29.4\build\dotnet\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Fody.1.29.4\build\dotnet\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.1.29.4\build\dotnet\Fody.targets'))" />
</Target>
+ <!-- if game path is invalid, show one user-friendly error instead of a slew of reference errors -->
<Target Name="BeforeBuild">
- <!-- 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 automatically; edit the *.csproj file and manually add a &lt;GamePath&gt; setting with the full directory path containing the Stardew Valley executable." />
</Target>
+ <!-- copy files into game directory and enable debugging (only in debug mode, and only in Windows because I haven't tried it with Linux/Mac) -->
+ <PropertyGroup Condition="$(Configuration) == 'Debug' AND $(OS) == 'Windows_NT'">
+ <StartAction>Program</StartAction>
+ <StartProgram>$(GamePath)\StardewModdingAPI.exe</StartProgram>
+ <StartWorkingDirectory>$(GamePath)</StartWorkingDirectory>
+ </PropertyGroup>
+ <Target Name="AfterBuild">
+ <Copy SourceFiles="$(TargetDir)\$(TargetName).exe" DestinationFolder="$(GamePath)" />
+ <Copy SourceFiles="$(TargetDir)\$(TargetName).pdb" DestinationFolder="$(GamePath)" />
+ <Copy SourceFiles="$(TargetDir)\$(TargetName).xml" DestinationFolder="$(GamePath)" />
+ <Copy SourceFiles="$(TargetDir)\Newtonsoft.Json.dll" DestinationFolder="$(GamePath)" />
+ </Target>
</Project> \ No newline at end of file