Skip to content

Instantly share code, notes, and snippets.

@flibitijibibo
Last active October 6, 2024 14:37
Show Gist options
  • Save flibitijibibo/f06e3f60eb66e5462da824e490229591 to your computer and use it in GitHub Desktop.
Save flibitijibibo/f06e3f60eb66e5462da824e490229591 to your computer and use it in GitHub Desktop.
Use this to update a game's FNA installation!
#!/bin/bash
# FNA Update Script
# Written by Ethan "flibitijibibo" Lee
#
# Released under public domain.
# No warranty implied; use at your own risk.
#
# Run this script in the game's executable folder.
#
# This script requires the following programs:
# - git
# - msbuild, which should include a C# compiler
#
# You may want to update MonoKickstart as well!
# https://github.com/flibitijibibo/MonoKickstart/tree/master/precompiled
# Be Smart. Be Safe.
set -e
# Move to script's directory
cd "`dirname "$0"`"
# Grab native libraries
curl -O https://fna.flibitijibibo.com/archive/fnalibs.tar.bz2
tar xvfj fnalibs.tar.bz2 lib64
rm fnalibs.tar.bz2 # Wouldn't want to waste disk space, would we...
# Download and build latest FNA
if [ -d "FNA" ]; then
cd FNA
git pull
git submodule update
else
git clone --recursive https://github.com/FNA-XNA/FNA
cd FNA
curl -o FNA.Settings.props https://flibitijibibo.com/Terraria.Settings.props
fi
msbuild /p:Configuration=Release /p:Platform=x86 FNA.sln
cd ..
cp FNA/bin/Release/* .
# We out.
echo Complete!
@flibitijibibo
Copy link
Author

Script has been redone for FNA3D.

@evan-goode
Copy link

Hi, thanks for this script. I'm getting the following output from msbuild, and the directory FNA/bin is never created. Any ideas? Should I try building it with MonoDevelop instead?

Microsoft (R) Build Engine version 16.10.1 for Mono
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 6/23/2022 10:01:37 PM.
Project "/home/evan/GOG Games/Terraria/game/FNA/FNA.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Release|Any CPU".
/home/evan/GOG Games/Terraria/game/FNA/FNA.sln.metaproj : warning MSB4121: The project configuration for project "FNA" was not specified in the solution file for the solution configuration "Release|Any CPU". [/home/evan/GOG Games/Terraria/game/FNA/FNA.sln]
Done Building Project "/home/evan/GOG Games/Terraria/game/FNA/FNA.sln" (default targets).

Build succeeded.

"/home/evan/GOG Games/Terraria/game/FNA/FNA.sln" (default target) (1) ->
(ValidateProjects target) -> 
  /home/evan/GOG Games/Terraria/game/FNA/FNA.sln.metaproj : warning MSB4121: The project configuration for project "FNA" was not specified in the solution file for the solution configuration "Release|Any CPU". [/home/evan/GOG Games/Terraria/game/FNA/FNA.sln]

    1 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.28

@Juane20
Copy link

Juane20 commented Jul 3, 2022

Hey! I'm trying to use it but I get the following error:
bzip2: (stdin) is not a bzip2 file.
tar: Child returned status 2
tar: Error is not recoverable: exiting now
How can I do? Thanks!

@evan-goode
Copy link

My fork should fix that: https://gist.github.com/evan-goode/a811f1437af7b3444e2d4155643a377c

That tar.bz2 file is behind a redirect now and curl needs to explicitly be told to follow it.

@Juane20
Copy link

Juane20 commented Jul 3, 2022

Thanks! Sorry for the questions, I'm quit noob in linux. I have another problem. The script can't use the 'msbuild' command 'cause it says: "not found", so, how can I install it?

@evan-goode
Copy link

I was never able to get it working with msbuild, but I just updated my fork to invoke make instead and that seems to work.

So you'd need to install (at least) make and mono. How to do that depends on which Linux distribution you use. On Ubuntu for example, I think you would want

sudo apt install build-essential mono-complete

Still struggling to get Terraria running smooth though 🙃

@Juane20
Copy link

Juane20 commented Jul 3, 2022

I'm trying it again, it said: curl (16) Error in the HTTP2 framing layer

@Juane20
Copy link

Juane20 commented Jul 3, 2022

Hey! It finally said: 'Complete!', really thanks for the help and the fast replies. Have a nice day!

@MyNameIsKeegan
Copy link

MyNameIsKeegan commented Jul 26, 2022

Using this script for Terraria I just get Warning: Could not find '/home/keeg/.local/share/Steam/steamapps/common/Terraria/fnaUpdate.sh', starting '/bin/bash' instead. Please check your profile settings. Kind of a Linux idiot so wondering if somebody else knows where to go from there? Thanks for time and help! On Manjaro.

@evan-goode
Copy link

Hmm how are you running it? Try these commands:

cd ~/.local/share/Steam/steamapps/common/Terraria/
curl -O https://gist.githubusercontent.com/evan-goode/a811f1437af7b3444e2d4155643a377c/raw/d9d47b64a3b0df12d4a05cc2f06550d7a0f60518/fnaUpdate.sh
bash fnaUpdate.sh

@MyNameIsKeegan
Copy link

Yep, that worked! I was running just by "Run in Konsole" via the context menu. I had also forgotten how to open the script from terminal... Was it an issue of Manjaro using zsh by default instead of bash?
Thanks for the help and quick reply!

@MyNameIsKeegan
Copy link

Got caught up with something almost immediately after running that script, but finally got to try running Terraria... and it crashes after a couple seconds with a black screen. Any ideas?

@CatgirlLunya
Copy link

@MyNameIsKeegan been getting the same error, seems to this:
Exception: System.TypeLoadException: Could not resolve type with token 01000203 from typeref (expected class 'SDL2.SDL_image' in assembly 'FNA, Version=22.2.0.0, Culture=neutral, PublicKeyToken=null') at (wrapper managed-to-native) System.RuntimeMethodHandle.GetFunctionPointer(intptr) at System.RuntimeMethodHandle.GetFunctionPointer () [0x00000] in <d1664be62cd44600bbd25f7afa292479>:0 at Terraria.Program.ForceJITOnAssembly (System.Reflection.Assembly assembly) [0x00060] in <2587bb223ae24a7fa015a01bdfbc78b9>:0 at Terraria.Program.ForceLoadAssembly (System.Reflection.Assembly assembly, System.Boolean initializeStaticMembers) [0x0000d] in <2587bb223ae24a7fa015a01bdfbc78b9>:0 at Terraria.Program.ForceLoadThread (System.Object threadContext) [0x00005] in <2587bb223ae24a7fa015a01bdfbc78b9>:0 at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00025] in <d1664be62cd44600bbd25f7afa292479>:0 at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in <d1664be62cd44600bbd25f7afa292479>:0 at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <d1664be62cd44600bbd25f7afa292479>:0 at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x0002b] in <d1664be62cd44600bbd25f7afa292479>:0 at System.Threading.ThreadHelper.ThreadStart (System.Object obj) [0x0000f] in <d1664be62cd44600bbd25f7afa292479>:0

@CatgirlLunya
Copy link

For anyone in the future, I fixed this by downloading FNA myself and changing the Makefile to have
lib/SDL2-CS/src/SDL2_gfx.cs \ lib/SDL2-CS/src/SDL2_image.cs \ lib/SDL2-CS/src/SDL2_mixer.cs \ lib/SDL2-CS/src/SDL2_ttf.cs \
at the bottom of the sources list, game runs significantly better now

@MyNameIsKeegan
Copy link

It runs now! And of course much better performance, thank you for your help! Audio is a bit crunchy and crackly now which is annoying but a big step forward from black screen.

@hypevhs
Copy link

hypevhs commented Oct 29, 2023

msbuild can be installed on arch linux with the mono-msbuild package

@CoolGirlAyden
Copy link

Msbuild doesn't seem to work for me, so instead I just used xbuild and it worked flawlessly

@ruffi123456789
Copy link

ruffi123456789 commented Aug 6, 2024

Could someone be kind enough to help me with using this with other Renderers than OpenGL on Arch Linux? I updated the Kickstarter and ran this Script, but /gldevice:Vulkan freezes right after starting the game, something about VK_DEVICE_LOST. Trying to start with /gldevice:D3D11 complains about no valid driver being found

Edit: Solved it by installing libdxvk and lib32-libdxvk from AUR. And also vkd3d and lib32-vkd3d from Extra and Multilib Repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment