Difference between revisions of "Modding:Migrate to 64-bit on Windows"

From Stardew Valley Wiki
Jump to navigation Jump to search
(remove note about ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch (that's now handled automatically by the NuGet package, thanks!))
(reorganize into 'for players' and 'for mod authors', copyedit text to fit new structure)
Line 5: Line 5:
 
</div>
 
</div>
  
This page explains how to update your mods for 64-bit Stardew Valley. This is mainly for mod authors, though the introductory sections are relevant to players too.
+
This page explains how to enable 64-bit Stardew Valley.  
  
==FAQs==
+
==For players==
 
===What does 64-bit mean?===
 
===What does 64-bit mean?===
 
The game's ''bitness'' (i.e. 32-bit or 64-bit) affects how much memory it can use. Stardew Valley is 32-bit on Windows, so it's limited to ≈3GB of the computer's memory. That's fine for most players, but those with a large number of mods (or large mods) can experience <tt>OutOfMemoryException</tt> crashes. Changing the game to 64-bit unlocks access to all available memory, which avoids <tt>OutOfMemoryException</tt> errors (if the computer itself has enough memory available).
 
The game's ''bitness'' (i.e. 32-bit or 64-bit) affects how much memory it can use. Stardew Valley is 32-bit on Windows, so it's limited to ≈3GB of the computer's memory. That's fine for most players, but those with a large number of mods (or large mods) can experience <tt>OutOfMemoryException</tt> crashes. Changing the game to 64-bit unlocks access to all available memory, which avoids <tt>OutOfMemoryException</tt> errors (if the computer itself has enough memory available).
  
===As a player, do I need 64-bit?===
+
===Do I need 64-bit?===
You only need this if you play on Windows and experience <tt>OutOfMemoryException</tt> crashes. Otherwise you can just use the default versions, which is simpler and will work fine.
+
You only need this if you play on Windows and experience <tt>OutOfMemoryException</tt> crashes. Otherwise you can just use the default versions, which are simpler and work fine.
  
===Will SMAPI be 64-bit by default?===
+
===Will SMAPI drop 32-bit support?===
Nope. SMAPI installs alongside the game by design, it doesn't change any game files. That means it'll stay 32-bit by default until the game supports 64-bit officially (if ever).
+
SMAPI will always support the official version of the game, which is currently 32-bit on Windows. The SMAPI installer automatically detects whether you have a 32-bit or 64-bit version of the game.
  
===How do I make the game 64-bit?===
+
===How do I enable 64-bit mode?===
 
The 64-bit version of Stardew Valley is '''experimental and unofficial'''. Essentially the process is:
 
The 64-bit version of Stardew Valley is '''experimental and unofficial'''. Essentially the process is:
  
Line 29: Line 29:
 
* This is '''experimental'''. The setup is more complicated, and some mods may not work in 64-bit mode yet.
 
* This is '''experimental'''. The setup is more complicated, and some mods may not work in 64-bit mode yet.
 
* This is '''unofficial'''. You shouldn't report bugs to the game developers unless you can reproduce them with the normal game version, and the default version of SMAPI will still be 32-bit.
 
* This is '''unofficial'''. You shouldn't report bugs to the game developers unless you can reproduce them with the normal game version, and the default version of SMAPI will still be 32-bit.
 +
 +
==For mod authors==
 +
''See [[#For players|for players]] above for general info.''
  
 
===Is this the modapocalypse?===
 
===Is this the modapocalypse?===
 
Nope. The vast majority of players will use the normal 32-bit version. This will only affect players which explicitly go through the process to make the game 64-bit, and most mods are already compatible with 64-bit mode.
 
Nope. The vast majority of players will use the normal 32-bit version. This will only affect players which explicitly go through the process to make the game 64-bit, and most mods are already compatible with 64-bit mode.
  
==Breaking changes for mod authors==
+
===How do I update mod code for 64-bit?===
===Review <tt>TargetPlatform</tt> constants===
+
Most SMAPI mods will work in both 32-bit and 64-bit mode already, and content packs don't need to do anything (they're compatible if the SMAPI mod loading them is). For SMAPI mods, there are two main requirements for 64-bit compatibility:
[[Modding:Modder Guide/APIs/Utilities#Constants|<tt>Constants.TargetPlatform</tt>]] indicates whether the mod is running on Android, Linux, MacOS, or Windows. If you use this to distinguish between XNA Framework (on Windows) and MonoGame (on other platforms), you should use the new <tt>Constants.GameFramework</tt> instead.
+
 
 +
<dl>
 +
<dt>Review <tt>TargetPlatform</tt> constants</dt>
 +
<dd>[[Modding:Modder Guide/APIs/Utilities#Constants|<tt>Constants.TargetPlatform</tt>]] indicates whether the mod is running on Android, Linux, MacOS, or Windows. If you use this to distinguish between XNA Framework (on Windows) and MonoGame (on other platforms), you should use the new <tt>Constants.GameFramework</tt> instead.</dd>
  
===Don't target x86===
+
<dt>Don't target x86</dt>
 +
<dd>
 
New mod projects target <tt>Any CPU</tt> by default. If you explicitly changed it to <tt>x86</tt>, you'll need to change it back to <tt>Any CPU</tt> to avoid errors for 64-bit players.
 
New mod projects target <tt>Any CPU</tt> by default. If you explicitly changed it to <tt>x86</tt>, you'll need to change it back to <tt>Any CPU</tt> to avoid errors for 64-bit players.
  
Line 53: Line 60:
 
<li>In the <tt>.sln</tt> solution file, replace all instances of <tt>x86</tt> with <tt>Any CPU</tt>.</li>
 
<li>In the <tt>.sln</tt> solution file, replace all instances of <tt>x86</tt> with <tt>Any CPU</tt>.</li>
 
</ol>
 
</ol>
 +
</dd>
  
 
[[Category:Modding]]
 
[[Category:Modding]]

Revision as of 01:25, 24 April 2021

Index

The following describes a future version of SMAPI, and may change before release.

This page explains how to enable 64-bit Stardew Valley.

For players

What does 64-bit mean?

The game's bitness (i.e. 32-bit or 64-bit) affects how much memory it can use. Stardew Valley is 32-bit on Windows, so it's limited to ≈3GB of the computer's memory. That's fine for most players, but those with a large number of mods (or large mods) can experience OutOfMemoryException crashes. Changing the game to 64-bit unlocks access to all available memory, which avoids OutOfMemoryException errors (if the computer itself has enough memory available).

Do I need 64-bit?

You only need this if you play on Windows and experience OutOfMemoryException crashes. Otherwise you can just use the default versions, which are simpler and work fine.

Will SMAPI drop 32-bit support?

SMAPI will always support the official version of the game, which is currently 32-bit on Windows. The SMAPI installer automatically detects whether you have a 32-bit or 64-bit version of the game.

How do I enable 64-bit mode?

The 64-bit version of Stardew Valley is experimental and unofficial. Essentially the process is:

  1. download the Linux version of the game;
  2. run a patch tool which makes changes for 64-bit support;
  3. install the separate 64-bit version of SMAPI.

A few caveats:

  • This is still in development, so you need to compile the code yourself to try it. You can watch this SMAPI ticket for updates.
  • This is experimental. The setup is more complicated, and some mods may not work in 64-bit mode yet.
  • This is unofficial. You shouldn't report bugs to the game developers unless you can reproduce them with the normal game version, and the default version of SMAPI will still be 32-bit.

For mod authors

See for players above for general info.

Is this the modapocalypse?

Nope. The vast majority of players will use the normal 32-bit version. This will only affect players which explicitly go through the process to make the game 64-bit, and most mods are already compatible with 64-bit mode.

How do I update mod code for 64-bit?

Most SMAPI mods will work in both 32-bit and 64-bit mode already, and content packs don't need to do anything (they're compatible if the SMAPI mod loading them is). For SMAPI mods, there are two main requirements for 64-bit compatibility:

Review TargetPlatform constants
Constants.TargetPlatform indicates whether the mod is running on Android, Linux, MacOS, or Windows. If you use this to distinguish between XNA Framework (on Windows) and MonoGame (on other platforms), you should use the new Constants.GameFramework instead.
Don't target x86
New mod projects target Any CPU by default. If you explicitly changed it to x86, you'll need to change it back to Any CPU to avoid errors for 64-bit players. To fix affected mods:
  1. In each mod's .csproj project file, remove these lines if present:
        <Platforms>x86</Platforms>
        <PlatformTarget>x86</PlatformTarget>
    

    If the mod uses the old project format (i.e. there's no <Project Sdk="Microsoft.NET.Sdk"> at the top), see How to: Configure projects to target platforms to set the platform to Any CPU.

  2. Fully exit Visual Studio.
  3. In the .sln solution file, replace all instances of x86 with Any CPU.