Skip to content

Instantly share code, notes, and snippets.

@johnazariah
Last active July 11, 2018 07:33
Show Gist options
  • Save johnazariah/d3607bf770db74083f1095c604fe614d to your computer and use it in GitHub Desktop.
Save johnazariah/d3607bf770db74083f1095c604fe614d to your computer and use it in GitHub Desktop.
Getting Organised with Orleans 2.0 in .NET Core

Getting Organized with Orleans 2.0 on .NET Core

Prerequisites

  • Install .NET Core >= 2.1.3 so you have access to dotnet tool install.
  • Install Fake 5.0 with dotnet tool install fake-cli -g.
  • Install Fake Templates with dotnet new -i "fake-template::*"

Building an Orleans Solution

  • Create a new folder and cd into it
  • Create a new Fake script with dotnet new fake.
  • Run fake run build.fsx a first time. This will build a dummy target and download all the packages fake needs.
  • Copy over the build.fsx from this gist.
  • Run fake run build.fsx -t Setup to create a shell solution and projects, and wire up the dependencies. You shouldn't have to run the Setup target again for this solution!
  • Run fake run build.fsx to build the newly created solution.
  • Modify the projects to suit your desires and run fake run build.fsx to build the solution again.

References

Updates

  • 2018-07-10 .NET Core 2.1 - Contracts requires a reference to Microsoft.Orleans.Core as well
#load ".fake/build.fsx/intellisense.fsx"
open Fake.Core
open Fake.DotNet
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open Fake.Core.TargetOperators
Target.create "Contracts" (fun _ ->
ignore <| DotNet.exec id "new" "classlib --name Contracts --no-restore"
ignore <| DotNet.exec id "add" "Contracts/Contracts.csproj package Microsoft.Orleans.Core --no-restore"
ignore <| DotNet.exec id "add" "Contracts/Contracts.csproj package Microsoft.Orleans.Core.Abstractions --no-restore"
ignore <| DotNet.exec id "add" "Contracts/Contracts.csproj package Microsoft.Orleans.OrleansCodeGenerator.Build --no-restore"
)
Target.create "Grains" (fun _ ->
ignore <| DotNet.exec id "new" "classlib --name Grains --no-restore"
ignore <| DotNet.exec id "add" "Grains/Grains.csproj package Microsoft.Orleans.Core.Abstractions --no-restore"
ignore <| DotNet.exec id "add" "Grains/Grains.csproj package Microsoft.Orleans.OrleansCodeGenerator.Build --no-restore"
ignore <| DotNet.exec id "add" "Grains/Grains.csproj reference Contracts/Contracts.csproj"
)
Target.create "Silo" (fun _ ->
ignore <| DotNet.exec id "new" "console --name Silo --no-restore"
ignore <| DotNet.exec id "add" "Silo/Silo.csproj package Microsoft.Orleans.Server --no-restore"
ignore <| DotNet.exec id "add" "Silo/Silo.csproj package Microsoft.Extensions.Logging.Console --no-restore"
ignore <| DotNet.exec id "add" "Silo/Silo.csproj package OrleansDashboard --no-restore"
ignore <| DotNet.exec id "add" "Silo/Silo.csproj reference Contracts/Contracts.csproj"
ignore <| DotNet.exec id "add" "Silo/Silo.csproj reference Grains/Grains.csproj"
)
Target.create "Client" (fun _ ->
ignore <| DotNet.exec id "new" "webapi --name Client --no-restore"
ignore <| DotNet.exec id "add" "Client/Client.csproj package Microsoft.Orleans.Client --no-restore"
ignore <| DotNet.exec id "add" "Client/Client.csproj package Microsoft.Extensions.Logging.Console --no-restore"
ignore <| DotNet.exec id "add" "Client/Client.csproj reference Contracts/Contracts.csproj"
)
Target.create "Solution" (fun _ ->
ignore <| DotNet.exec id "new" "sln --name Orleans2"
ignore <| DotNet.exec id "sln" "Orleans2.sln add Contracts/Contracts.csproj"
ignore <| DotNet.exec id "sln" "Orleans2.sln add Grains/Grains.csproj"
ignore <| DotNet.exec id "sln" "Orleans2.sln add Silo/Silo.csproj"
ignore <| DotNet.exec id "sln" "Orleans2.sln add Client/Client.csproj"
)
Target.create "SetupSilo" ignore
Target.create "SetupClient" ignore
"Contracts"
==> "Grains"
==> "Silo"
==> "SetupSilo"
"Contracts"
==> "Grains"
==> "Client"
==> "SetupClient"
"SetupSilo" ==> "Solution"
"SetupClient" ==> "Solution"
Target.create "Setup" ignore
"Solution" ==> "Setup"
Target.create "Clean" (fun _ ->
!! "src/**/bin"
++ "src/**/obj"
|> Shell.cleanDirs
)
Target.create "Build" (fun _ ->
DotNet.build id ""
)
Target.create "All" ignore
"Clean"
==> "Build"
==> "All"
Target.runOrDefault "All"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment