This commit is contained in:
Diego 2019-11-04 11:02:33 +00:00
Родитель b0a57c9175
Коммит 253259f10f
9 изменённых файлов: 399 добавлений и 80 удалений

Просмотреть файл

@ -0,0 +1,75 @@
FROM jupyter/scipy-notebook:latest
# Install .NET CLI dependencies
ARG NB_USER=jovyan
ARG NB_UID=1000
ENV USER ${NB_USER}
ENV NB_UID ${NB_UID}
ENV HOME /home/${NB_USER}
WORKDIR ${HOME}
USER root
RUN apt-get update
RUN apt-get install -y curl
# Install .NET CLI dependencies
RUN apt-get install -y --no-install-recommends \
libc6 \
libgcc1 \
libgssapi-krb5-2 \
libicu60 \
libssl1.1 \
libstdc++6 \
zlib1g
RUN rm -rf /var/lib/apt/lists/*
# Install .NET Core SDK
ENV DOTNET_SDK_VERSION 3.0.100
RUN curl -SL --output dotnet.tar.gz https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz \
&& dotnet_sha512='766da31f9a0bcfbf0f12c91ea68354eb509ac2111879d55b656f19299c6ea1c005d31460dac7c2a4ef82b3edfea30232c82ba301fb52c0ff268d3e3a1b73d8f7' \
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
&& mkdir -p /usr/share/dotnet \
&& tar -zxf dotnet.tar.gz -C /usr/share/dotnet \
&& rm dotnet.tar.gz \
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
# Enable detection of running in a container
ENV DOTNET_RUNNING_IN_CONTAINER=true \
# Enable correct mode for dotnet watch (only mode supported in a container)
DOTNET_USE_POLLING_FILE_WATCHER=true \
# Skip extraction of XML docs - generally not useful within an image/container - helps performance
NUGET_XMLDOC_MODE=skip
# Trigger first run experience by running arbitrary cmd
RUN dotnet help
# Copy notebooks
COPY ./notebooks/ ${HOME}/notebooks/
# Copy package sources
COPY ./NuGet.config ${HOME}/nuget.config
RUN chown -R ${NB_UID} ${HOME}
USER ${USER}
# Install lastest build from master branch of Microsoft.DotNet.Interactive from myget
RUN dotnet tool install -g dotnet-try --add-source "https://dotnet.myget.org/F/dotnet-try/api/v3/index.json"
# Or install latest Microsoft.DotNet.Interactive from nuget
# RUN dotnet tool install -g dotnet-try
ENV PATH="${PATH}:${HOME}/.dotnet/tools"
RUN echo "$PATH"
# Install kernel specs
RUN dotnet try jupyter install
# Set root to notebooks
WORKDIR ${HOME}/notebooks/

Просмотреть файл

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet-core" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
<add key="dotnet-fsharp" value="https://dotnet.myget.org/F/fsharp/api/v3/index.json" />
<add key="dotnet-try" value="https://dotnet.myget.org/F/dotnet-try/api/v3/index.json" />
<add key="roslyn" value="https://dotnet.myget.org/F/roslyn/api/v3/index.json" />
<add key="dotnet-corefxlab" value="https://dotnet.myget.org/F/dotnet-corefxlab/api/v3/index.json" />
</packageSources>
</configuration>

67
CreateBinder.md Normal file
Просмотреть файл

@ -0,0 +1,67 @@
# Share your notebooks on [Binder](https://mybinder.org/)
###### How to share your .NET Jupyter Notebook
If you want to share notebooks you have made using .Net kernels one easy way is to generate a binder image that everyone can open and execute.
Requisites:
* A Github repo and at least one notebook to share
* **Dockerfile** to create the binder image
* **Nuget.Config** file to provide package source to use in notebooks
You can use the Dockerfile and Nuget.Config files from the folder `Binder Dependecies` to get started.
## Steps
The repo file structure should look something like this.
<img src ="https://user-images.githubusercontent.com/375556/67017073-19137180-f0f1-11e9-9744-b5f8ec532e32.png" width = "30%">
The Dockerfile will install dotnet sdk
,then copy the notebooks and Nuget.config to folder under the notebook user
```docker
# Copy notebooks
COPY ./notebooks/ ${HOME}/notebooks/
# Copy package sources
COPY ./NuGet.config ${HOME}/nuget.config
RUN chown -R ${NB_UID} ${HOME}
USER ${USER}
```
Now push your changes to [github](https://github.com/).
Open a browser on [MyBinder homepage](https://mybinder.org/).
<img src ="https://user-images.githubusercontent.com/375556/67016428-16fce300-f0f0-11e9-98e7-d066ecb91049.png" width="70%">
Put your repository url and branch
<img src = "https://user-images.githubusercontent.com/375556/67016633-66dbaa00-f0f0-11e9-8a6d-c7191de3142e.png" width="70%">
Press launch to test your binder.
During development it is useful to use a commit hash so that you can even test different commits at the same time.
When happy with the result expand the section to reveal the link and badge code so you can now embed it in your blogs and posts.
<img src = "https://user-images.githubusercontent.com/375556/67016821-bd48e880-f0f0-11e9-8c79-4fc97a06741a.png" width = "70%">
## Start in jupyter Lab
Binder will start with jupyter notebook ux, if you want to default to jupyter lab then add `?urlpath=lab` query parameter to the url of your badge.
For example turn
```[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/dotnet/try/master)```
into
```[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/dotnet/try/master?urlpath=lab)```
Return to [README.md](README.md)

30
DotNetTry.md Normal file
Просмотреть файл

@ -0,0 +1,30 @@
# Try .NET <img src ="https://user-images.githubusercontent.com/2546640/56708992-deee8780-66ec-11e9-9991-eb85abb1d10a.png" width="80px" alt="dotnet bot in space" align ="right">
|| [**Basics**](#basics) • [**Experiences**](#experiences) || [**Setup**](#setup) • [**Getting Started**](#getting-started) || [**Samples**](https://github.com/dotnet/try-samples) ||
![Try_.NET Enabled](https://img.shields.io/badge/Try_.NET-Enabled-501078.svg)
[![Build Status](https://dev.azure.com/dnceng/public/_apis/build/status/dotnet/try/try-ci?branchName=master)](https://dev.azure.com/dnceng/public/_build/latest?definitionId=495&branchName=master)
## Basics
**What is Try .NET**: Try .NET is an interactive documentation generator for .NET Core.
**Please Note**: At the moment Try .NET only works with C# documentation.
## Experiences
Use Try .NET to create executable C# snippets for your websites or, interactive markdown files that users can run on their machine.
**Websites**
Microsoft Docs uses Try .NET to create interactive documentation. Users can run and edit code all in the browser.
<img src ="https://user-images.githubusercontent.com/2546640/57144765-c850cc00-6d8f-11e9-982d-50d2b6dc3591.gif" width = "80%">
**Interactive .NET documentation**
Try .NET enables .NET developers to create interactive markdown files.
To make your markdown files interactive, you will need to [.NET Core 3.0 SDK](https://dotnet.microsoft.com/download/dotnet-core/3.0), the dotnet try global tool and [Visual Studio](https://visualstudio.microsoft.com/) / [VS Code](https://code.visualstudio.com/)(or any other editor of your choice).
<img src ="https://user-images.githubusercontent.com/2546640/57158389-47a2c780-6db1-11e9-96ad-8c6e9ab52853.png" width = "80%">
To get started follow [setup](DotNetTryLocal.md) instructions

76
DotNetTryLocal.md Normal file
Просмотреть файл

@ -0,0 +1,76 @@
# Getting started with dotnet try
## Setup
Before you get can start creating interactive documentation, you will need to install the following:
- [.NET Core 3.0 SDK](https://dotnet.microsoft.com/download/dotnet-core/3.0)
- [dotnet try global tool](https://www.nuget.org/packages/dotnet-try/)
`dotnet tool install --global dotnet-try`
Updating to the latest version of the tool is easy just run the command below
`dotnet tool update -g dotnet-try`
Once you have successfully installed `dotnet try` global tool, enter the command `dotnet try -h` you will see a list of commands:
| Command | Purpose |
|----------------|----------------------------------------|
| `demo` | Learn how to create Try .NET content with an interactive demo |
| `verify` | Verify Markdown files in the target directory and its children. |
## 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 dotnet-try`
Then install from the preview package feed:
`dotnet tool install -g --add-source "https://dotnet.myget.org/F/dotnet-try/api/v3/index.json" 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.
<img src = "https://user-images.githubusercontent.com/2546640/68031087-4c2d3780-fc91-11e9-803f-228116e6afa2.png" width ="80%">
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
```console
> dotnet new console -o myApp
```
This will create a console app with the files `myApp.csproj` and `Program.cs`.
3. Open `mydoc`folder in Visual Studio Code.
4. Create a file called `doc.md`. Inside that file, add some text and a code fence:
````markdown
# My Interactive Document:
```cs --source-file ./myApp/Program.cs --project ./myApp/myApp.csproj
```
````
5. Now, navigate back to the `mydoc` folder and run the following command:
```console
> 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](https://github.com/dotnet/try-samples).
- Clone the [dotnet/try-samples](https://github.com/dotnet/try-samples) repo.
- Follow the quick steps listed [here](https://github.com/dotnet/try-samples#basics) to get started.
Return to [README.md](README.md)

9
Notebook.md Normal file
Просмотреть файл

@ -0,0 +1,9 @@
# Jupyter Notebooks with .NET Core | Preview 1 <img src ="https://upload.wikimedia.org/wikipedia/commons/thumb/3/38/Jupyter_logo.svg/207px-Jupyter_logo.svg.png" width="38px" alt="dotnet bot in space" align ="right">
The documentation provide in this repo shows you how you can try, create and share .NET Jupyter Notebooks.
Guide to getting started with .NET Notebooks
- [Try .NET Jupyter notebooks](NotebooksOnBinder.md) : try our lastest online using binder.
- [Create your notebook on your machine](NotebooksLocalExperience.md) : Get started locally.
- [Share your .NET Notebook](CreateBinder.md) : Create your own binder and share with others.

Просмотреть файл

@ -0,0 +1,50 @@
# Create .NET Jupyter Notebooks
##### Getting started locally on your machine
### Installation
Requirements
- [.NET 3.0 SDK](https://dotnet.microsoft.com/download) (follow the setup for your OS)
- [Jupyter](https://jupyter.org/install) : JupyterLab can be installed using [Anaconda](https://www.anaconda.com/distribution) or `conda` or `pip`. For more details on how to do this please checkout the [offical Jupyter installation](https://jupyter.org/install) guide.
### Install the .NET Kernel
- Open Command Prompt or if you have Anaconda installed use Anaconda Prompt
- Install the dotnet try global tool
`dotnet tool install -g dotnet-try --add-source https://dotnet.myget.org/F/dotnet-try/api/v3/index.json`
*Please note: If you have the `dotnet try` global tool already installed, you will need to uninstall before grabbing the kernel enabled version of the dotnet try global tool.*
- Check to see if jupyter is installed
`jupyter kernelspec list`
- Install the kernel
`dotnet try jupyter install`
<img src ="https://user-images.githubusercontent.com/2546640/63954737-93106e00-ca51-11e9-8c72-939f3f558d05.png" width = "50%">
- Test installation
`jupyter kernelspec list`
You should see the `.net-csharp` and `.net-fsharp` listed.
<img src ="https://user-images.githubusercontent.com/2546640/67889556-76fa7d00-fb25-11e9-9d23-e4178642b721.png" width ="70%">
* To start a new notebook, you can either type `jupyter lab` Anaconda prompt or launch a notebook using the Anaconda Navigator.
* Once Jupyter Lab has launched in your preferred browser, you have the option to create a **C# and F# notebook**.
<img src = "https://user-images.githubusercontent.com/2546640/67889988-3b13e780-fb26-11e9-91a1-48d5972b5df2.png" width = "70%">
- Now you can write .NET
<img src = "https://user-images.githubusercontent.com/2546640/67981834-db860c80-fbf7-11e9-89b5-29d2480ed1fa.png" width = "70%">
For more information on our APIs via C# and F#, please check out our documentation on [binder](https://mybinder.org/v2/gh/dotnet/try/master?urlpath=lab) or in dotnet/try repo in the NotebookExamples folder.
<img src = "https://user-images.githubusercontent.com/2546640/67980555-120e5800-fbf5-11e9-9c00-0d021b1ed21c.png" width = "40%">
Now that you have created your .NET notebook, you probably want to share it with others. In the [next document](CreateBinder.md), you will learn how to share your .NET notebook with others using binder.
Happy sharing!

47
NotebooksOnBinder.md Normal file
Просмотреть файл

@ -0,0 +1,47 @@
# Use our latest version on [Binder](https://mybinder.org/)
###### Zero install - try our .NET Jupyter Notebook.
**Requirement :** A browser
To get you started, we created a set of samples (C# and F#). These samples have been designed to provide a **zero-install** experience, allowing you to try the .NET kernel setup free.
## Steps
- Click on the **launch binder** badge below.
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/dotnet/try/master?urlpath=lab)
- This launches the binder service. If this is your first time visiting, it'll take a minute or two to cold start.
<img src ="https://user-images.githubusercontent.com/2546640/68036481-25c0c980-fc9c-11e9-97bd-1aeab5037453.gif" width ="70%" >
- Select one of the .NET folder options, "csharp" or "fsharp" (C# or F#)
- In the C# or F# folder you will find a *Docs* and a *Samples* folder.
- Docs folder - A how to guide that goes over formatting, plotting, magic commands etc.
<img src = "https://user-images.githubusercontent.com/2546640/67980555-120e5800-fbf5-11e9-9c00-0d021b1ed21c.png" width = "40%">
- Samples folder - Contains a set of samples that you learn and experiment with.
<img src = "https://user-images.githubusercontent.com/2546640/67979951-be4f3f00-fbf3-11e9-90c2-16df089bafd9.png" width = "50%">
- Select the *Samples Folder*, pick a .ipynb file that looks interesting, and start running the cells. You can just click Run to run the first cell. Each time you click Run it will run the next cell.
- Once the notebook has loaded make sure you trust it by clicking on the **Not Trusted** button then **Trust**
<img src ="https://user-images.githubusercontent.com/2546640/67038545-9d63f580-f0ed-11e9-95d9-8df56a4c7b21.png" width ="60%">
*Please note the first cell might take a few seconds, since we are loading a few nuget packages*
<img src ="https://user-images.githubusercontent.com/2546640/67975582-c48ced80-fbea-11e9-8008-908756af5dd3.png" width = "60%">
- Now, you can run and edit the cells, import and plot data.
<img src = "https://user-images.githubusercontent.com/2546640/67975878-55fc5f80-fbeb-11e9-9fb8-f4861c5b3dd3.png" width = "70%">
<img src = "https://user-images.githubusercontent.com/2546640/66444747-6b2e0600-ea12-11e9-8934-d352ed07b532.png" width = "70%">
<img src = "https://user-images.githubusercontent.com/2546640/66444785-89940180-ea12-11e9-8c98-4ce5c1dfc1a4.png" width = "70%">
<img src = "https://user-images.githubusercontent.com/2546640/66444810-a92b2a00-ea12-11e9-855f-c933d3367778.png" width = "70%">
Now that you have had a tour of the .NET notebooks with binder, you can get started with building your .NET notebook locally on your machine.
Follow the link below to get you started.
[Create your notebook on your machine](NotebooksLocalExperience.md) : Get started on your machine.

110
README.md
Просмотреть файл

@ -1,96 +1,46 @@
# Try .NET <img src ="https://user-images.githubusercontent.com/2546640/56708992-deee8780-66ec-11e9-9991-eb85abb1d10a.png" width="80px" alt="dotnet bot in space" align ="right">
|| [**Basics**](#basics) • [**Contribution Guidelines**](#contribution) • [**Experiences**](#experiences) || [**Setup**](#setup) • [**Getting Started**](#getting-started) || [**Samples**](https://github.com/dotnet/try-samples) ||
|| [**Contribution Guidelines**](#contribution) || [**Table of content**](#table-of-content) || [**Customers & Partners**](#customers--partners) ||
![Try_.NET Enabled](https://img.shields.io/badge/Try_.NET-Enabled-501078.svg)
[![Build Status](https://dev.azure.com/dnceng/public/_apis/build/status/dotnet/try/try-ci?branchName=master)](https://dev.azure.com/dnceng/public/_build/latest?definitionId=495&branchName=master)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/dotnet/try/master)
**Welcome to the Try .NET repo.**
## Basics
**What is Try .NET**: Try .NET is an interactive documentation generator for .NET Core.
Try .NET provides developers and content with tools to create interactive experiences.
**Please Note**: At the moment Try .NET only works with C# documentation.
There are different flavors of Try .NET interactive experiences from the web with blazor(as seen on [Microsoft docs](https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/intro-to-csharp/hello-world)), interactive documentation generator for .NET core with [dotnet try global tool](DotNetTry.md), and [.NET Jupyter Notebooks](Notebook.md).
### Flavors of Try .NET
**Try .NET Online**
<img src="https://user-images.githubusercontent.com/2546640/57144765-c850cc00-6d8f-11e9-982d-50d2b6dc3591.gif" width="60%">
**Interactive .NET Core documentation with `dotnet try global tool`**
<img src="https://user-images.githubusercontent.com/2546640/57158389-47a2c780-6db1-11e9-96ad-8c6e9ab52853.png" width="52%">
**Jupyter Notebooks with .NET**
<img src="https://user-images.githubusercontent.com/2546640/67889988-3b13e780-fb26-11e9-91a1-48d5972b5df2.png" width="60%">
<img src="https://user-images.githubusercontent.com/2546640/67912370-1b99b080-fb60-11e9-9839-0058d02488cf.png" width="52%">
Our interactive experience powers the online interactive .NET documentation, [dotnet try global tool](DotNetTry.md) and [Notebooks](Notebook.md).
## Table of Content
- [Getting Started with Try .NET](DotNetTry.md): Interactive documentation generator for .NET Core.
- [Getting started with .NET Jupyter Notebooks](Notebook.md) : Write and run .NET code in Jupyter Notebooks
## Contribution Guidelines
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.
## Experiences
Use Try .NET to create executable C# snippets for your websites or, interactive markdown files that users can run on their machine.
## Customers & Partners
| Microsoft Docs | Azure Synapse |Azure HDInsight (HDI) |
|----------|:-------------:|:-------------:|
|Microsoft Docs uses [Try .NET](https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/intro-to-csharp/hello-world) to create interactive documentation. Users can run and edit .NET code in the browser. | Azure Synapse uses the .NET kernel to write and run quick ad-hoc queries in addition to developing complete, end-to-end big data scenarios, such as reading in data, transforming it, and visualizing it|You can launch Jupyter notebooks from your HDInsight cluster to run big data queries against the compute resources in that cluster. |
**Websites**
Microsoft Docs uses Try .NET to create interactive documentation. Users can run and edit code all in the browser.
![Try NET_online](https://user-images.githubusercontent.com/2546640/57144765-c850cc00-6d8f-11e9-982d-50d2b6dc3591.gif)
**Interactive .NET documentation**
Try .NET enables .NET developers to create interactive markdown files.
To make your markdown files interactive, you will need to [.NET Core 3.0 SDK](https://dotnet.microsoft.com/download/dotnet-core/3.0), the dotnet try global tool(*coming soon*) and [Visual Studio](https://visualstudio.microsoft.com/) / [VS Code](https://code.visualstudio.com/)(or any other editor of your choice).
![interactive_doc](https://user-images.githubusercontent.com/2546640/57158389-47a2c780-6db1-11e9-96ad-8c6e9ab52853.png)
## Setup
Before you get can start creating interactive documentation, you will need to install the following:
- [.NET Core 3.0 SDK](https://dotnet.microsoft.com/download/dotnet-core/3.0) and [2.1](https://dotnet.microsoft.com/download/dotnet-core/2.1) currently `dotnet try` global tool targets 2.1.
- [dotnet try global tool](https://www.nuget.org/packages/dotnet-try/)
`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`
Once you have successfully installed `dotnet try` global tool, enter the command `dotnet try -h` you will see a list of commands:
| Command | Purpose |
|----------------|----------------------------------------|
| `demo` | Learn how to create Try .NET content with an interactive demo |
| `verify` | Verify Markdown files in the target directory and its children. |
## 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 dotnet-try`
Then install from the preview package feed:
`dotnet tool install -g --add-source "https://dotnet.myget.org/F/dotnet-try/api/v3/index.json" 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`
**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
```console
> dotnet new console -o myApp
```
This will create a console app with the files `myApp.csproj` and `Program.cs`.
3. Open `mydoc`folder in Visual Studio Code.
4. Create a file called `doc.md`. Inside that file, add some text and a code fence:
````markdown
# My Interactive Document:
```cs --source-file ./myApp/Program.cs --project ./myApp/myApp.csproj
```
````
5. Now, navigate back to the `mydoc` folder and run the following command:
```console
> 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](https://github.com/dotnet/try-samples).
- Clone the [dotnet/try-samples](https://github.com/dotnet/try-samples) repo.
- Follow the quick steps listed [here](https://github.com/dotnet/try-samples#basics) to get started.