dotnet try

Runnable .NET code on your site

Getting started with dotnet try

Setup

Before you get can started creating interactive documentation, you will need to install the following:

Updating to the latest version of the tool is easy. Run the following command:

> dotnet tool update -g Microsoft.dotnet-try

Installing preview builds from master

To install the latest preview build from master, first uninstall the existing version of the tool:

> dotnet tool uninstall -g Microsoft.dotnet-try

Then, install from the preview package feed:

> dotnet tool install -g --add-source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" Microsoft.dotnet-try

Getting Started

You can get started using either one of the options below.

Option1: dotnet try demo

  • Create a new folder.

  • cd to your new folder.

  • Run command dotnet try demo : This will load our interactive dotnet try getting started tutorial.

The tutorials below work you through the following:

  • Creating a new Try .NET project.

  • Display interactive snippets using C# regions.

  • Creating Sessions

  • Verifying your projects: dotnet try verify a compiler for your documentation.

  • Passing Arguments

  • Using read only snippets

Option 2: Starting from scratch.

  1. Go to the terminal and create a folder called mydoc.

  2. cd to the mydoc folder and create a new console app with the following command:

> dotnet new console -o myApp

This will create a console app with the files myApp.csproj and Program.cs.

  1. Open the mydoc folder in Visual Studio Code.

  2. Create a file called doc.md. Inside that file, add some text and a code fence:

# My Interactive Document:

```cs --source-file ./myApp/Program.cs --project ./myApp/myApp.csproj
```
  1. Now, navigate to the mydoc folder in your console and run the following command:

     > dotnet try

You have created your first C# interactive developer experience. You should now be able to run your console app and see the result in the browser.

Option 3: Explore our samples repo.

Return to README.md

https://www.youtube.com/playlist?list=PLMYKxbaJxSpHvrqzf-GqdCu7o4HaW3qlV Advanced c# LINQ tutorials.

Last updated