Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile entire project & run server on Linux #995

Merged
merged 14 commits into from
May 31, 2020

Conversation

MarijnS95
Copy link
Member

@MarijnS95 MarijnS95 commented Mar 24, 2020

These patches allow compiling the entire project (currently minus NitroxTest and NitroxLauncher) under Linux using xbuild/msbuild. The server starts just fine but I am unable time-wise to test any client with it.

TODO:

  • Figure out an msbuild compiler barrier for NitroxLauncher
  • Convert NitroxTest to platform/VS-agnostic test framework
  • Fix Resources/ capitalization in AssetTools, where I've been told this should be addressed.

Note that there'll be loads more fun when Subnautica Experimental drops to stable 😉. Dependency capitalization changed once again, aside a hoist of other changes.

How-to:

This assumes have all the necessary packages installed (mono, xbuild/msbuild, nuget) for your favorite distribution. In the cloned folder, run:

nuget restore
msbuild # or the deprecated xbuild
# Start the server
mono ./NitroxServer-Subnautica/bin/Debug/NitroxServer-Subnautica.exe
# Or start the server using wine:
./NitroxServer-Subnautica/bin/Debug/NitroxServer-Subnautica.exe

@Jannify
Copy link
Member

Jannify commented Mar 29, 2020

If it should not be merged why not making it a draft?

@MarijnS95
Copy link
Member Author

MarijnS95 commented Mar 29, 2020

@Jannify Because you cannot do so after clicking the button slightly too quickly? (Pedantic much...)

Rather, I'm looking for comments/feedback on the changes and suggestions for the TODO items.

@Ghaarg
Copy link
Contributor

Ghaarg commented Apr 3, 2020

I am also migrating to linux and had some thoughts for linux migration some time ago.
An idea i had to make the launcher also usable on linux/mac was to migrate most of it to something like ElektronNet or as a lightweight version webview-cs (preferred on my side cause i hate npm).
This approach would be more work but may be worth it and better than writing another app that just patches, starts and unpatches afterwards.
But ofc, there may be other cross platform front-end solutions for C# i do not know and may be better suited.
At the moment i don't think we come around mono and that is a problem with the launcher solutions above. Harmony and some reflections do not seem to be available for the dotnet framework (the cross platform one), which both front-ends use.

At the moment i don't know any elegant way to solve the above problems. Maybe a mono app that just patches, runs the client and unpatches is the best way until we can use Harmony with dotnet.

@nesrak1
Copy link
Member

nesrak1 commented Apr 3, 2020

This fix is really only to compile and run the server. The launcher is being rewritten in electron at the moment (looks like it will be written in js and call .net to patch and start the game.) Also, unity uses mono for all platforms afaik so there shouldn't be any problems with Harmony.

@MarijnS95
Copy link
Member Author

Rebased this PR on top of master to solve conflicts, fix more capitalization issues 🙈 and implement a compile-time barrier for NitroxTest and NitroxLauncher. The barrier is simple but cannot be applied to a <Project> as a whole, unfortunately.

@MarijnS95 MarijnS95 changed the title [DONOTMERGE] Compile entire project & run server on Linux Compile entire project & run server on Linux May 25, 2020
@MarijnS95 MarijnS95 marked this pull request as ready for review May 25, 2020 23:54
@MarijnS95
Copy link
Member Author

Build-tested on Windows, still works fine. Let the review process commence 😁

@Sunrunner37
Copy link
Member

This looks fine to me although I don't know anything about linux compilation. If you can update then we can merge.

MarijnS95 added 11 commits May 29, 2020 09:45
Capitailization with the vsproj file has to match on case-sensitive file
systems/os-es.
VS doesn't seem able to keep these xml files clean and understandable. A
followup <PropertyGroup> without conditions sets the OutputType to
Library again.
AssetTools-NET is said to handle this properly but it doesn't, so
:shrug:
Tests reference Microsoft.VisualStudio.TestTools.UnitTesting which is
not available under Mono.

Rather than attempting to "rewrite" all tests to use a different
framework, disable it for now until someone finds the time and courage
to do so.
This reverts commit 8ed0fef618b75b2e57cbb168809a2aab524819da.
MarijnS95 added 2 commits May 29, 2020 10:22
Normalize filename capitalization to match the class name, just like
ServerProtoBufSerializer.cs.
This file has been recapitalized to match the classname, but the csproj
was conveniently forgotten about.
@MarijnS95
Copy link
Member Author

@Sunrunner37 Unfortunately this needs validation on Windows again. Multiple issues and capitalization needed to be fixed even if it was just a few patches behind. I expect Linux building is going to be broken 90% of the time if work persists like this.

Referring back to an earlier rant about transitive dependencies not properly including LitJSON.dll in the output dir, the commit that "fixes" this is no longer needed and the server can now properly start again without having LitJSON.dll in the same folder as NitroxModel-Subnautica.dll. Looks like that got fixed by installing a Subnautica update which includes both files in Subnautica_Data/Managed. Should we rely on their version though?

@MarijnS95
Copy link
Member Author

I expect Linux building is going to be broken 90% of the time if work persists like this.

The simple solution is obviously to run the tests on Linux as well using GH Actions. Smooth sailing so far (not), the only thing left is making the depot downloader cross-compatible and then everything should work. Let's do that in a different PR though.

Logging is used in Main() and ConfigureConsoleWindow() before the logger
is set up, resulting in a nice NullReferenceException. Reorder the code
to ensure we can use it as early as possible without having any sort of
CultureInfo issues with formatting.
@Sunrunner37 Sunrunner37 merged commit 3c366af into SubnauticaNitrox:master May 31, 2020
@MarijnS95 MarijnS95 deleted the linux branch May 31, 2020 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants