Skip to content

Instantly share code, notes, and snippets.

@ianphil
Created March 29, 2022 01:24
Show Gist options
  • Save ianphil/01cfb8a77d1d31e1ad657131a099d1f7 to your computer and use it in GitHub Desktop.
Save ianphil/01cfb8a77d1d31e1ad657131a099d1f7 to your computer and use it in GitHub Desktop.
dotnet 6 "Hello World" Orleans setup script for bash
#!/usr/bin/env bash
POSITIONAL=()
while (( $# > 0 )); do
case "${1}" in
-d|--directory)
SOLUTION_NAME="${2^}"
shift
;;
*)
POSITIONAL+=("${1}")
shift
;;
esac
done
set -- "${POSITIONAL[@]}"
SOURCE_DIRECTORY="$HOME/src" # TODO: This might not be others code directory!
SOLUTION_PATH="$SOURCE_DIRECTORY/$SOLUTION_NAME"
SILO_PROJECT_NAME="${SOLUTION_NAME}Silo"
CLIENT_PROJECT_NAME="${SOLUTION_NAME}Client"
GRAINS_PROJECT_NAME="${SOLUTION_NAME}Grains"
GRAIN_INTERFACES_PROJECT_NAME="${SOLUTION_NAME}GrainInterfaces"
SILO_PROJECT_PATH="$SOLUTION_PATH/$SILO_PROJECT_NAME"
CLIENT_PROJECT_PATH="$SOLUTION_PATH/$CLIENT_PROJECT_NAME"
GRAINS_PROJECT_PATH="$SOLUTION_PATH/$GRAINS_PROJECT_NAME"
GRAIN_INTERFACES_PROJECT_PATH="$SOLUTION_PATH/$GRAIN_INTERFACES_PROJECT_NAME"
SILO_CSPROJ="$SILO_PROJECT_PATH/${SILO_PROJECT_NAME}.csproj"
CLIENT_CSPROJ="$CLIENT_PROJECT_PATH/${CLIENT_PROJECT_NAME}.csproj"
GRAINS_CSPROJ="$GRAINS_PROJECT_PATH/${GRAINS_PROJECT_NAME}.csproj"
GRAIN_INTERFACE_CSPROJ="$GRAIN_INTERFACES_PROJECT_PATH/${GRAIN_INTERFACES_PROJECT_NAME}.csproj"
mkdir -p "$SOLUTION_PATH"
pushd "$SOLUTION_PATH"
dotnet new sln
mkdir -p "$SILO_PROJECT_PATH"
mkdir -p "$CLIENT_PROJECT_PATH"
mkdir -p "$GRAINS_PROJECT_PATH"
mkdir -p "$GRAIN_INTERFACES_PROJECT_PATH"
dotnet new console -o "$SILO_PROJECT_PATH"
dotnet new console -o "$CLIENT_PROJECT_PATH"
dotnet new classlib -o "$GRAINS_PROJECT_PATH"
dotnet new classlib -o "$GRAIN_INTERFACES_PROJECT_PATH"
dotnet sln add "$SILO_CSPROJ"
dotnet sln add "$CLIENT_CSPROJ"
dotnet sln add "$GRAINS_CSPROJ"
dotnet sln add "$GRAIN_INTERFACE_CSPROJ"
dotnet add "$CLIENT_CSPROJ" reference "$GRAIN_INTERFACE_CSPROJ"
dotnet add "$SILO_CSPROJ" reference "$GRAIN_INTERFACE_CSPROJ"
dotnet add "$GRAINS_CSPROJ" reference "$GRAIN_INTERFACE_CSPROJ"
dotnet add "$SILO_CSPROJ" reference "$GRAINS_CSPROJ"
dotnet add "$SILO_CSPROJ" package Microsoft.Orleans.Server --version 3.6.0
dotnet add "$SILO_CSPROJ" package Microsoft.Extensions.Logging.Console --version 6.0.0
dotnet add "$CLIENT_CSPROJ" package Microsoft.Extensions.Logging.Console --version 6.0.0
dotnet add "$CLIENT_CSPROJ" package Microsoft.Orleans.Client --version 3.6.0
dotnet add "$GRAIN_INTERFACE_CSPROJ" package Microsoft.Orleans.Core.Abstractions --version 3.6.0
dotnet add "$GRAIN_INTERFACE_CSPROJ" package Microsoft.Orleans.CodeGenerator.MSBuild --version 3.6.0
dotnet add "$GRAINS_CSPROJ" package Microsoft.Orleans.CodeGenerator.MSBuild --version 3.6.0
dotnet add "$GRAINS_CSPROJ" package Microsoft.Orleans.Core.Abstractions --version 3.6.0
dotnet add "$GRAINS_CSPROJ" package Microsoft.Orleans.Runtime.Abstractions --version 3.6.0
dotnet add "$GRAINS_CSPROJ" package Microsoft.Extensions.Logging.Abstractions --version 6.0.0
dotnet restore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment