Gmod.NET
Cross-platform .NET Module/Plugin platform for Garry's Mod powered by .NET Core.
About
Gmod.NET is Garry's Mod Module/Plugin loader for C# and other .NET languages which runs across all platforms (Windows, Linux, Mac Os). Gmod.NET allows you to develop cross-platform Garry's Mod extensions without need to close or reload your game or server.
Similar projects
Check out gmod_csModuleLoader by Bailey Drahoss.
Current features
GmodNET provides functionality to write Garry's Mod modules in C# or any other CIL-compiled language as .NET Core 3.1 class libraries. For more information on modules and API check out project's wiki. Only x86_64
version of Garry's Mod is currently supported.
Need help?
Check out our wiki or join our discord server.
Building and contributing
Build instructions
To build GmodDotNet you need to have following software installed and registered with your PATH environment variable:
-
Latest version of git
-
Latest version of CMake
-
Latest version of dotnet SDK
-
(On Windows) Latest version of Visual Studio 2019 with C++ package
-
(On macOS) Latest version of Xcode
-
(On Linux) Latest versions of make and gcc (or clang)
Build steps:
-
Clone this git repository (building outside of git repository is not supported)
-
In the root of the cloned repository run
dotnet build runtime.csproj -c Debug
ordotnet build runtime.csproj -c Release
instruction in your command prompt.
NOTE: runtime.csproj
is not a real C# project file but a kind of build script. To work with the managed part of GmodDotNet open gm_dotnet_managed/gm_dotnet_managed.sln
solution file in your IDE instead.
runtime.csproj
build script will produce following folders in the root of repository:
-
build
folder contains the full build of GmodDotNet runtime (both native and managed). The content of this folder should be copied togarrysmod/lua/bin
. -
Modules
folder contains tests suit. To run tests this folder should be copied togarrysmod/lua/bin
. -
nupkgs
folder containsGmodNET.API
NuGet package.
You may also want to copy the content of lua
folder to the corresponding destinations in garrysmod/lua
.
Folder structure
Gmod.NET is subdivided into three subprojects.
Garry's Mod binary native module and helper libraries are
contained in gm_dotnet_native
folder and organized as CMake project.
Managed part is contained in gm_dotnet_managed
folder and organized with .NET soultion file gm_dotnet_managed.sln
.
Bootstrap Lua scripts are contained in lua
folder.
Nightly builds
You can find latest nightly builds GmodDotNet runtime at http://nightly.gmodnet.xyz/. To use nightly NuGet packages connect to our nightly NuGet feed.
Installation and usage
-
Download latest build from the project's releases page.
-
Unpack archive for your OS to the
%GARRYS_MOD_ROOT_FOLDER%garrysmod/lua/bin/
folder. -
Create a
Modules
folder insidegarrysmod/lua/bin/
. -
Download and copy
gm_dotnet_server.lua
togarrysmod/lua/autorun/server
folder. -
Download and copy
gm_dotnet_client.lua
togarrysmod/lua/autorun/client
folder. -
Place your .NET module, ...deps.json file, and all dependencies in
Modules/%exact_name_of_the_module_without_dll/
folder. -
If you signed your module with GmodNetModuleSigner, copy
[name_of_your_module].modulekey
and[name_of_your_module].modulesign
to the same folder as above (Modules/%exact_name_of_the_module_without_dll/
). -
If you want your module to be serverside (clientside) only then add file
TYPE
toModules/%exact_name_of_the_module_without_dll/
with contentserver
(client
). -
Use
gmod_net_load_all
(gmod_net_load_all_cl
for client-side) console command to load all managed modules andgmod_net_unload_all
(gmod_net_unload_all_cl
) to unload them. Modules can be hot-reloaded, so one doesn't need to quit game to see changes.
License
Whole project is licensed under MIT License.
Dependencies and code usage
Gmod.NET is making use of or borrows code from the following projects:
-
CoreCLR, CoreFX, and core-setup by .NET Foundation (MIT License)
-
pure_lua_SHA by Egor Skriptunoff (MIT License)
-
NSec by Klaus Hartke (MIT License)
-
Libsodium by Frank Denis (ISC License)
See other copyright notices in the NOTICE file.