INITIALIZING
c#

.NET Interactive, NuGet Servers and Polyglot Notebooks. What is this Dark Magic?!

.NET Interactive, NuGet Servers and Polyglot Notebooks. What is this Dark Magic?!

I write a lot of Enterprise Libraries — a fancy name for “code I refuse to write twice” — and I keep perfectly reasonable markdown guides on how to install and use them via NuGet. And yet, without fail, every single time, I end up opening Visual Studio or VS Code anyway to do a live, real-time demo of how the thing actually works, because apparently static docs have never once been convincing enough on their own, including to me, the person who wrote them.

Wait a minute — live documentation, where I can show you the code actually running, in real time, inside the documentation itself, no separate demo required, no “trust me, just run it”?

Yes. Yes you can. Enter .NET Interactive and Polyglot Notebooks, quietly one of the more underrated tools in the entire .NET ecosystem.

A polyglot notebook with .NET Interactive is exactly what it sounds like: a single notebook where you write and execute code in multiple languages side by side, in the same document, sharing variables between cells like they're old friends who've always known each other. .NET Interactive is the engine underneath making that particular magic trick possible.

If you've used Jupyter notebooks before, you already have the mental model, congratulations, skip ahead. If not: a Jupyter Notebook is an open-source web app for documents that mix live code, equations, visualizations, and narrative text — the backbone of most modern data science and ML workflows, and the reason data scientists never seem quite as stressed about documentation as the rest of us.

I'm going to show you how to document and demo live code properly. Documentation doesn't have to be boring anymore, and frankly, it never should have been.

NuGet Registry

First step: a NuGet feed to actually publish to. You can host your own NuGet server, or, if you're already living on GitHub like the rest of us, use the GitHub Packages NuGet registry instead. We'll use the latter today, but everything downstream applies identically to a self-hosted feed, so nobody gets left out.

The one thing you genuinely need first is a personal access token — the modern equivalent of a secret handshake, minus the awkward hand positioning. Once you have that, publishing via CLI looks like this:

dotnet nuget add source --username USERNAME --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/NAMESPACE/index.json"
  • USERNAME — your usual GitHub username, the one you definitely remember without checking.
  • GITHUB_TOKEN — the personal access token you just generated, guard it accordingly.
  • NAMESPACE — your organization, or your own personal GitHub namespace.

I already publish a handful of packages into a private registry this way, quietly, like a responsible adult. Now for the actually fun part.

.NET Interactive Polyglot

We'll use VS Code for this, because at this point fighting that is a losing battle for everyone. Once installed, grab the Polyglot Notebooks extension.

So what actually is .NET Interactive? Let's let it speak for itself:

“.NET Interactive is an engine and API for running and editing code interactively, including:

  • Running code and getting its results.
  • Evaluating code to provide language services such as completions and diagnostics.
  • Sharing data and variables between multiple languages and across remote machines.

While typically associated with notebook technologies such as Jupyter and the Polyglot Notebooks extension for Visual Studio Code, .NET Interactive has other uses as well, such as building REPLs and embedded script engines.”

I've been using it constantly for my libraries, and it's genuinely changed how I hand off documentation — people just clone the repo, open the notebook, and start experimenting with real, runnable code instead of reading a wall of markdown and taking it entirely on faith like it's a religious text. Life saver, no exaggeration.

Here's a sample notebook, walked through step by step, no faith required.

Step 1

Create a new notebook. In VS Code, open the command palette and start typing >polyglot — IntelliSense will surface “Create new blank notebook,” like it's been waiting for you to ask. Pick .ipynb as the extension; since it's the standard Jupyter/Python notebook format, GitHub renders it beautifully as formatted output right in the repo, no extra setup, no static site generator, no fighting a rendering pipeline at 11pm.

Step 2

Register the NuGet source, in a PowerShell cell:

dotnet nuget add source https://nuget.pkg.github.com/NAMESPACE/index.json -n MyGithubFeed -u USERNAME -p PERSONALTOKEN

If the source is already registered, this quietly no-ops instead of throwing a tantrum about it — exactly the well-adjusted behavior you want from something you might run more than once without thinking about it.

Confirm it actually registered, in a second PowerShell cell:

dotnet nuget list source --format Detailed

Then, in a C# cell, pull in the package and actually use it, which is, after all, the entire point:

#i "nuget:https://nuget.pkg.github.com/NAMESPACE/index.json"
#r "nuget:JTServices.Security.Utils,1.0.0"

using JTServices.Security.Utils;

var result = RandomStringGenerator.Generate();

result

And just for fun, add a markdown cell describing what's happening — nothing stops a notebook from documenting itself as it goes, which is either delightfully elegant or extremely lazy, depending on how charitable you're feeling toward me today.

Run the whole thing with “Run All,” and every cell executes top to bottom, obediently, in order, like a class that's actually paying attention. It's mostly self-explanatory, except that last bare line — result isn't dead code sitting there awkwardly, it's .NET Interactive automatically displaying a cell's final expression, and Polyglot's built-in visualizer renders it cleanly with zero extra formatting code from you. It handles complex objects too — tables, charts, the works — right out of the box, and you can extend the visualizer yourself if the defaults ever stop being enough, which, so far, they haven't for me.

And the best part: since it's a real .ipynb file, GitHub renders the entire executed notebook — code, output, markdown commentary, all of it — as clean formatted output the second you push it. No build step. No static site generator. Nothing standing between “I wrote this” and “you can see it.”

Obviously, I'm not showing my actual namespace or credentials here — this is a demo, and you should never, ever commit passwords or other sensitive values into a notebook, a repo, a Slack message, a sticky note on your monitor, anywhere. But the shape of it is exactly what you'd end up with.

I'd genuinely encourage you to try this. It changes how you think about documentation once “here's how it works” comes with a working, runnable receipt stapled to it instead of just your word.

Happy coding!!!

Para valorar camisetas de la selección española de fútbol con criterios claros, es recomendable revisar la correspondencia entre la ficha y el modelo buscado. La decisión queda mejor respaldada al comprobar que las imágenes muestren frontal, espalda, escudo y cuello.