Getting .net onto screeps.

  • SUN

    The Tl; Dr;

    .Net wasm development has been maturing nicely over the past couple of years so I thought i'd take it upon myself to get my creeps able to C#.

    After an initial PoC with mono I have the begginings of an initial swing at full C#ness up on github here here (not much to see, watch this space) built on top of blazor.

    Initial Findings

    So far I have experimented with three approaches, none of which are particularly screeps-ready.

    Mono Wasm

    • Build environment can be be finnicky to set up
    • Build output (.net libraries + mono 'runtime') is above 5mb
    • Allows use of the .net dlls (broad strokes here) practically as is

    My first working versions have been with the base mono wasm implementation.I expect that as time progresses mono will in the short term create the most usable 'core' for screeps as they continue to work on mixed mode (AOT + IL side by side) compilation.


    • Built on top of mono
    • Easy to set up & deploy
    • Makes major assumptions about deployment environment (hint: it isn't screeps!).
    • Requires custom harness that ignores almost everything that blazor puts on top of mono.
    • Continued blazor development keeps causing issues with the harness.

    Why use blazor if i'm going to ignore most of it? It's a (mostly) stable target that tightly integrates with the core visual studio experience with very little extra footwork needed. I messed with mono/corert/blazor simultaneously but blazor is simply the first past the gate to work on the public (ptr) server.

    I do however expect the blazor team to keep optimizing for browser deployment which will only make its use harder for screeps. For example I've already discovered two removed methods that I relied on removed as they push towards release (Removed for good reasons, mind) .

    CoreRt Wasm

    • Aims to be AOT optimized - theoretically better size & speed
    • Furthest from feature complete in regards to wasm
    • No inbuilt javascript interop as of writing
    • I found it easier to set up than the mono wasm stuff, but it has more steps
    • Currently less overall documentation for wasm builds

    Long term this is probably the most promising for .net wasm in general not just for screeps. Their work is mindblowing* but utltimately I just ended up happier for something easier to use and build against (blazor)

    *Not to say that mono/blazor isn't fantastic, i'm just most familiar with the inner workings of corert... not that that is saying much.