Created
June 13, 2018 17:08
-
-
Save MLKrisJohnson/5eeaeec151045f3bfac7f515e3380b31 to your computer and use it in GitHub Desktop.
Compile script for using .NET Core with CodeRunner <https://coderunnerapp.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# To use CodeRunner with .NET Core on a Mac, do this: | |
# | |
# 1. Buy CodeRunner <https://coderunnerapp.com> | |
# 2. Download and install .NET Core SDK from <https://www.microsoft.com/net/learn/get-started/macos> | |
# 3. Launch CodeRunner and open its Preferences | |
# 4. In the Languages pane: | |
# - Select the existing "C#" language (which is for Mono), click the | |
# gear icon at the bottom of the window and choose Duplicate, then | |
# name the new language "C# .NET Core". | |
# - Ensure the "Language uses compile script" checkbox is checked, | |
# click the "Edit Script" button, and replace the script content | |
# with this file. Save. | |
# - In the "Run command" entry field, replace contents with this: | |
# dotnet run --no-build --project "$compiler" | |
# - Close the Preferences window | |
# 5. Now you can choose "C# .NET Core" as your language in the upper-left | |
# pop-up menu, write some code, and it will be compiled and run | |
# using the .NET Core SDK. | |
# This is a CodeRunner compile script. Compile scripts are used to compile | |
# code before being run using the run command specified in CodeRunner | |
# preferences. This script is invoked with the following properties: | |
# | |
# Current directory: The directory of the source file being run | |
# | |
# Arguments $1-$n: User-defined compile flags | |
# | |
# Environment: $CR_FILENAME Filename of the source file being run | |
# $CR_ENCODING Encoding code of the source file | |
# $CR_TMPDIR Path of CodeRunner's temporary directory | |
# | |
# This script should have the following return values: | |
# | |
# Exit status: 0 on success (CodeRunner will continue and execute run command) | |
# | |
# Output (stdout): On success, one line of text which can be accessed | |
# using the $compiler variable in the run command | |
# | |
# Output (stderr): Anything outputted here will be displayed in | |
# the CodeRunner console | |
# HOME isn't available to this script, but dotnet needs it. | |
export HOME="/Users/$(whoami)" | |
cr_path="$(pwd)/$CR_FILENAME" | |
if [ -d "$CR_TMPDIR/cr_dotnet" ]; then | |
rm -rf "$CR_TMPDIR/dotnet" | |
fi | |
mkdir -p "$CR_TMPDIR/dotnet" | |
cd "$CR_TMPDIR/dotnet" | |
dotnet new console >/dev/null | |
cp "$cr_path" Program.cs | |
dotnet build >/dev/null | |
status=$? | |
if [ $status -eq 0 ]; then | |
echo "$(pwd)/dotnet.csproj" | |
fi | |
exit $status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment