Create Interactive .NET Documentation with Try .NET

Maria Naggaga


When it comes to developers’ documentation, it is essential that we capture their interest and lead them down the path of success as soon as possible. Across multiple languages, developer ecosystems have been providing their communities with interactive documentation where users can read the docs, run code and, edit it all in one place.
For the past two years, the language team has been evolving Try.NET to support interactive documentation both online and offline.

What is Try.NET

Try .NET is an interactive documentation generator for .NET Core.

Try .NET Online

When Try .NET initially launched in September 2017, on, we executed all our code server side using Azure Container Instances. However, over the past fives months we switched our code execution client side using Blazor and Web Assembly.

You can see this for yourself by visiting this page, and going to the developer tools. Under the Console tab, you will see the following message WASM:Initialized now, switch over to the Network tab, you will see all the DLLs now running on the client side.

Console Tab: WASM Initialized

Network tab: DLLs

Try .NET Offline

It was essential for us to provide interactive documentation both online and offline. For our offline experience, it was crucial for us to create an experience that plugged into our content writers’ current workflow.
In our findings, we noticed that our content developers had two common areas they consistently used while creating developer documentation.

  1. A sample project that users could download and run.
  2. Markdown files with a set of instructions, and code snippets they copied and pasted from their code base.

Try .NET enables .NET developers to create interactive markdown files with the use of the dotnet try global tool.
To make your markdown files interactive, you will need the .NET Core SDK, the dotnet try global tool, Visual Studio / VS Code, and your repo.

How are we doing this?

Extending Markdown

In markdown, you use fenced code blocks to highlight code snippets. You triple back-ticks before and after code blocks. You can add optional language identifiers to enable syntax highlighting in your fenced code block.

For example, C# code block would look like this:

With Try .NET we have extended our code fences to include additional options.

We have created the following options:

  • --region option points to a C# region
  • --source-file option points to the program file
  • -- project option that points to project files plus the references to system assemblies.

So, what we are doing here is accessing code from a #region named methods in a backing project myapp and enabling you to run it within your markdown.

Using #regions

In our markdown we extended the code fence to include --region option that points to a C# region which targets a region named methods.

So, your Program.cs would look like this:

dotnet try verify

dotnet try verify is a compiler for your documentation. With this command, you can make sure that every code snippet will work and is in sync with the backing project.

The goal of dotnet try verify is to validate that your documentation works as intended.

By running dotnet try verify you will be able to detect markdown and compile errors. For example, if I removed a semicolon from the code snippet above and renamed the region from methods to method, I would get the following errors.


Try the dotnet try global tool

dotnet try is now available for use! This is an early preview of the dotnet try global tool so, please check our repository and NuGet package for regular updates.

Getting Started

  • Clone this repo
  • Checkout out the samples branch¬†git checkout samples
  • Install .NET Core SDK 3.0 and 2.1 currently dotnet try global tool targets 2.1.
  • Go to your terminal
  • Install the Try .NET tools

dotnet tool install --global dotnet-try --version 1.0.19264.11

Updating to the latest version of the tool is easy just run the command below

dotnet tool update -g dotnet-try

  • Navigate to the Samples directory of this repository and, type the following dotnet try.
    dotnet try global tool
  • This will launch the browser.
    Interactive .NET documentation

Try .NET is now Open Source

Try .NET source code is now on GitHub!  As we are still in the early stages of our development, we are unable to take any feature PRs at the moment but, we do intend to do this in the future. Please feel free to file any bugs reports under our issues. And if you have any feature suggestion, please submit them under our issues using the community suggestions label.

Looking forward to seeing all the interactive .NET documentation, and workshop you create.

Maria Naggaga
Maria Naggaga

Senior Program Manager

Follow Maria   

Reed Copsey Jr. 2019-05-16 13:36:57
The naming of this seems... odd. Shouldn't it be "Try C#" since VB.Net and F# have zero representation in any of this information? Calling it the ".NET Editor" seems like poor naming.
Sugendran Ganess
Sugendran Ganess 2019-05-16 23:08:03
This is so awesome. Well done to all involved.
Michael DeMond 2019-05-17 00:11:22
This is incredible.  According to my developer tools stats, the page downloaded 8MB of data, with 18.5MB of total (decompressed?) resources.  The total load time was 6 seconds pulling from a 100-megabit connection.  The cached reload was 3 seconds which still seems a little slow but the fact that MSFT is working on Chromium now means that this process should only get optimized going further.  You can see all the .NET dlls in the Network tab exactly as described.  SO COOL... sorta like Silverlight again without having to install the plugin and already works on all major browsers!
Thomas Levesque 2019-05-17 01:12:42
This is pretty cool. I wonder, is there an easy way to publish a Try .NET website to host it on Azure (or anywhere else)? Something like "dotnet try publish" :)
Richard Grosman
Richard Grosman 2019-05-17 01:13:59
'Paste' missing:
anonymous 2019-05-17 10:26:12
This comment has been deleted.
anonymous 2019-05-17 10:37:03
This comment has been deleted.