Skip to content

Instantly share code, notes, and snippets.

@brackendev
Last active July 7, 2019 03:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brackendev/17cb61112493e4bc906e0d6f7d3ee11b to your computer and use it in GitHub Desktop.
Save brackendev/17cb61112493e4bc906e0d6f7d3ee11b to your computer and use it in GitHub Desktop.
[Shell] Bootstrap an F# Visual Studio solution on UNIX (with console, library, and test projects)
#!/bin/sh
# Bootstrap an F# Visual Studio solution on UNIX (with console, library, and test projects)
########## Create solution ##########
mkdir $1
cd $1
dotnet new sln
echo •••••••••• $1 solution created ••••••••••
########## Create library project ##########
mkdir $1.Library
cd $1.Library
dotnet new classlib -lang F#
cd ..
dotnet sln add ./$1.Library/$1.Library.fsproj
echo •••••••••• $1 library project created ••••••••••
########## Create console project ##########
mkdir $1.Console
cd $1.Console
dotnet new console -lang F#
dotnet add reference ../$1.Library/$1.Library.fsproj
cd ..
dotnet sln add ./$1.Console/$1.Console.fsproj
echo •••••••••• $1 console project created ••••••••••
########## Create test project ##########
mkdir $1.Tests
cd $1.Tests
dotnet new xunit -lang F#
dotnet add reference ../$1.Library/$1.Library.fsproj
cd ..
dotnet sln add ./$1.Tests/$1.Tests.fsproj
echo •••••••••• $1 test project created ••••••••••
########## Create Console/Program.fs ##########
echo "open System
open $1.$1
[<EntryPoint>]
let main argv =
printfn \"%s\" $1.$1.helloWorld
0" > $1.Console/Program.fs
echo •••••••••• $1.Console/Program.fs created ••••••••••
########## Create Library/Library.fs ##########
echo "namespace $1
module $1 =
let helloWorld: string = \"Hello, World!\"" > $1.Library/Library.fs
echo •••••••••• $1.Library/Library.fs created ••••••••••
########## Create Tests/Tests.fs ##########
echo "module Tests
open Xunit
open $1
[<Fact>]
let \`\`$1.helloWorld test\`\` () =
Assert.Equal(\"Hello, World!\", $1.helloWorld)" > $1.Tests/Tests.fs
echo •••••••••• $1.Tests/Tests.fs created ••••••••••
########## Test ##########
dotnet test
echo •••••••••• Tested ••••••••••
########## Run ##########
cd $1.Console
dotnet run
cd ..
echo •••••••••• Ran ••••••••••
########## .gitignore ##########
wget -O .gitignore https://raw.githubusercontent.com/github/gitignore/master/VisualStudio.gitignore
echo •••••••••• .gitignore created ••••••••••
cd ..
echo •••••••••• $1 bootstrapped! ••••••••••
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment