|
| 1 | +# Setup |
| 2 | + |
| 3 | +Example code is written directly into Markdown documents, which requires |
| 4 | +nothing more than a text editor. However, to develop, run and test those |
| 5 | +examples interactively and ensure their correctness, you will need |
| 6 | +[Try .NET][dotnet-try] installed as a global tool using: |
| 7 | + |
| 8 | + dotnet tool install -g dotnet-try --version 1.0.19266.1 |
| 9 | + |
| 10 | +Once installed, simply run `dotnet try` in a directory with a clone of the |
| 11 | +repository containing this documentation. |
| 12 | + |
| 13 | +Try .NET requires [.NET Core 3.0 SDK][netcore3] _and_ [2.1][netcore21] to be |
| 14 | +installed prior to its installation and use. |
| 15 | + |
| 16 | +If you have [Docker] installed, you can get Try .NET and its requirements |
| 17 | +setup in a ready-to-run container image without affecting your local setup. |
| 18 | +To do so, create a file named `Dockerfile` with the following content: |
| 19 | + |
| 20 | +```Dockerfile |
| 21 | +FROM microsoft/dotnet:3.0-sdk |
| 22 | + |
| 23 | +ENV PATH="${PATH}:/root/.dotnet/tools" |
| 24 | + |
| 25 | +RUN dotnet tool install -g dotnet-try --version 1.0.19266.1 \ |
| 26 | + && curl -k https://dot.net/v1/dotnet-install.sh \ |
| 27 | + | bash /dev/stdin --install-dir /usr/share/dotnet --version 2.1.503 \ |
| 28 | + && mkdir /doc |
| 29 | + |
| 30 | +WORKDIR /doc |
| 31 | + |
| 32 | +ENTRYPOINT ["dotnet", "try"] |
| 33 | +``` |
| 34 | + |
| 35 | +Next, build the image, tagging it `dotnet-try`: |
| 36 | + |
| 37 | + docker build -t dotnet-try . |
| 38 | + |
| 39 | +Then whenever you wish to develop, run and test the code in the Markdown |
| 40 | +documents, change the current working directory of your shell (`cd`) to where |
| 41 | +you cloned the repository containing the documents and run the image using: |
| 42 | + |
| 43 | + docker run -ti --rm -p 5000:80 -v "$(pwd):/doc" dotnet-try |
| 44 | + |
| 45 | +If you are using PowerShell, run instead using: |
| 46 | + |
| 47 | + docker run -ti --rm -p 5000:80 -v "$($PWD)/doc" dotnet-try |
| 48 | + |
| 49 | +If you are using the Windows Command Prompt (`cmd.exe`), run instead |
| 50 | +using: |
| 51 | + |
| 52 | + docker run -ti --rm -p 5000:80 -v "%cd%/doc" dotnet-try |
| 53 | + |
| 54 | +Finally, open a browser and navigate to `http://localhost:5000/README.md`. |
| 55 | + |
| 56 | + |
| 57 | +[dotnet-try]: https://github.com/dotnet/try |
| 58 | +[dotnet-try-setup]: https://github.com/dotnet/try/blob/301dacfdd8af34586def0722a08452bab6393bc9/README.md#setup |
| 59 | +[netcore21]: https://dotnet.microsoft.com/download/dotnet-core/2.1 |
| 60 | +[netcore3]: https://dotnet.microsoft.com/download/dotnet-core/3.0 |
| 61 | +[docker]: https://www.docker.com/ |
0 commit comments