Skip to content

Instantly share code, notes, and snippets.

@jonsagara
Last active May 18, 2019 06:12
Show Gist options
  • Save jonsagara/764f9f7f2e3f204a802c3d7a86599a5c to your computer and use it in GitHub Desktop.
Save jonsagara/764f9f7f2e3f204a802c3d7a86599a5c to your computer and use it in GitHub Desktop.
Create new F# .NET Core solution on macOS via CLI and using paket
# Create a solution and directory
dotnet new sln -o Test3
cd Test3
# Add an F# project to the solution file
dotnet new console -lang F# -o src/App
# Add the F# project to the solution file
dotnet sln add src/App/App.fsproj
# Download the Paket bootstrapper
mkdir .paket
curl -L https://github.com/fsprojects/Paket/releases/download/5.207.0/paket.bootstrapper.exe -o .paket/paket.bootstrapper.exe
# Initialize Paket
mono .paket/paket.bootstrapper.exe
mono .paket/paket.exe init
# Add FSharp.Core to the F# Project
mono .paket/paket.exe add --project src/App/App.fsproj FSharp.Core
# Make sure it builds and runs
dotnet build
dotnet run --project src/App
# Optional, just for testing ability to reference nuget packages via Paket in .fsx files
# Add support for Newtonsoft.Json
mono .paket/paket.exe add --project src/App/App.fsproj Newtonsoft.Json
# Open the solution in VS Code
code .
# Add an F# Script file (TestNewtonsoftJson.fsx) to the src/App subdirectory, and add the following contents:
#I "../../packages"
#r "NETStandard.Library/build/netstandard2.0/ref/netstandard.dll"
#r "Newtonsoft.Json/lib/netstandard2.0/Newtonsoft.Json.dll"
open Newtonsoft.Json
type Person = {
Name: string
}
let json = JsonConvert.SerializeObject({ Name = "Jon" })
printfn "Serialized person: %s" json
# Highlight all contents, then ALT+ENTER to send it to FSI in VS Code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment