Exe
net6.0
enable
enable
TShock
TShock.Run
Always
embedded
true
..\prebuilts\HttpServer.dll
/*
This is a patch to allow self contained apps to run from the root while having the modules in a ./bin folder.
https://github.com/dotnet/sdk/issues/10366
The script replaces the ./TShock.dll with ./bin/TShock.dll
alternates: dnSpy(does this method), NetCoreBeauty
*/
var find = Encoding.UTF8.GetBytes("TShock.dll\0");
var replace = Encoding.UTF8.GetBytes("bin" + Path.DirectorySeparatorChar + "TShock.dll\0");
var contents = File.ReadAllBytes(HostExe);
var matches = 0;
var offset = Array.FindIndex(contents, (b) => {
matches = (b == find[matches]) ? matches + 1 : 0;
return matches == find.Length;
});
if (offset > -1) offset -= find.Length - 1;
var x = 0;
Array.ForEach(replace, _ => { contents[offset + x] = replace[x++]; });
File.WriteAllBytes(HostExe, contents);