kyle kukshtel
About  Projects  Blog  Inspiration  Archives  RSS  Search 

Discovering Dotnet-Script

Running C# inside C# with dotnet-script

February 26, 2023

Tagged: Programming   C#  


Discovering Dotnet-Script

Since last year I’ve been thinking about how to handle tooltips in games. For Cantata, we have a procedural tooltip system. This means that, instead of hand creating every possible tooltip and toggling it on/off when the player mouses over something, we have no handcrafted tooltips and instead build them procedurally from components at runtime.

This has a ton of benefits, but one of the pain points has always been stuff like this:


Though we don’t have explicit Gameobject tooltips, each tooltip does still have its own script that is full of lots of conditional logic. Writing them procedurally is nice, but there are also downsides in the sense that changing a tooltip requires a full game recompile in order have changes updated. Wouldn’t it be nice to be able to author these external to the game and have their changes hot-loaded?


Along the way to solving the above (which I think I finally cracked, but more on that in a future post), I discovered something called dotnet-script.

dotnet-script basically lets you execute something very close to C# (.csx - C# Script Files”) inside of C# as well as as standalone script files. It is exactly as cool as it sounds, and after a lot of research seems like the best solution for scripting in dotnet/Unity.

However, it also seems basically undiscovered, outside of a dedicated group of people that are aware of how cool it is. Searching on Google for results and blogs on it turns up only a few pages of results. So in the spirit of trying to help other people out and increase those search results, I wanted to put together a sort of index” blog post that just captures everything useful I could find on dotnet-script. Enjoy.


Dotnet-script Repo + Readme Though the docs are lacking, the Readme on the repo provides a fairly comprehensive overview of things.

Filip W’s blog One of the main contributors of dotnet-script has a blog where he occasionally talks about new features it gets with each new release.

Dotnet-script Repo Tests The software seems pretty well tested, and the tests are broken up pretty nicely by feature here. It’s worth reading through the tests here to find something for your use case.

Script Examples

Looking through the dotnet-script tag on Github brought up a few repos. I combed through most of them to see if any were worth mentioning. Worth mentioning that besides some headers, it seems like .csx is largely the same as modern C#. Here’s the results:

Good References

These are some high-quality references I found for actual script files.

Assorted dev-related scripts:
Git-related scripts:
Dotnet build related scripts:


Grab bag of other references found on github.

Assorted Blog Posts

Other people exploring and talking about dotnet-script

That’s it for now! Hope this helps other people looking into using dotnet-script in their projects. As I mentioend above, I’ll have a post in the future about what I’m doing with it, so look forward to that!

Published on February 26, 2023.

Tagged: Programming   C#  

subscribe to my newsletter