├── .gitattributes
├── src
├── content
│ ├── None
│ │ ├── src
│ │ │ └── AppName.1
│ │ │ │ ├── paket.references
│ │ │ │ ├── Models.fs
│ │ │ │ ├── web.config
│ │ │ │ ├── HttpHandlers.fs
│ │ │ │ ├── AppName.1.fsproj
│ │ │ │ └── Program.fs
│ │ ├── paket.dependencies
│ │ ├── tests
│ │ │ └── AppName.1.Tests
│ │ │ │ ├── AppName.1.Tests.fsproj
│ │ │ │ └── Tests.fs
│ │ └── paket.lock
│ ├── Razor
│ │ ├── src
│ │ │ └── AppName.1
│ │ │ │ ├── Views
│ │ │ │ ├── Partial.cshtml
│ │ │ │ ├── Index.cshtml
│ │ │ │ └── _Layout.cshtml
│ │ │ │ ├── paket.references
│ │ │ │ ├── Models.fs
│ │ │ │ ├── WebRoot
│ │ │ │ └── main.css
│ │ │ │ ├── web.config
│ │ │ │ ├── AppName.1.fsproj
│ │ │ │ └── Program.fs
│ │ ├── paket.dependencies
│ │ ├── tests
│ │ │ └── AppName.1.Tests
│ │ │ │ ├── AppName.1.Tests.fsproj
│ │ │ │ └── Tests.fs
│ │ └── paket.lock
│ ├── DotLiquid
│ │ ├── src
│ │ │ └── AppName.1
│ │ │ │ ├── paket.references
│ │ │ │ ├── Models.fs
│ │ │ │ ├── WebRoot
│ │ │ │ └── main.css
│ │ │ │ ├── Views
│ │ │ │ └── Index.html
│ │ │ │ ├── web.config
│ │ │ │ ├── AppName.1.fsproj
│ │ │ │ └── Program.fs
│ │ ├── tests
│ │ │ └── AppName.1.Tests
│ │ │ │ ├── paket.references
│ │ │ │ ├── AppName.1.Tests.fsproj
│ │ │ │ └── Tests.fs
│ │ ├── paket.dependencies
│ │ └── paket.lock
│ ├── Giraffe
│ │ ├── src
│ │ │ └── AppName.1
│ │ │ │ ├── paket.references
│ │ │ │ ├── WebRoot
│ │ │ │ └── main.css
│ │ │ │ ├── web.config
│ │ │ │ ├── AppName.1.fsproj
│ │ │ │ └── Program.fs
│ │ ├── paket.dependencies
│ │ ├── tests
│ │ │ └── AppName.1.Tests
│ │ │ │ ├── AppName.1.Tests.fsproj
│ │ │ │ └── Tests.fs
│ │ └── paket.lock
│ ├── Paket
│ │ ├── tests
│ │ │ └── AppName.1.Tests
│ │ │ │ └── paket.references
│ │ └── .config
│ │ │ └── dotnet-tools.json
│ ├── _Default
│ │ ├── build.bat
│ │ ├── build.sh
│ │ ├── README.md
│ │ └── AppName.1.sln
│ └── .template.config
│ │ └── template.json
└── giraffe-template.nuspec
├── giraffe-64x64.png
├── global.json
├── appveyor.yml
├── .psscripts
├── install-dotnet.ps1
├── nuget-updates.ps1
└── build-functions.ps1
├── RELEASE_NOTES.md
├── .gitignore
├── LICENSE
└── README.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 | *.sh text eol=lf
--------------------------------------------------------------------------------
/src/content/None/src/AppName.1/paket.references:
--------------------------------------------------------------------------------
1 | Giraffe
--------------------------------------------------------------------------------
/src/content/Razor/src/AppName.1/Views/Partial.cshtml:
--------------------------------------------------------------------------------
1 |
AppName.1
--------------------------------------------------------------------------------
/src/content/Razor/src/AppName.1/paket.references:
--------------------------------------------------------------------------------
1 | Giraffe
2 | Giraffe.Razor
--------------------------------------------------------------------------------
/src/content/DotLiquid/src/AppName.1/paket.references:
--------------------------------------------------------------------------------
1 | Giraffe
2 | Giraffe.DotLiquid
--------------------------------------------------------------------------------
/src/content/Giraffe/src/AppName.1/paket.references:
--------------------------------------------------------------------------------
1 | Giraffe
2 | Giraffe.ViewEngine
--------------------------------------------------------------------------------
/giraffe-64x64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/giraffe-fsharp/giraffe-template/master/giraffe-64x64.png
--------------------------------------------------------------------------------
/src/content/DotLiquid/tests/AppName.1.Tests/paket.references:
--------------------------------------------------------------------------------
1 | Microsoft.NET.Test.Sdk
2 | Microsoft.AspNetCore.TestHost
3 | xunit
4 | xunit.runner.visualstudio
--------------------------------------------------------------------------------
/src/content/None/src/AppName.1/Models.fs:
--------------------------------------------------------------------------------
1 | namespace AppName._1.Models
2 |
3 | []
4 | type Message =
5 | {
6 | Text : string
7 | }
--------------------------------------------------------------------------------
/src/content/Razor/src/AppName.1/Models.fs:
--------------------------------------------------------------------------------
1 | namespace AppName._1.Models
2 |
3 | []
4 | type Message =
5 | {
6 | Text : string
7 | }
--------------------------------------------------------------------------------
/src/content/DotLiquid/src/AppName.1/Models.fs:
--------------------------------------------------------------------------------
1 | namespace AppName._1.Models
2 |
3 | []
4 | type Message =
5 | {
6 | Text : string
7 | }
--------------------------------------------------------------------------------
/src/content/Paket/tests/AppName.1.Tests/paket.references:
--------------------------------------------------------------------------------
1 | Microsoft.NET.Test.Sdk
2 | Microsoft.AspNetCore.TestHost
3 | xunit
4 | xunit.runner.visualstudio
5 | FSharp.Core
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "projects": [ "src", "tests" ],
3 | "sdk": {
4 | "version": "8.0.300",
5 | "rollForward": "latestMajor",
6 | "allowPrerelease": false
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/content/Razor/src/AppName.1/Views/Index.cshtml:
--------------------------------------------------------------------------------
1 | @model AppName._1.Models.Message
2 | @{
3 | Layout = "_Layout";
4 | }
5 | @{
6 | await Html.RenderPartialAsync("Partial");
7 | }
8 |
9 | @Model.Text
10 |
--------------------------------------------------------------------------------
/src/content/Razor/src/AppName.1/WebRoot/main.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: Arial, Helvetica, sans-serif;
3 | color: #333;
4 | font-size: .9em;
5 | }
6 |
7 | h1 {
8 | font-size: 1.5em;
9 | color: #334499;
10 | }
--------------------------------------------------------------------------------
/src/content/DotLiquid/src/AppName.1/WebRoot/main.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: Arial, Helvetica, sans-serif;
3 | color: #333;
4 | font-size: .9em;
5 | }
6 |
7 | h1 {
8 | font-size: 1.5em;
9 | color: #334499;
10 | }
--------------------------------------------------------------------------------
/src/content/Giraffe/src/AppName.1/WebRoot/main.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: Arial, Helvetica, sans-serif;
3 | color: #333;
4 | font-size: .9em;
5 | }
6 |
7 | h1 {
8 | font-size: 1.5em;
9 | color: #334499;
10 | }
--------------------------------------------------------------------------------
/src/content/Paket/.config/dotnet-tools.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "isRoot": true,
4 | "tools": {
5 | "paket": {
6 | "version": "7.2.0",
7 | "commands": [
8 | "paket"
9 | ]
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/src/content/Razor/src/AppName.1/Views/_Layout.cshtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | AppName.1
5 |
6 |
7 |
8 | @RenderBody()
9 |
10 |
--------------------------------------------------------------------------------
/src/content/None/paket.dependencies:
--------------------------------------------------------------------------------
1 | storage: none
2 | framework: auto-detect
3 | source https://api.nuget.org/v3/index.json
4 |
5 | nuget Giraffe ~> 6.4.0
6 | nuget Microsoft.NET.Test.Sdk
7 | nuget Microsoft.AspNetCore.TestHost
8 | nuget xunit
9 | nuget xunit.runner.visualstudio
--------------------------------------------------------------------------------
/src/content/DotLiquid/src/AppName.1/Views/Index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | AppName.1
5 |
6 |
7 |
8 | AppName.1
9 |
10 | {{ text }}
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/content/Giraffe/paket.dependencies:
--------------------------------------------------------------------------------
1 | storage: none
2 | framework: auto-detect
3 | source https://api.nuget.org/v3/index.json
4 |
5 | nuget Giraffe ~> 6.4.0
6 | nuget Giraffe.ViewEngine
7 | nuget Microsoft.NET.Test.Sdk
8 | nuget Microsoft.AspNetCore.TestHost
9 | nuget xunit
10 | nuget xunit.runner.visualstudio
--------------------------------------------------------------------------------
/src/content/_Default/build.bat:
--------------------------------------------------------------------------------
1 | rem #if (Paket)
2 | dotnet tool restore
3 | IF NOT EXIST paket.lock (
4 | dotnet paket install
5 | ) ELSE (
6 | dotnet paket restore
7 | )
8 | rem #endif
9 | dotnet restore
10 | dotnet build --no-restore
11 | rem #if (!ExcludeTests)
12 | dotnet test --no-build
13 | rem #endif
--------------------------------------------------------------------------------
/src/content/_Default/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #if (Paket)
3 | dotnet tool restore
4 | if [ ! -e "paket.lock" ]
5 | then
6 | dotnet paket install
7 | else
8 | dotnet paket restore
9 | fi
10 | #endif
11 | dotnet restore
12 | dotnet build --no-restore
13 | #if (!ExcludeTests)
14 | dotnet test --no-build
15 | #endif
--------------------------------------------------------------------------------
/src/content/DotLiquid/paket.dependencies:
--------------------------------------------------------------------------------
1 | storage: none
2 | framework: auto-detect
3 | source https://api.nuget.org/v3/index.json
4 |
5 | nuget Giraffe ~> 6.4.0
6 | nuget Giraffe.DotLiquid >= 3 prerelease
7 | nuget Microsoft.NET.Test.Sdk
8 | nuget Microsoft.AspNetCore.TestHost
9 | nuget xunit
10 | nuget xunit.runner.visualstudio
--------------------------------------------------------------------------------
/src/content/Razor/paket.dependencies:
--------------------------------------------------------------------------------
1 | storage: none
2 | framework: auto-detect
3 | source https://api.nuget.org/v3/index.json
4 |
5 | nuget Giraffe ~> 6.4.0
6 | nuget Giraffe.Razor >= 5.1.0 prerelease
7 | nuget Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation ~> 8.0
8 | nuget Microsoft.NET.Test.Sdk
9 | nuget Microsoft.AspNetCore.TestHost
10 | nuget xunit
11 | nuget xunit.runner.visualstudio
12 |
--------------------------------------------------------------------------------
/src/content/None/src/AppName.1/web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/content/Razor/src/AppName.1/web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/content/DotLiquid/src/AppName.1/web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/content/Giraffe/src/AppName.1/web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/content/None/src/AppName.1/HttpHandlers.fs:
--------------------------------------------------------------------------------
1 | namespace AppName._1
2 |
3 | module HttpHandlers =
4 |
5 | open Microsoft.AspNetCore.Http
6 | open Giraffe
7 | open AppName._1.Models
8 |
9 | let handleGetHello =
10 | fun (next : HttpFunc) (ctx : HttpContext) ->
11 | task {
12 | let response = {
13 | Text = "Hello world, from Giraffe!"
14 | }
15 | return! json response next ctx
16 | }
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | version: 0.1.0-{build}
2 | image: Visual Studio 2022
3 | environment:
4 | DOTNET_CLI_TELEMETRY_OPTOUT: 1
5 | init:
6 | - git config --global core.autocrlf true
7 | install:
8 | - ps: .\.psscripts\install-dotnet.ps1 -SdkVersions "8.0.300"
9 | build: off
10 | build_script:
11 | - ps: .\build.ps1
12 | test: off
13 | artifacts:
14 | - path: '**\giraffe-template.*.nupkg'
15 | name: Giraffe Template package
16 | nuget:
17 | account_feed: false
18 | project_feed: true
19 | deploy:
20 | provider: NuGet
21 | api_key:
22 | secure: U0+zbuUi8+HYyp6Ks14srAKnN379SjFH+Se7wwVwyDMQ+OmghTby2HZrZMtiQvnv
23 | skip_symbols: false
24 | artifact: /.*\.nupkg/
25 | on:
26 | appveyor_repo_tag: true
27 |
--------------------------------------------------------------------------------
/src/content/None/src/AppName.1/AppName.1.fsproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | AppName.1
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/content/None/tests/AppName.1.Tests/AppName.1.Tests.fsproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/content/Giraffe/tests/AppName.1.Tests/AppName.1.Tests.fsproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/content/DotLiquid/tests/AppName.1.Tests/AppName.1.Tests.fsproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/content/Razor/tests/AppName.1.Tests/AppName.1.Tests.fsproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net8.0
4 | true
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/giraffe-template.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | giraffe-template
5 | 1.5.002
6 | Giraffe Template for dotnet-new
7 | A dotnet-new template for Giraffe web applications.
8 | A dotnet-new template for Giraffe web applications.
9 | Dustin Moris Gorski, David Sinclair and contributors
10 | Dustin Moris Gorski
11 | https://github.com/giraffe-fsharp/giraffe-template
12 | images/giraffe-64x64.png
13 | false
14 | https://raw.githubusercontent.com/giraffe-fsharp/Giraffe/master/RELEASE_NOTES.md
15 | en-GB
16 | giraffe web app razor pages micro service dotnet new template
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/content/Giraffe/src/AppName.1/AppName.1.fsproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | AppName.1
6 | false
7 | true
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | PreserveNewest
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/content/_Default/README.md:
--------------------------------------------------------------------------------
1 | # AppName.1
2 |
3 | A [Giraffe](https://github.com/giraffe-fsharp/Giraffe) web application, which has been created via the `dotnet new giraffe` command.
4 |
5 | ## Build and test the application
6 |
7 | ### Windows
8 |
9 | Run the `build.bat` script in order to restore, build and test (if you've selected to include tests) the application:
10 |
11 | ```
12 | > ./build.bat
13 | ```
14 |
15 | ### Linux/macOS
16 |
17 | Run the `build.sh` script in order to restore, build and test (if you've selected to include tests) the application:
18 |
19 | ```
20 | $ ./build.sh
21 | ```
22 |
23 | ## Run the application
24 |
25 | After a successful build you can start the web application by executing the following command in your terminal:
26 |
27 | ```
28 | dotnet run -p src/AppName.1
29 | ```
30 |
31 | The application uses HTTPS redirection when run in production which is the default unless explicitly overridden. If you don't have a certificate configured for HTTPS, be sure to set `ASPNETCORE_ENVIRONMENT=Development`. In order to test production mode during development you can generate a self signed certificate using this guide: https://docs.microsoft.com/en-us/dotnet/core/additional-tools/self-signed-certificates-guide
32 |
33 | After the application has started visit [http://localhost:5000](http://localhost:5000) in your preferred browser.
--------------------------------------------------------------------------------
/src/content/DotLiquid/src/AppName.1/AppName.1.fsproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | AppName.1
6 | false
7 | true
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | PreserveNewest
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/content/Razor/src/AppName.1/AppName.1.fsproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | AppName.1
6 | false
7 | true
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | PreserveNewest
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/.psscripts/install-dotnet.ps1:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------
2 | # Install .NET SDK
3 | # ----------------------------------------------
4 |
5 | param
6 | (
7 | [switch] $ForceUbuntuInstall
8 | )
9 |
10 | $ErrorActionPreference = "Stop"
11 |
12 | Import-module "$PSScriptRoot\build-functions.ps1" -Force
13 |
14 | if ($ForceUbuntuInstall.IsPresent)
15 | {
16 | $desiredSdk = Get-DesiredSdk
17 | $versionParts = $desiredSdk.Split(".")
18 | $majorMinorVer = $versionParts[0] + "." + $versionParts[1]
19 | $ubuntuVersion = Get-UbuntuVersion
20 |
21 | Write-Host "Ubuntu version: $ubuntuVersion"
22 | Install-NetSdkForUbuntu $ubuntuVersion $majorMinorVer
23 | return
24 | }
25 |
26 | # Rename the global.json before making the dotnet --version call
27 | # This will prevent AppVeyor to fail because it might not find
28 | # the desired SDK specified in the global.json
29 | $globalJson = Get-Item "$PSScriptRoot\..\global.json"
30 | Rename-Item -Path $globalJson.FullName -NewName "global.json.bak" -Force
31 |
32 | # Get the current .NET SDK version
33 | $currentSdk = dotnet-version
34 |
35 | # After we established the current installed .NET SDK we can put the global.json back
36 | Rename-Item -Path ($globalJson.FullName + ".bak") -NewName "global.json" -Force
37 |
38 | $desiredSdk = Get-DesiredSdk
39 |
40 | if ($desiredSdk -eq $currentSdk)
41 | {
42 | Write-Host "The current .NET SDK matches the project's desired .NET SDK: $desiredSDK" -ForegroundColor Green
43 | return
44 | }
45 |
46 | Write-Host "The current .NET SDK ($currentSdk) doesn't match the project's desired .NET SDK ($desiredSdk)." -ForegroundColor Yellow
47 |
48 | Write-Host "Attempting to download and install the correct .NET SDK..."
49 |
50 | $sdkZipPath = Get-NetSdkFromWeb $desiredSdk
51 | Install-NetSdkFromArchive $sdkZipPath
52 |
53 | Write-Host ".NET SDK installation complete." -ForegroundColor Green
54 | dotnet-version
--------------------------------------------------------------------------------
/src/content/Giraffe/paket.lock:
--------------------------------------------------------------------------------
1 | STORAGE: NONE
2 | RESTRICTION: == net8.0
3 | NUGET
4 | remote: https://api.nuget.org/v3/index.json
5 | FSharp.Core (8.0.200)
6 | Giraffe (6.0)
7 | FSharp.Core (>= 6.0.1)
8 | Giraffe.ViewEngine (>= 1.3)
9 | Microsoft.IO.RecyclableMemoryStream (>= 2.2)
10 | Newtonsoft.Json (>= 13.0.1)
11 | System.Text.Json (>= 6.0.2)
12 | Utf8Json (>= 1.3.7)
13 | Giraffe.ViewEngine (1.4)
14 | FSharp.Core (>= 5.0)
15 | Microsoft.AspNetCore.TestHost (8.0.4)
16 | System.IO.Pipelines (>= 8.0)
17 | Microsoft.CodeCoverage (17.9)
18 | Microsoft.IO.RecyclableMemoryStream (3.0)
19 | Microsoft.NET.Test.Sdk (17.9)
20 | Microsoft.CodeCoverage (>= 17.9)
21 | Microsoft.TestPlatform.TestHost (>= 17.9)
22 | Microsoft.TestPlatform.ObjectModel (17.9)
23 | System.Reflection.Metadata (>= 1.6)
24 | Microsoft.TestPlatform.TestHost (17.9)
25 | Microsoft.TestPlatform.ObjectModel (>= 17.9)
26 | Newtonsoft.Json (>= 13.0.1)
27 | Newtonsoft.Json (13.0.3)
28 | System.Collections.Immutable (8.0)
29 | System.IO.Pipelines (8.0)
30 | System.Reflection.Emit (4.7)
31 | System.Reflection.Emit.Lightweight (4.7)
32 | System.Reflection.Metadata (8.0)
33 | System.Collections.Immutable (>= 8.0)
34 | System.Text.Encodings.Web (8.0)
35 | System.Text.Json (8.0.3)
36 | System.Text.Encodings.Web (>= 8.0)
37 | System.Threading.Tasks.Extensions (4.5.4)
38 | System.ValueTuple (4.5)
39 | Utf8Json (1.3.7)
40 | System.Reflection.Emit (>= 4.3)
41 | System.Reflection.Emit.Lightweight (>= 4.3)
42 | System.Threading.Tasks.Extensions (>= 4.4)
43 | System.ValueTuple (>= 4.4)
44 | xunit (2.8)
45 | xunit.analyzers (>= 1.13)
46 | xunit.assert (>= 2.8)
47 | xunit.core (2.8)
48 | xunit.abstractions (2.0.3)
49 | xunit.analyzers (1.13)
50 | xunit.assert (2.8)
51 | xunit.core (2.8)
52 | xunit.extensibility.core (2.8)
53 | xunit.extensibility.execution (2.8)
54 | xunit.extensibility.core (2.8)
55 | xunit.abstractions (>= 2.0.3)
56 | xunit.extensibility.execution (2.8)
57 | xunit.extensibility.core (2.8)
58 | xunit.runner.visualstudio (2.8)
59 |
--------------------------------------------------------------------------------
/.psscripts/nuget-updates.ps1:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------
2 | # Helper script to find NuGet package upgrades
3 | # ----------------------------------------------
4 |
5 | function Get-NuGetPackageInfo ($nugetPackageId, $currentVersion)
6 | {
7 | $url = "https://api-v2v3search-0.nuget.org/query?q=$nugetPackageId&prerelease=false"
8 | $result = Invoke-RestMethod -Uri $url -Method Get
9 | $latestVersion = $result.data[0].version
10 | $upgradeAvailable = $currentVersion -and !$latestVersion.StartsWith($currentVersion.Replace("*", ""))
11 |
12 | [PSCustomObject]@{
13 | PackageName = $nugetPackageId;
14 | Current = $currentVersion;
15 | Latest = $latestVersion;
16 | UpgradeAvailable = $upgradeAvailable
17 | }
18 | }
19 |
20 | filter Highlight-Upgrades
21 | {
22 | $lines = $_.Split([Environment]::NewLine)
23 | foreach ($line in $lines) {
24 | if ($line.Trim().EndsWith("True")) {
25 | Write-Host $line -ForegroundColor DarkGreen
26 | } else {
27 | Write-Host $line -ForegroundColor Gray
28 | }
29 | }
30 | }
31 |
32 | Write-Host ""
33 | Write-Host ""
34 | Write-Host "--------------------------------------------------" -ForegroundColor DarkYellow
35 | Write-Host " Scanning all projects for NuGet package upgrades " -ForegroundColor DarkYellow
36 | Write-Host "--------------------------------------------------" -ForegroundColor DarkYellow
37 | Write-Host ""
38 |
39 | $projects = Get-ChildItem "$PSScriptRoot\..\**\*.*proj" -Recurse | % { $_.FullName }
40 |
41 | foreach ($project in $projects)
42 | {
43 | $projName = Split-Path $project -Leaf
44 | Write-Host $projName -ForegroundColor Magenta
45 |
46 | [xml]$proj = Get-Content $project
47 | $references = $proj.Project.ItemGroup.PackageReference | Where-Object { $_.Include -ne $null }
48 | $packages = @()
49 |
50 | foreach ($reference in $references)
51 | {
52 | $id = $reference.Include
53 | $version = $reference.Version
54 | $packages += Get-NuGetPackageInfo $id $version
55 | }
56 |
57 | $packages `
58 | | Format-Table -Property PackageName, Current, Latest, UpgradeAvailable -AutoSize `
59 | | Out-String `
60 | | Highlight-Upgrades
61 | }
--------------------------------------------------------------------------------
/src/content/None/tests/AppName.1.Tests/Tests.fs:
--------------------------------------------------------------------------------
1 | module Tests
2 |
3 | open System
4 | open System.IO
5 | open System.Net
6 | open System.Net.Http
7 | open Xunit
8 | open Microsoft.AspNetCore.Builder
9 | open Microsoft.AspNetCore.Hosting
10 | open Microsoft.AspNetCore.TestHost
11 | open Microsoft.Extensions.DependencyInjection
12 |
13 | // ---------------------------------
14 | // Helper functions (extend as you need)
15 | // ---------------------------------
16 |
17 | let createHost() =
18 | WebHostBuilder()
19 | .UseContentRoot(Directory.GetCurrentDirectory())
20 | .Configure(Action AppName._1.App.configureApp)
21 | .ConfigureServices(Action AppName._1.App.configureServices)
22 |
23 | let runTask task =
24 | task
25 | |> Async.AwaitTask
26 | |> Async.RunSynchronously
27 |
28 | let httpGet (path : string) (client : HttpClient) =
29 | path
30 | |> client.GetAsync
31 | |> runTask
32 |
33 | let isStatus (code : HttpStatusCode) (response : HttpResponseMessage) =
34 | Assert.Equal(code, response.StatusCode)
35 | response
36 |
37 | let ensureSuccess (response : HttpResponseMessage) =
38 | if not response.IsSuccessStatusCode
39 | then response.Content.ReadAsStringAsync() |> runTask |> failwithf "%A"
40 | else response
41 |
42 | let readText (response : HttpResponseMessage) =
43 | response.Content.ReadAsStringAsync()
44 | |> runTask
45 |
46 | let shouldEqual (expected : string) (actual : string) =
47 | Assert.Equal(expected, actual)
48 |
49 | let shouldContain (expected : string) (actual : string) =
50 | Assert.True(actual.Contains expected)
51 |
52 | // ---------------------------------
53 | // Tests
54 | // ---------------------------------
55 |
56 | []
57 | let ``Route /api/hello returns "Hello world, from Giraffe!"`` () =
58 | use server = new TestServer(createHost())
59 | use client = server.CreateClient()
60 |
61 | client
62 | |> httpGet "/api/hello"
63 | |> ensureSuccess
64 | |> readText
65 | |> shouldContain "Hello world, from Giraffe!"
66 |
67 | []
68 | let ``Route which doesn't exist returns 404 Page not found`` () =
69 | use server = new TestServer(createHost())
70 | use client = server.CreateClient()
71 |
72 | client
73 | |> httpGet "/route/which/does/not/exist"
74 | |> isStatus HttpStatusCode.NotFound
75 | |> readText
76 | |> shouldEqual "Not Found"
--------------------------------------------------------------------------------
/src/content/DotLiquid/paket.lock:
--------------------------------------------------------------------------------
1 | STORAGE: NONE
2 | RESTRICTION: == net8.0
3 | NUGET
4 | remote: https://api.nuget.org/v3/index.json
5 | DotLiquid (2.2.692)
6 | FSharp.Core (8.0.200)
7 | Giraffe (6.0)
8 | FSharp.Core (>= 6.0.1)
9 | Giraffe.ViewEngine (>= 1.3)
10 | Microsoft.IO.RecyclableMemoryStream (>= 2.2)
11 | Newtonsoft.Json (>= 13.0.1)
12 | System.Text.Json (>= 6.0.2)
13 | Utf8Json (>= 1.3.7)
14 | Giraffe.DotLiquid (3.0.0-rc-1)
15 | DotLiquid (>= 2.0.366)
16 | FSharp.Core (>= 5.0)
17 | Giraffe (>= 5.0.0-rc-6)
18 | Ply (>= 0.3.1)
19 | Giraffe.ViewEngine (1.4)
20 | FSharp.Core (>= 5.0)
21 | Microsoft.AspNetCore.TestHost (8.0.4)
22 | System.IO.Pipelines (>= 8.0)
23 | Microsoft.CodeCoverage (17.9)
24 | Microsoft.IO.RecyclableMemoryStream (3.0)
25 | Microsoft.NET.Test.Sdk (17.9)
26 | Microsoft.CodeCoverage (>= 17.9)
27 | Microsoft.TestPlatform.TestHost (>= 17.9)
28 | Microsoft.TestPlatform.ObjectModel (17.9)
29 | System.Reflection.Metadata (>= 1.6)
30 | Microsoft.TestPlatform.TestHost (17.9)
31 | Microsoft.TestPlatform.ObjectModel (>= 17.9)
32 | Newtonsoft.Json (>= 13.0.1)
33 | Newtonsoft.Json (13.0.3)
34 | Ply (0.3.1)
35 | FSharp.Core (>= 4.6.2)
36 | System.Threading.Tasks.Extensions (>= 4.5.4)
37 | System.Collections.Immutable (8.0)
38 | System.IO.Pipelines (8.0)
39 | System.Reflection.Emit (4.7)
40 | System.Reflection.Emit.Lightweight (4.7)
41 | System.Reflection.Metadata (8.0)
42 | System.Collections.Immutable (>= 8.0)
43 | System.Text.Encodings.Web (8.0)
44 | System.Text.Json (8.0.3)
45 | System.Text.Encodings.Web (>= 8.0)
46 | System.Threading.Tasks.Extensions (4.5.4)
47 | System.ValueTuple (4.5)
48 | Utf8Json (1.3.7)
49 | System.Reflection.Emit (>= 4.3)
50 | System.Reflection.Emit.Lightweight (>= 4.3)
51 | System.Threading.Tasks.Extensions (>= 4.4)
52 | System.ValueTuple (>= 4.4)
53 | xunit (2.8)
54 | xunit.analyzers (>= 1.13)
55 | xunit.assert (>= 2.8)
56 | xunit.core (2.8)
57 | xunit.abstractions (2.0.3)
58 | xunit.analyzers (1.13)
59 | xunit.assert (2.8)
60 | xunit.core (2.8)
61 | xunit.extensibility.core (2.8)
62 | xunit.extensibility.execution (2.8)
63 | xunit.extensibility.core (2.8)
64 | xunit.abstractions (>= 2.0.3)
65 | xunit.extensibility.execution (2.8)
66 | xunit.extensibility.core (2.8)
67 | xunit.runner.visualstudio (2.8)
68 |
--------------------------------------------------------------------------------
/src/content/None/paket.lock:
--------------------------------------------------------------------------------
1 | STORAGE: NONE
2 | RESTRICTION: == net7.0
3 | NUGET
4 | remote: https://api.nuget.org/v3/index.json
5 | FSharp.Core (7.0.400)
6 | Giraffe (6.0)
7 | FSharp.Core (>= 6.0.1)
8 | Giraffe.ViewEngine (>= 1.3)
9 | Microsoft.IO.RecyclableMemoryStream (>= 2.2)
10 | Newtonsoft.Json (>= 13.0.1)
11 | System.Text.Json (>= 6.0.2)
12 | Utf8Json (>= 1.3.7)
13 | Giraffe.ViewEngine (1.4)
14 | FSharp.Core (>= 5.0)
15 | Microsoft.AspNetCore.TestHost (7.0.10)
16 | System.IO.Pipelines (>= 7.0)
17 | Microsoft.CodeCoverage (17.7)
18 | Microsoft.IO.RecyclableMemoryStream (2.3.2)
19 | Microsoft.NET.Test.Sdk (17.7)
20 | Microsoft.CodeCoverage (>= 17.7)
21 | Microsoft.TestPlatform.TestHost (>= 17.7)
22 | Microsoft.NETCore.Platforms (7.0.4)
23 | Microsoft.TestPlatform.ObjectModel (17.7)
24 | NuGet.Frameworks (>= 6.5)
25 | System.Reflection.Metadata (>= 1.6)
26 | Microsoft.TestPlatform.TestHost (17.7)
27 | Microsoft.TestPlatform.ObjectModel (>= 17.7)
28 | Newtonsoft.Json (>= 13.0.1)
29 | NETStandard.Library (2.0.3)
30 | Microsoft.NETCore.Platforms (>= 1.1)
31 | Newtonsoft.Json (13.0.3)
32 | NuGet.Frameworks (6.7)
33 | System.Collections.Immutable (7.0)
34 | System.IO.Pipelines (7.0)
35 | System.Reflection.Emit (4.7)
36 | System.Reflection.Emit.Lightweight (4.7)
37 | System.Reflection.Metadata (7.0.2)
38 | System.Collections.Immutable (>= 7.0)
39 | System.Text.Encodings.Web (7.0)
40 | System.Text.Json (7.0.3)
41 | System.Text.Encodings.Web (>= 7.0)
42 | System.Threading.Tasks.Extensions (4.5.4)
43 | System.ValueTuple (4.5)
44 | Utf8Json (1.3.7)
45 | System.Reflection.Emit (>= 4.3)
46 | System.Reflection.Emit.Lightweight (>= 4.3)
47 | System.Threading.Tasks.Extensions (>= 4.4)
48 | System.ValueTuple (>= 4.4)
49 | xunit (2.5)
50 | xunit.analyzers (>= 1.2)
51 | xunit.assert (>= 2.5)
52 | xunit.core (2.5)
53 | xunit.abstractions (2.0.3)
54 | xunit.analyzers (1.2)
55 | xunit.assert (2.5)
56 | NETStandard.Library (>= 1.6.1)
57 | xunit.core (2.5)
58 | xunit.extensibility.core (2.5)
59 | xunit.extensibility.execution (2.5)
60 | xunit.extensibility.core (2.5)
61 | NETStandard.Library (>= 1.6.1)
62 | xunit.abstractions (>= 2.0.3)
63 | xunit.extensibility.execution (2.5)
64 | NETStandard.Library (>= 1.6.1)
65 | xunit.extensibility.core (2.5)
66 | xunit.runner.visualstudio (2.5)
67 |
--------------------------------------------------------------------------------
/src/content/None/src/AppName.1/Program.fs:
--------------------------------------------------------------------------------
1 | module AppName._1.App
2 |
3 | open System
4 | open Microsoft.AspNetCore.Builder
5 | open Microsoft.AspNetCore.Cors.Infrastructure
6 | open Microsoft.AspNetCore.Hosting
7 | open Microsoft.Extensions.Hosting
8 | open Microsoft.Extensions.Logging
9 | open Microsoft.Extensions.DependencyInjection
10 | open Giraffe
11 | open AppName._1.HttpHandlers
12 |
13 | // ---------------------------------
14 | // Web app
15 | // ---------------------------------
16 |
17 | let webApp =
18 | choose [
19 | subRoute "/api"
20 | (choose [
21 | GET >=> choose [
22 | route "/hello" >=> handleGetHello
23 | ]
24 | ])
25 | setStatusCode 404 >=> text "Not Found" ]
26 |
27 | // ---------------------------------
28 | // Error handler
29 | // ---------------------------------
30 |
31 | let errorHandler (ex : Exception) (logger : ILogger) =
32 | logger.LogError(ex, "An unhandled exception has occurred while executing the request.")
33 | clearResponse >=> setStatusCode 500 >=> text ex.Message
34 |
35 | // ---------------------------------
36 | // Config and Main
37 | // ---------------------------------
38 |
39 | let configureCors (builder : CorsPolicyBuilder) =
40 | builder
41 | .WithOrigins(
42 | "http://localhost:5000",
43 | "https://localhost:5001")
44 | .AllowAnyMethod()
45 | .AllowAnyHeader()
46 | |> ignore
47 |
48 | let configureApp (app : IApplicationBuilder) =
49 | let env = app.ApplicationServices.GetService()
50 | (match env.IsDevelopment() with
51 | | true ->
52 | app.UseDeveloperExceptionPage()
53 | | false ->
54 | app .UseGiraffeErrorHandler(errorHandler)
55 | .UseHttpsRedirection())
56 | .UseCors(configureCors)
57 | .UseGiraffe(webApp)
58 |
59 | let configureServices (services : IServiceCollection) =
60 | services.AddCors() |> ignore
61 | services.AddGiraffe() |> ignore
62 |
63 | let configureLogging (builder : ILoggingBuilder) =
64 | builder.AddConsole()
65 | .AddDebug() |> ignore
66 |
67 | []
68 | let main args =
69 | Host.CreateDefaultBuilder(args)
70 | .ConfigureWebHostDefaults(
71 | fun webHostBuilder ->
72 | webHostBuilder
73 | .Configure(Action configureApp)
74 | .ConfigureServices(configureServices)
75 | .ConfigureLogging(configureLogging)
76 | |> ignore)
77 | .Build()
78 | .Run()
79 | 0
--------------------------------------------------------------------------------
/src/content/Razor/tests/AppName.1.Tests/Tests.fs:
--------------------------------------------------------------------------------
1 | module Tests
2 |
3 | open System
4 | open System.IO
5 | open System.Net
6 | open System.Net.Http
7 | open Xunit
8 | open Microsoft.AspNetCore.Builder
9 | open Microsoft.AspNetCore.Hosting
10 | open Microsoft.AspNetCore.TestHost
11 | open Microsoft.Extensions.DependencyInjection
12 |
13 | // ---------------------------------
14 | // Helper functions (extend as you need)
15 | // ---------------------------------
16 |
17 | let createHost() =
18 | WebHostBuilder()
19 | .UseContentRoot(Directory.GetCurrentDirectory())
20 | .Configure(Action AppName._1.App.configureApp)
21 | .ConfigureServices(Action AppName._1.App.configureServices)
22 |
23 | let runTask task =
24 | task
25 | |> Async.AwaitTask
26 | |> Async.RunSynchronously
27 |
28 | let httpGet (path : string) (client : HttpClient) =
29 | path
30 | |> client.GetAsync
31 | |> runTask
32 |
33 | let isStatus (code : HttpStatusCode) (response : HttpResponseMessage) =
34 | Assert.Equal(code, response.StatusCode)
35 | response
36 |
37 | let ensureSuccess (response : HttpResponseMessage) =
38 | if not response.IsSuccessStatusCode
39 | then response.Content.ReadAsStringAsync() |> runTask |> failwithf "%A"
40 | else response
41 |
42 | let readText (response : HttpResponseMessage) =
43 | response.Content.ReadAsStringAsync()
44 | |> runTask
45 |
46 | let shouldEqual (expected : string) (actual : string) =
47 | Assert.Equal(expected, actual)
48 |
49 | let shouldContain (expected : string) (actual : string) =
50 | Assert.True(actual.Contains expected)
51 |
52 | // ---------------------------------
53 | // Tests
54 | // ---------------------------------
55 |
56 | []
57 | let ``Route / returns "Hello world, from Giraffe!"`` () =
58 | use server = new TestServer(createHost())
59 | use client = server.CreateClient()
60 |
61 | client
62 | |> httpGet "/"
63 | |> ensureSuccess
64 | |> readText
65 | |> shouldContain "Hello world, from Giraffe!"
66 |
67 | []
68 | let ``Route /hello/fooBar returns "Hello fooBar, from Giraffe!"`` () =
69 | use server = new TestServer(createHost())
70 | use client = server.CreateClient()
71 |
72 | client
73 | |> httpGet "/hello/fooBar"
74 | |> ensureSuccess
75 | |> readText
76 | |> shouldContain "Hello fooBar, from Giraffe!"
77 |
78 | []
79 | let ``Route which doesn't exist returns 404 Page not found`` () =
80 | use server = new TestServer(createHost())
81 | use client = server.CreateClient()
82 |
83 | client
84 | |> httpGet "/route/which/does/not/exist"
85 | |> isStatus HttpStatusCode.NotFound
86 | |> readText
87 | |> shouldEqual "Not Found"
--------------------------------------------------------------------------------
/src/content/DotLiquid/tests/AppName.1.Tests/Tests.fs:
--------------------------------------------------------------------------------
1 | module Tests
2 |
3 | open System
4 | open System.IO
5 | open System.Net
6 | open System.Net.Http
7 | open Xunit
8 | open Microsoft.AspNetCore.Builder
9 | open Microsoft.AspNetCore.Hosting
10 | open Microsoft.AspNetCore.TestHost
11 | open Microsoft.Extensions.DependencyInjection
12 |
13 | // ---------------------------------
14 | // Helper functions (extend as you need)
15 | // ---------------------------------
16 |
17 | let createHost() =
18 | WebHostBuilder()
19 | .UseContentRoot(Directory.GetCurrentDirectory())
20 | .Configure(Action AppName._1.App.configureApp)
21 | .ConfigureServices(Action AppName._1.App.configureServices)
22 |
23 | let runTask task =
24 | task
25 | |> Async.AwaitTask
26 | |> Async.RunSynchronously
27 |
28 | let httpGet (path : string) (client : HttpClient) =
29 | path
30 | |> client.GetAsync
31 | |> runTask
32 |
33 | let isStatus (code : HttpStatusCode) (response : HttpResponseMessage) =
34 | Assert.Equal(code, response.StatusCode)
35 | response
36 |
37 | let ensureSuccess (response : HttpResponseMessage) =
38 | if not response.IsSuccessStatusCode
39 | then response.Content.ReadAsStringAsync() |> runTask |> failwithf "%A"
40 | else response
41 |
42 | let readText (response : HttpResponseMessage) =
43 | response.Content.ReadAsStringAsync()
44 | |> runTask
45 |
46 | let shouldEqual (expected : string) (actual : string) =
47 | Assert.Equal(expected, actual)
48 |
49 | let shouldContain (expected : string) (actual : string) =
50 | Assert.True(actual.Contains expected)
51 |
52 | // ---------------------------------
53 | // Tests
54 | // ---------------------------------
55 |
56 | []
57 | let ``Route / returns "Hello world, from Giraffe!"`` () =
58 | use server = new TestServer(createHost())
59 | use client = server.CreateClient()
60 |
61 | client
62 | |> httpGet "/"
63 | |> ensureSuccess
64 | |> readText
65 | |> shouldContain "Hello world, from Giraffe!"
66 |
67 | []
68 | let ``Route /hello/fooBar returns "Hello fooBar, from Giraffe!"`` () =
69 | use server = new TestServer(createHost())
70 | use client = server.CreateClient()
71 |
72 | client
73 | |> httpGet "/hello/fooBar"
74 | |> ensureSuccess
75 | |> readText
76 | |> shouldContain "Hello fooBar, from Giraffe!"
77 |
78 | []
79 | let ``Route which doesn't exist returns 404 Page not found`` () =
80 | use server = new TestServer(createHost())
81 | use client = server.CreateClient()
82 |
83 | client
84 | |> httpGet "/route/which/does/not/exist"
85 | |> isStatus HttpStatusCode.NotFound
86 | |> readText
87 | |> shouldEqual "Not Found"
--------------------------------------------------------------------------------
/src/content/Giraffe/tests/AppName.1.Tests/Tests.fs:
--------------------------------------------------------------------------------
1 | module Tests
2 |
3 | open System
4 | open System.IO
5 | open System.Net
6 | open System.Net.Http
7 | open Xunit
8 | open Microsoft.AspNetCore.Builder
9 | open Microsoft.AspNetCore.Hosting
10 | open Microsoft.AspNetCore.TestHost
11 | open Microsoft.Extensions.DependencyInjection
12 |
13 | // ---------------------------------
14 | // Helper functions (extend as you need)
15 | // ---------------------------------
16 |
17 | let createHost() =
18 | WebHostBuilder()
19 | .UseContentRoot(Directory.GetCurrentDirectory())
20 | .Configure(Action AppName._1.App.configureApp)
21 | .ConfigureServices(Action AppName._1.App.configureServices)
22 |
23 | let runTask task =
24 | task
25 | |> Async.AwaitTask
26 | |> Async.RunSynchronously
27 |
28 | let httpGet (path : string) (client : HttpClient) =
29 | path
30 | |> client.GetAsync
31 | |> runTask
32 |
33 | let isStatus (code : HttpStatusCode) (response : HttpResponseMessage) =
34 | Assert.Equal(code, response.StatusCode)
35 | response
36 |
37 | let ensureSuccess (response : HttpResponseMessage) =
38 | if not response.IsSuccessStatusCode
39 | then response.Content.ReadAsStringAsync() |> runTask |> failwithf "%A"
40 | else response
41 |
42 | let readText (response : HttpResponseMessage) =
43 | response.Content.ReadAsStringAsync()
44 | |> runTask
45 |
46 | let shouldEqual (expected : string) (actual : string) =
47 | Assert.Equal(expected, actual)
48 |
49 | let shouldContain (expected : string) (actual : string) =
50 | Assert.True(actual.Contains expected)
51 |
52 | // ---------------------------------
53 | // Tests
54 | // ---------------------------------
55 |
56 | []
57 | let ``Route / returns "Hello world, from Giraffe!"`` () =
58 | use server = new TestServer(createHost())
59 | use client = server.CreateClient()
60 |
61 | client
62 | |> httpGet "/"
63 | |> ensureSuccess
64 | |> readText
65 | |> shouldContain "Hello world, from Giraffe!"
66 |
67 | []
68 | let ``Route /hello/fooBar returns "Hello fooBar, from Giraffe!"`` () =
69 | use server = new TestServer(createHost())
70 | use client = server.CreateClient()
71 |
72 | client
73 | |> httpGet "/hello/fooBar"
74 | |> ensureSuccess
75 | |> readText
76 | |> shouldContain "Hello fooBar, from Giraffe!"
77 |
78 | []
79 | let ``Route which doesn't exist returns 404 Page not found`` () =
80 | use server = new TestServer(createHost())
81 | use client = server.CreateClient()
82 |
83 | client
84 | |> httpGet "/route/which/does/not/exist"
85 | |> isStatus HttpStatusCode.NotFound
86 | |> readText
87 | |> shouldEqual "Not Found"
--------------------------------------------------------------------------------
/src/content/DotLiquid/src/AppName.1/Program.fs:
--------------------------------------------------------------------------------
1 | module AppName._1.App
2 |
3 | open System
4 | open System.IO
5 | open Microsoft.AspNetCore.Builder
6 | open Microsoft.AspNetCore.Cors.Infrastructure
7 | open Microsoft.AspNetCore.Hosting
8 | open Microsoft.Extensions.Hosting
9 | open Microsoft.Extensions.Logging
10 | open Microsoft.Extensions.DependencyInjection
11 | open Giraffe
12 | open DotLiquid
13 | open AppName._1.Models
14 |
15 | // ---------------------------------
16 | // Web app
17 | // ---------------------------------
18 |
19 | let indexHandler (name : string) =
20 | let greetings = sprintf "Hello %s, from Giraffe!" name
21 | let model = { Text = greetings }
22 | dotLiquidHtmlTemplate "Views/Index.html" model
23 |
24 | let webApp =
25 | choose [
26 | GET >=>
27 | choose [
28 | route "/" >=> indexHandler "world"
29 | routef "/hello/%s" indexHandler
30 | ]
31 | setStatusCode 404 >=> text "Not Found" ]
32 |
33 | // ---------------------------------
34 | // Error handler
35 | // ---------------------------------
36 |
37 | let errorHandler (ex : Exception) (logger : ILogger) =
38 | logger.LogError(ex, "An unhandled exception has occurred while executing the request.")
39 | clearResponse >=> setStatusCode 500 >=> text ex.Message
40 |
41 | // ---------------------------------
42 | // Config and Main
43 | // ---------------------------------
44 |
45 | let configureCors (builder : CorsPolicyBuilder) =
46 | builder
47 | .WithOrigins(
48 | "http://localhost:5000",
49 | "https://localhost:5001")
50 | .AllowAnyMethod()
51 | .AllowAnyHeader()
52 | |> ignore
53 |
54 | let configureApp (app : IApplicationBuilder) =
55 | let env = app.ApplicationServices.GetService()
56 | (match env.IsDevelopment() with
57 | | true ->
58 | app.UseDeveloperExceptionPage()
59 | | false ->
60 | app .UseGiraffeErrorHandler(errorHandler)
61 | .UseHttpsRedirection())
62 | .UseCors(configureCors)
63 | .UseStaticFiles()
64 | .UseGiraffe(webApp)
65 |
66 | let configureServices (services : IServiceCollection) =
67 | services.AddCors() |> ignore
68 | services.AddGiraffe() |> ignore
69 |
70 | let configureLogging (builder : ILoggingBuilder) =
71 | builder.AddConsole()
72 | .AddDebug() |> ignore
73 |
74 | []
75 | let main args =
76 | let contentRoot = Directory.GetCurrentDirectory()
77 | let webRoot = Path.Combine(contentRoot, "WebRoot")
78 | Host.CreateDefaultBuilder(args)
79 | .ConfigureWebHostDefaults(
80 | fun webHostBuilder ->
81 | webHostBuilder
82 | .UseContentRoot(contentRoot)
83 | .UseWebRoot(webRoot)
84 | .Configure(Action configureApp)
85 | .ConfigureServices(configureServices)
86 | .ConfigureLogging(configureLogging)
87 | |> ignore)
88 | .Build()
89 | .Run()
90 | 0
--------------------------------------------------------------------------------
/src/content/Razor/src/AppName.1/Program.fs:
--------------------------------------------------------------------------------
1 | module AppName._1.App
2 |
3 | open System
4 | open System.IO
5 | open Microsoft.AspNetCore.Builder
6 | open Microsoft.AspNetCore.Cors.Infrastructure
7 | open Microsoft.AspNetCore.Hosting
8 | open Microsoft.Extensions.Hosting
9 | open Microsoft.Extensions.Logging
10 | open Microsoft.Extensions.DependencyInjection
11 | open Giraffe
12 | open Giraffe.Razor
13 | open AppName._1.Models
14 |
15 | // ---------------------------------
16 | // Web app
17 | // ---------------------------------
18 |
19 | let indexHandler (name : string) =
20 | let greetings = sprintf "Hello %s, from Giraffe!" name
21 | let model = { Text = greetings }
22 | razorHtmlView "Index" (Some model) None None
23 |
24 | let webApp =
25 | choose [
26 | GET >=>
27 | choose [
28 | route "/" >=> indexHandler "world"
29 | routef "/hello/%s" indexHandler
30 | ]
31 | setStatusCode 404 >=> text "Not Found" ]
32 |
33 | // ---------------------------------
34 | // Error handler
35 | // ---------------------------------
36 |
37 | let errorHandler (ex : Exception) (logger : ILogger) =
38 | logger.LogError(ex, "An unhandled exception has occurred while executing the request.")
39 | clearResponse >=> setStatusCode 500 >=> text ex.Message
40 |
41 | // ---------------------------------
42 | // Config and Main
43 | // ---------------------------------
44 |
45 | let configureCors (builder : CorsPolicyBuilder) =
46 | builder
47 | .WithOrigins(
48 | "http://localhost:5000",
49 | "https://localhost:5001")
50 | .AllowAnyMethod()
51 | .AllowAnyHeader()
52 | |> ignore
53 |
54 | let configureApp (app : IApplicationBuilder) =
55 | let env = app.ApplicationServices.GetService()
56 | (match env.IsDevelopment() with
57 | | true ->
58 | app.UseDeveloperExceptionPage()
59 | | false ->
60 | app .UseGiraffeErrorHandler(errorHandler)
61 | .UseHttpsRedirection())
62 | .UseCors(configureCors)
63 | .UseStaticFiles()
64 | .UseGiraffe(webApp)
65 |
66 | let configureServices (services : IServiceCollection) =
67 | let sp = services.BuildServiceProvider()
68 | let env = sp.GetService()
69 | let viewsFolderPath = Path.Combine(env.ContentRootPath, "Views")
70 | services.AddRazorEngine viewsFolderPath |> ignore
71 | services.AddCors() |> ignore
72 | services.AddGiraffe() |> ignore
73 |
74 | let configureLogging (builder : ILoggingBuilder) =
75 | builder.AddConsole()
76 | .AddDebug() |> ignore
77 |
78 | []
79 | let main args =
80 | let contentRoot = Directory.GetCurrentDirectory()
81 | let webRoot = Path.Combine(contentRoot, "WebRoot")
82 | Host.CreateDefaultBuilder(args)
83 | .ConfigureWebHostDefaults(
84 | fun webHostBuilder ->
85 | webHostBuilder
86 | .UseContentRoot(contentRoot)
87 | .UseWebRoot(webRoot)
88 | .Configure(Action configureApp)
89 | .ConfigureServices(configureServices)
90 | .ConfigureLogging(configureLogging)
91 | |> ignore)
92 | .Build()
93 | .Run()
94 | 0
--------------------------------------------------------------------------------
/src/content/Razor/paket.lock:
--------------------------------------------------------------------------------
1 | STORAGE: NONE
2 | RESTRICTION: == net8.0
3 | NUGET
4 | remote: https://api.nuget.org/v3/index.json
5 | FSharp.Core (8.0.200)
6 | Giraffe (6.0)
7 | FSharp.Core (>= 6.0.1)
8 | Giraffe.ViewEngine (>= 1.3)
9 | Microsoft.IO.RecyclableMemoryStream (>= 2.2)
10 | Newtonsoft.Json (>= 13.0.1)
11 | System.Text.Json (>= 6.0.2)
12 | Utf8Json (>= 1.3.7)
13 | Giraffe.Razor (5.1.0-rc-2)
14 | FSharp.Core (>= 5.0)
15 | Giraffe (>= 5.0.0-rc-6)
16 | Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (>= 5.0)
17 | Ply (>= 0.3.1)
18 | Giraffe.ViewEngine (1.4)
19 | FSharp.Core (>= 5.0)
20 | Microsoft.AspNetCore.Mvc.Razor.Extensions (6.0.29)
21 | Microsoft.AspNetCore.Razor.Language (>= 6.0.29)
22 | Microsoft.CodeAnalysis.Razor (>= 6.0.29)
23 | Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (7.0.18)
24 | Microsoft.AspNetCore.Mvc.Razor.Extensions (>= 6.0)
25 | Microsoft.CodeAnalysis.Razor (>= 6.0)
26 | Microsoft.Extensions.DependencyModel (>= 7.0)
27 | Microsoft.AspNetCore.Razor.Language (6.0.29)
28 | Microsoft.AspNetCore.TestHost (8.0.4)
29 | System.IO.Pipelines (>= 8.0)
30 | Microsoft.CodeAnalysis.Analyzers (3.3.4)
31 | Microsoft.CodeAnalysis.Common (4.9.2)
32 | Microsoft.CodeAnalysis.Analyzers (>= 3.3.4)
33 | System.Collections.Immutable (>= 8.0)
34 | System.Reflection.Metadata (>= 8.0)
35 | System.Runtime.CompilerServices.Unsafe (>= 6.0)
36 | Microsoft.CodeAnalysis.CSharp (4.9.2)
37 | Microsoft.CodeAnalysis.Common (4.9.2)
38 | Microsoft.CodeAnalysis.Razor (6.0.29)
39 | Microsoft.AspNetCore.Razor.Language (>= 6.0.29)
40 | Microsoft.CodeAnalysis.Common (>= 4.0)
41 | Microsoft.CodeAnalysis.CSharp (>= 4.0)
42 | Microsoft.CodeCoverage (17.9)
43 | Microsoft.Extensions.DependencyModel (8.0)
44 | System.Text.Encodings.Web (>= 8.0)
45 | System.Text.Json (>= 8.0)
46 | Microsoft.IO.RecyclableMemoryStream (3.0)
47 | Microsoft.NET.Test.Sdk (17.9)
48 | Microsoft.CodeCoverage (>= 17.9)
49 | Microsoft.TestPlatform.TestHost (>= 17.9)
50 | Microsoft.TestPlatform.ObjectModel (17.9)
51 | System.Reflection.Metadata (>= 1.6)
52 | Microsoft.TestPlatform.TestHost (17.9)
53 | Microsoft.TestPlatform.ObjectModel (>= 17.9)
54 | Newtonsoft.Json (>= 13.0.1)
55 | Newtonsoft.Json (13.0.3)
56 | Ply (0.3.1)
57 | FSharp.Core (>= 4.6.2)
58 | System.Threading.Tasks.Extensions (>= 4.5.4)
59 | System.Collections.Immutable (8.0)
60 | System.IO.Pipelines (8.0)
61 | System.Reflection.Emit (4.7)
62 | System.Reflection.Emit.Lightweight (4.7)
63 | System.Reflection.Metadata (8.0)
64 | System.Collections.Immutable (>= 8.0)
65 | System.Runtime.CompilerServices.Unsafe (6.0)
66 | System.Text.Encodings.Web (8.0)
67 | System.Text.Json (8.0.3)
68 | System.Text.Encodings.Web (>= 8.0)
69 | System.Threading.Tasks.Extensions (4.5.4)
70 | System.ValueTuple (4.5)
71 | Utf8Json (1.3.7)
72 | System.Reflection.Emit (>= 4.3)
73 | System.Reflection.Emit.Lightweight (>= 4.3)
74 | System.Threading.Tasks.Extensions (>= 4.4)
75 | System.ValueTuple (>= 4.4)
76 | xunit (2.8)
77 | xunit.analyzers (>= 1.13)
78 | xunit.assert (>= 2.8)
79 | xunit.core (2.8)
80 | xunit.abstractions (2.0.3)
81 | xunit.analyzers (1.13)
82 | xunit.assert (2.8)
83 | xunit.core (2.8)
84 | xunit.extensibility.core (2.8)
85 | xunit.extensibility.execution (2.8)
86 | xunit.extensibility.core (2.8)
87 | xunit.abstractions (>= 2.0.3)
88 | xunit.extensibility.execution (2.8)
89 | xunit.extensibility.core (2.8)
90 | xunit.runner.visualstudio (2.8)
91 |
--------------------------------------------------------------------------------
/src/content/_Default/AppName.1.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26124.0
5 | MinimumVisualStudioVersion = 15.0.26124.0
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B8CB57F5-C87C-48A1-A3DC-BF5BBA95EB25}"
7 | EndProject
8 | #if (!ExcludeTests)
9 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{E6D01694-CB7C-4226-99EE-103B75B923FB}"
10 | EndProject
11 | #endif
12 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "AppName.1", "src\AppName.1\AppName.1.fsproj", "{C56E75B2-5671-46E1-8594-6529135E7082}"
13 | EndProject
14 | #if (!ExcludeTests)
15 | Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "AppName.1.Tests", "tests\AppName.1.Tests\AppName.1.Tests.fsproj", "{DB284F96-3FC7-49A0-8667-18732B962F3E}"
16 | EndProject
17 | #endif
18 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_root", "_root", "{625E3CAC-600B-450D-BF54-E3059450591A}"
19 | ProjectSection(SolutionItems) = preProject
20 | build.bat = build.bat
21 | build.sh = build.sh
22 | #if (Paket)
23 | paket.dependencies = paket.dependencies
24 | paket.lock = paket.lock
25 | #endif
26 | README.md = README.md
27 | EndProjectSection
28 | EndProject
29 | Global
30 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
31 | Debug|Any CPU = Debug|Any CPU
32 | Debug|x64 = Debug|x64
33 | Debug|x86 = Debug|x86
34 | Release|Any CPU = Release|Any CPU
35 | Release|x64 = Release|x64
36 | Release|x86 = Release|x86
37 | EndGlobalSection
38 | GlobalSection(SolutionProperties) = preSolution
39 | HideSolutionNode = FALSE
40 | EndGlobalSection
41 | GlobalSection(NestedProjects) = preSolution
42 | {C56E75B2-5671-46E1-8594-6529135E7082} = {B8CB57F5-C87C-48A1-A3DC-BF5BBA95EB25}
43 | #if (!ExcludeTests)
44 | {DB284F96-3FC7-49A0-8667-18732B962F3E} = {E6D01694-CB7C-4226-99EE-103B75B923FB}
45 | #endif
46 | EndGlobalSection
47 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
48 | {C56E75B2-5671-46E1-8594-6529135E7082}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
49 | {C56E75B2-5671-46E1-8594-6529135E7082}.Debug|Any CPU.Build.0 = Debug|Any CPU
50 | {C56E75B2-5671-46E1-8594-6529135E7082}.Debug|x64.ActiveCfg = Debug|Any CPU
51 | {C56E75B2-5671-46E1-8594-6529135E7082}.Debug|x64.Build.0 = Debug|Any CPU
52 | {C56E75B2-5671-46E1-8594-6529135E7082}.Debug|x86.ActiveCfg = Debug|Any CPU
53 | {C56E75B2-5671-46E1-8594-6529135E7082}.Debug|x86.Build.0 = Debug|Any CPU
54 | {C56E75B2-5671-46E1-8594-6529135E7082}.Release|Any CPU.ActiveCfg = Release|Any CPU
55 | {C56E75B2-5671-46E1-8594-6529135E7082}.Release|Any CPU.Build.0 = Release|Any CPU
56 | {C56E75B2-5671-46E1-8594-6529135E7082}.Release|x64.ActiveCfg = Release|Any CPU
57 | {C56E75B2-5671-46E1-8594-6529135E7082}.Release|x64.Build.0 = Release|Any CPU
58 | {C56E75B2-5671-46E1-8594-6529135E7082}.Release|x86.ActiveCfg = Release|Any CPU
59 | {C56E75B2-5671-46E1-8594-6529135E7082}.Release|x86.Build.0 = Release|Any CPU
60 | #if (!ExcludeTests)
61 | {DB284F96-3FC7-49A0-8667-18732B962F3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
62 | {DB284F96-3FC7-49A0-8667-18732B962F3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
63 | {DB284F96-3FC7-49A0-8667-18732B962F3E}.Debug|x64.ActiveCfg = Debug|Any CPU
64 | {DB284F96-3FC7-49A0-8667-18732B962F3E}.Debug|x64.Build.0 = Debug|Any CPU
65 | {DB284F96-3FC7-49A0-8667-18732B962F3E}.Debug|x86.ActiveCfg = Debug|Any CPU
66 | {DB284F96-3FC7-49A0-8667-18732B962F3E}.Debug|x86.Build.0 = Debug|Any CPU
67 | {DB284F96-3FC7-49A0-8667-18732B962F3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
68 | {DB284F96-3FC7-49A0-8667-18732B962F3E}.Release|Any CPU.Build.0 = Release|Any CPU
69 | {DB284F96-3FC7-49A0-8667-18732B962F3E}.Release|x64.ActiveCfg = Release|Any CPU
70 | {DB284F96-3FC7-49A0-8667-18732B962F3E}.Release|x64.Build.0 = Release|Any CPU
71 | {DB284F96-3FC7-49A0-8667-18732B962F3E}.Release|x86.ActiveCfg = Release|Any CPU
72 | {DB284F96-3FC7-49A0-8667-18732B962F3E}.Release|x86.Build.0 = Release|Any CPU
73 | #endif
74 | EndGlobalSection
75 | EndGlobal
76 |
--------------------------------------------------------------------------------
/src/content/Giraffe/src/AppName.1/Program.fs:
--------------------------------------------------------------------------------
1 | module AppName._1.App
2 |
3 | open System
4 | open System.IO
5 | open Microsoft.AspNetCore.Builder
6 | open Microsoft.AspNetCore.Cors.Infrastructure
7 | open Microsoft.AspNetCore.Hosting
8 | open Microsoft.Extensions.Hosting
9 | open Microsoft.Extensions.Logging
10 | open Microsoft.Extensions.DependencyInjection
11 | open Giraffe
12 |
13 | // ---------------------------------
14 | // Models
15 | // ---------------------------------
16 |
17 | type Message =
18 | {
19 | Text : string
20 | }
21 |
22 | // ---------------------------------
23 | // Views
24 | // ---------------------------------
25 |
26 | module Views =
27 | open Giraffe.ViewEngine
28 |
29 | let layout (content: XmlNode list) =
30 | html [] [
31 | head [] [
32 | title [] [ encodedText "AppName._1" ]
33 | link [ _rel "stylesheet"
34 | _type "text/css"
35 | _href "/main.css" ]
36 | ]
37 | body [] content
38 | ]
39 |
40 | let partial () =
41 | h1 [] [ encodedText "AppName._1" ]
42 |
43 | let index (model : Message) =
44 | [
45 | partial()
46 | p [] [ encodedText model.Text ]
47 | ] |> layout
48 |
49 | // ---------------------------------
50 | // Web app
51 | // ---------------------------------
52 |
53 | let indexHandler (name : string) =
54 | let greetings = sprintf "Hello %s, from Giraffe!" name
55 | let model = { Text = greetings }
56 | let view = Views.index model
57 | htmlView view
58 |
59 | let webApp =
60 | choose [
61 | GET >=>
62 | choose [
63 | route "/" >=> indexHandler "world"
64 | routef "/hello/%s" indexHandler
65 | ]
66 | setStatusCode 404 >=> text "Not Found" ]
67 |
68 | // ---------------------------------
69 | // Error handler
70 | // ---------------------------------
71 |
72 | let errorHandler (ex : Exception) (logger : ILogger) =
73 | logger.LogError(ex, "An unhandled exception has occurred while executing the request.")
74 | clearResponse >=> setStatusCode 500 >=> text ex.Message
75 |
76 | // ---------------------------------
77 | // Config and Main
78 | // ---------------------------------
79 |
80 | let configureCors (builder : CorsPolicyBuilder) =
81 | builder
82 | .WithOrigins(
83 | "http://localhost:5000",
84 | "https://localhost:5001")
85 | .AllowAnyMethod()
86 | .AllowAnyHeader()
87 | |> ignore
88 |
89 | let configureApp (app : IApplicationBuilder) =
90 | let env = app.ApplicationServices.GetService()
91 | (match env.IsDevelopment() with
92 | | true ->
93 | app.UseDeveloperExceptionPage()
94 | | false ->
95 | app .UseGiraffeErrorHandler(errorHandler)
96 | .UseHttpsRedirection())
97 | .UseCors(configureCors)
98 | .UseStaticFiles()
99 | .UseGiraffe(webApp)
100 |
101 | let configureServices (services : IServiceCollection) =
102 | services.AddCors() |> ignore
103 | services.AddGiraffe() |> ignore
104 |
105 | let configureLogging (builder : ILoggingBuilder) =
106 | builder.AddConsole()
107 | .AddDebug() |> ignore
108 |
109 | []
110 | let main args =
111 | let contentRoot = Directory.GetCurrentDirectory()
112 | let webRoot = Path.Combine(contentRoot, "WebRoot")
113 | Host.CreateDefaultBuilder(args)
114 | .ConfigureWebHostDefaults(
115 | fun webHostBuilder ->
116 | webHostBuilder
117 | .UseContentRoot(contentRoot)
118 | .UseWebRoot(webRoot)
119 | .Configure(Action configureApp)
120 | .ConfigureServices(configureServices)
121 | .ConfigureLogging(configureLogging)
122 | |> ignore)
123 | .Build()
124 | .Run()
125 | 0
--------------------------------------------------------------------------------
/RELEASE_NOTES.md:
--------------------------------------------------------------------------------
1 | Release Notes
2 | =============
3 |
4 | ## 1.5.0
5 |
6 | - Updated templates to .NET 8 and latest Giraffe
7 |
8 |
9 | ## 1.4.0
10 |
11 | - Updated templates to .NET 7 and latest Giraffe
12 |
13 | ## 1.3.0
14 |
15 | - Removed log filter
16 | - Improved default CORS policy
17 | - HTTPS redirection not during Development
18 | - Updated to Giraffe 5.0.0-rc-6 with Ply
19 |
20 | ## 1.2.0
21 |
22 | - Updated all templates to .NET 5 and Giraffe 5.0.0-rc-1
23 |
24 | ## 1.1.0
25 |
26 | - Changed all templates to make use of the passed in `args` when composing the ASP.NET Core web host.
27 |
28 | ## 1.0.0
29 |
30 | - Updated Giraffe to version `4.1.x`
31 | - Set `netcoreapp3.1` as default target framework
32 | - Upgraded all templates to use .NET Core's generic host
33 | - Updated Paket to use `dotnet tools` distribution
34 | - Fixed cyclic dependency issue when `dotnet new giraffe` is run from within a folder named `Giraffe`
35 | - Added `paket.references` files to `*.fsproj` files when `-UsePaket` is enabled
36 | - Creating a `.sln` file referencing the created projects as part of the template
37 | - Fixed bug where hyphens in project name caused builds to fail (e.g. `dotnet new giraffe -n foo-bar`)
38 | - Renamed `IncludeTests` flag to `ExcludeTests` and inverted logic
39 | - Renamed `UsePaket` flag to `Paket` so that the default abbreviation is `-P` instead of `-U`
40 | - Added new `Solution` flag, which determines if a complete solution with `src` and (optional) `tests` folder should get created or not. Default value is set to `false`
41 | - Fixed build some warnings
42 |
43 | For more information please visit the [updated documentation](README.md) regarding the latest template options of the Giraffe template.
44 |
45 | ## 0.20.0
46 |
47 | - Added shebang and fixed shellcheck warnings
48 | - Updated Giraffe to version 3.4.x
49 | - Updated TestHost to version 2.1.x for test projects
50 |
51 | ## 0.19.0
52 |
53 | - Updated Giraffe to version 3.2.x
54 | - Updated Giraffe.Razor to version 2.0.x
55 | - Added TaskBuilder.fs as dependency to all templates
56 |
57 | ## 0.18.0
58 |
59 | - Updated all templates to latest Giraffe version
60 | - Updates all templates to .NET Core 2.1 apps
61 | - Updated paket to latest version
62 | - Fixed minor bugs with the generation of the `None` view engine template
63 | - Fixed line ending issue in *.sh files
64 | - Added post action to set read permissions to the build.sh file
65 |
66 | ## 0.17.0
67 |
68 | Updated paket.exe to latest Paket release (fixes #12).
69 |
70 | ## 0.16.0
71 |
72 | Updated all templates to use the latest `Giraffe 1.1.*` release.
73 |
74 | ## 0.15.0
75 |
76 | Updated all templates to use the latest `Giraffe 1.0.0` release.
77 |
78 | ## 0.14.0
79 |
80 | #### New features
81 |
82 | - Added the ASP.NET Core default developer exception page when environment is development.
83 |
84 | ## 0.13.0
85 |
86 | #### New features
87 |
88 | - Added a default `web.config` file to all templates to support Azure deployments.
89 |
90 | ## 0.12.0
91 |
92 | #### New features
93 |
94 | - Added `none` as a new option to the `--ViewEngine` parameter, which will create a Giraffe web application without any view engine (Web API only).
95 | - Added a new parameter called `--UsePaket` which will use Paket instead of NuGet as the package manager for the Giraffe web application.
96 |
97 | #### Enhancements
98 |
99 | - Updated the default Giraffe template to the latest version of Giraffe and made use of the new HTML attributes from the `GiraffeViewEngine`.
100 |
101 | ## 0.11.0
102 |
103 | #### New features
104 |
105 | Added an additional parameter called `IncludeTests` which can be added to auto generate an accompanying test project to your Giraffe web application.
106 |
107 | #### Examples:
108 |
109 | Default Giraffe web application with the `GiraffeViewEngine` and no tests:
110 |
111 | ```
112 | dotnet new giraffe
113 | ```
114 |
115 | Default Giraffe web application with the `GiraffeViewEngine` and a default test project:
116 |
117 | ```
118 | dotnet new giraffe --IncludeTests
119 | ```
120 |
121 | Giraffe web application with the Razor view engine and a default test project:
122 |
123 | ```
124 | dotnet new giraffe --ViewEngine razor --IncludeTests
125 | ```
126 |
127 | ## 0.10.0
128 |
129 | #### New features
130 |
131 | The Giraffe template supports three different view engines now:
132 |
133 | - `giraffe` (default)
134 | - `razor`
135 | - `dotliquid`
136 |
137 | You can optionally specify the `--ViewEngine` (or short `-V`) parameter and select one of the supported options when creating a new Giraffe project:
138 |
139 | ```
140 | dotnet new giraffe --ViewEngine razor
141 | ```
142 |
143 | When you run `dotnet new giraffe` it will automatically create a new Giraffe project with the default `GiraffeViewEngine` engine.
144 |
145 | ## 0.9.0 and before
146 |
147 | Previous releases of this library were documented in [Giraffe's release notes](https://github.com/giraffe-fsharp/Giraffe/blob/master/RELEASE_NOTES.md).
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # MSTest test Results
33 | [Tt]est[Rr]esult*/
34 | [Bb]uild[Ll]og.*
35 |
36 | # NUNIT
37 | *.VisualState.xml
38 | TestResult.xml
39 |
40 | # Build Results of an ATL Project
41 | [Dd]ebugPS/
42 | [Rr]eleasePS/
43 | dlldata.c
44 |
45 | # .NET Core
46 | project.lock.json
47 | project.fragment.lock.json
48 | artifacts/
49 | **/Properties/launchSettings.json
50 |
51 | *_i.c
52 | *_p.c
53 | *_i.h
54 | *.ilk
55 | *.meta
56 | *.obj
57 | *.pch
58 | *.pdb
59 | *.pgc
60 | *.pgd
61 | *.rsp
62 | *.sbr
63 | *.tlb
64 | *.tli
65 | *.tlh
66 | *.tmp
67 | *.tmp_proj
68 | *.log
69 | *.vspscc
70 | *.vssscc
71 | .builds
72 | *.pidb
73 | *.svclog
74 | *.scc
75 |
76 | # Chutzpah Test files
77 | _Chutzpah*
78 |
79 | # Visual C++ cache files
80 | ipch/
81 | *.aps
82 | *.ncb
83 | *.opendb
84 | *.opensdf
85 | *.sdf
86 | *.cachefile
87 | *.VC.db
88 | *.VC.VC.opendb
89 |
90 | # Visual Studio profiler
91 | *.psess
92 | *.vsp
93 | *.vspx
94 | *.sap
95 |
96 | # TFS 2012 Local Workspace
97 | $tf/
98 |
99 | # Guidance Automation Toolkit
100 | *.gpState
101 |
102 | # ReSharper is a .NET coding add-in
103 | _ReSharper*/
104 | *.[Rr]e[Ss]harper
105 | *.DotSettings.user
106 |
107 | # JustCode is a .NET coding add-in
108 | .JustCode
109 |
110 | # TeamCity is a build add-in
111 | _TeamCity*
112 |
113 | # DotCover is a Code Coverage Tool
114 | *.dotCover
115 |
116 | # Visual Studio code coverage results
117 | *.coverage
118 | *.coveragexml
119 |
120 | # NCrunch
121 | _NCrunch_*
122 | .*crunch*.local.xml
123 | nCrunchTemp_*
124 |
125 | # MightyMoose
126 | *.mm.*
127 | AutoTest.Net/
128 |
129 | # Web workbench (sass)
130 | .sass-cache/
131 |
132 | # Installshield output folder
133 | [Ee]xpress/
134 |
135 | # DocProject is a documentation generator add-in
136 | DocProject/buildhelp/
137 | DocProject/Help/*.HxT
138 | DocProject/Help/*.HxC
139 | DocProject/Help/*.hhc
140 | DocProject/Help/*.hhk
141 | DocProject/Help/*.hhp
142 | DocProject/Help/Html2
143 | DocProject/Help/html
144 |
145 | # Click-Once directory
146 | publish/
147 |
148 | # Publish Web Output
149 | *.[Pp]ublish.xml
150 | *.azurePubxml
151 | # TODO: Comment the next line if you want to checkin your web deploy settings
152 | # but database connection strings (with potential passwords) will be unencrypted
153 | *.pubxml
154 | *.publishproj
155 |
156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
157 | # checkin your Azure Web App publish settings, but sensitive information contained
158 | # in these scripts will be unencrypted
159 | PublishScripts/
160 |
161 | # NuGet Packages
162 | *.nupkg
163 | # The packages folder can be ignored because of Package Restore
164 | **/packages/*
165 | # except build/, which is used as an MSBuild target.
166 | !**/packages/build/
167 | # Uncomment if necessary however generally it will be regenerated when needed
168 | #!**/packages/repositories.config
169 | # NuGet v3's project.json files produces more ignorable files
170 | *.nuget.props
171 | *.nuget.targets
172 |
173 | # Microsoft Azure Build Output
174 | csx/
175 | *.build.csdef
176 |
177 | # Microsoft Azure Emulator
178 | ecf/
179 | rcf/
180 |
181 | # Windows Store app package directories and files
182 | AppPackages/
183 | BundleArtifacts/
184 | Package.StoreAssociation.xml
185 | _pkginfo.txt
186 |
187 | # Visual Studio cache files
188 | # files ending in .cache can be ignored
189 | *.[Cc]ache
190 | # but keep track of directories ending in .cache
191 | !*.[Cc]ache/
192 |
193 | # Others
194 | ClientBin/
195 | ~$*
196 | *~
197 | *.dbmdl
198 | *.dbproj.schemaview
199 | *.jfm
200 | *.pfx
201 | *.publishsettings
202 | orleans.codegen.cs
203 |
204 | # Since there are multiple workflows, uncomment next line to ignore bower_components
205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
206 | #bower_components/
207 |
208 | # RIA/Silverlight projects
209 | Generated_Code/
210 |
211 | # Backup & report files from converting an old project file
212 | # to a newer Visual Studio version. Backup files are not needed,
213 | # because we have git ;-)
214 | _UpgradeReport_Files/
215 | Backup*/
216 | UpgradeLog*.XML
217 | UpgradeLog*.htm
218 |
219 | # SQL Server files
220 | *.mdf
221 | *.ldf
222 | *.ndf
223 |
224 | # Business Intelligence projects
225 | *.rdl.data
226 | *.bim.layout
227 | *.bim_*.settings
228 |
229 | # Microsoft Fakes
230 | FakesAssemblies/
231 |
232 | # GhostDoc plugin setting file
233 | *.GhostDoc.xml
234 |
235 | # Node.js Tools for Visual Studio
236 | .ntvs_analysis.dat
237 | node_modules/
238 |
239 | # Typescript v1 declaration files
240 | typings/
241 |
242 | # Visual Studio 6 build log
243 | *.plg
244 |
245 | # Visual Studio 6 workspace options file
246 | *.opt
247 |
248 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
249 | *.vbw
250 |
251 | # Visual Studio LightSwitch build output
252 | **/*.HTMLClient/GeneratedArtifacts
253 | **/*.DesktopClient/GeneratedArtifacts
254 | **/*.DesktopClient/ModelManifest.xml
255 | **/*.Server/GeneratedArtifacts
256 | **/*.Server/ModelManifest.xml
257 | _Pvt_Extensions
258 |
259 | # Paket dependency manager
260 | .paket/paket.exe
261 | paket-files/
262 |
263 | # FAKE - F# Make
264 | .fake/
265 |
266 | # JetBrains Rider
267 | .idea/
268 | *.sln.iml
269 |
270 | # Ionide VS Code
271 | .ionide/
272 |
273 | # CodeRush
274 | .cr/
275 |
276 | # Python Tools for Visual Studio (PTVS)
277 | __pycache__/
278 | *.pyc
279 |
280 | # Cake - Uncomment if you are using it
281 | # tools/**
282 | # !tools/packages.config
283 |
284 | # Telerik's JustMock configuration file
285 | *.jmconfig
286 |
287 | # BizTalk build output
288 | *.btp.cs
289 | *.btm.cs
290 | *.odx.cs
291 | *.xsd.cs
292 |
293 | #macOS
294 |
295 | .DS_Store
296 |
297 | #custom
298 |
299 | .temp
300 |
301 | #Ionide
302 | .ionide
--------------------------------------------------------------------------------
/src/content/.template.config/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "identity": "Giraffe.Template",
3 | "shortName": "giraffe",
4 | "name": "Giraffe",
5 | "author": "Dustin Moris Gorski, David Sinclair and contributors",
6 | "classifications": [ "Web", "Giraffe", "ASP.NET" ],
7 | "tags": {
8 | "language": "F#"
9 | },
10 | "sourceName": "AppName.1",
11 | "symbols": {
12 | "ViewEngine": {
13 | "type": "parameter",
14 | "dataType": "choice",
15 | "defaultValue": "giraffe",
16 | "choices": [
17 | {
18 | "choice": "giraffe",
19 | "description": "Giraffe.ViewEngine views"
20 | },
21 | {
22 | "choice": "razor",
23 | "description": "MVC Razor views"
24 | },
25 | {
26 | "choice": "dotliquid",
27 | "description": "DotLiquid template views"
28 | },
29 | {
30 | "choice": "none",
31 | "description": "No template engine (API only)"
32 | }
33 | ]
34 | },
35 | "Solution": {
36 | "type": "parameter",
37 | "dataType": "bool",
38 | "defaultValue": "false"
39 | },
40 | "ExcludeTests": {
41 | "type": "parameter",
42 | "dataType": "bool",
43 | "defaultValue": "false"
44 | },
45 | "Paket": {
46 | "type": "parameter",
47 | "dataType": "bool",
48 | "defaultValue": "false"
49 | }
50 | },
51 | "sources": [
52 | {
53 | "source": "./Giraffe/src/AppName.1/",
54 | "target": "./",
55 | "condition": "(ViewEngine == \"giraffe\") && (!Solution)",
56 | "modifiers": [
57 | {
58 | "condition": "(!Paket)",
59 | "exclude": [ "**/paket.*" ]
60 | }
61 | ]
62 | },
63 | {
64 | "source": "./Giraffe/",
65 | "target": "./",
66 | "condition": "(ViewEngine == \"giraffe\") && (!Solution) && (Paket)",
67 | "modifiers": [
68 | {
69 | "condition": "(!Solution)",
70 | "exclude": [ "tests/**/*", "src/**/*" ]
71 | }
72 | ]
73 | },
74 | {
75 | "source": "./Giraffe/",
76 | "target": "./",
77 | "condition": "(ViewEngine == \"giraffe\") && (Solution)",
78 | "modifiers": [
79 | {
80 | "condition": "(ExcludeTests)",
81 | "exclude": [ "**/AppName.1.Tests/**/*" ]
82 | },
83 | {
84 | "condition": "(!Paket)",
85 | "exclude": [ "**/paket.*" ]
86 | }
87 | ]
88 | },
89 | {
90 | "source": "./Razor/src/AppName.1/",
91 | "target": "./",
92 | "condition": "(ViewEngine == \"razor\") && (!Solution)",
93 | "modifiers": [
94 | {
95 | "condition": "(!Paket)",
96 | "exclude": [ "**/paket.*" ]
97 | }
98 | ]
99 | },
100 | {
101 | "source": "./Razor/",
102 | "target": "./",
103 | "condition": "(ViewEngine == \"razor\") && (!Solution) && (Paket)",
104 | "modifiers": [
105 | {
106 | "condition": "(!Solution)",
107 | "exclude": [ "tests/**/*", "src/**/*" ]
108 | }
109 | ]
110 | },
111 | {
112 | "source": "./Razor/",
113 | "target": "./",
114 | "condition": "(ViewEngine == \"razor\") && (Solution)",
115 | "modifiers": [
116 | {
117 | "condition": "(ExcludeTests)",
118 | "exclude": [ "**/AppName.1.Tests/**/*" ]
119 | },
120 | {
121 | "condition": "(!Paket)",
122 | "exclude": [ "**/paket.*" ]
123 | }
124 | ]
125 | },
126 | {
127 | "source": "./DotLiquid/src/AppName.1/",
128 | "target": "./",
129 | "condition": "(ViewEngine == \"dotliquid\") && (!Solution)",
130 | "modifiers": [
131 | {
132 | "condition": "(!Paket)",
133 | "exclude": [ "**/paket.*" ]
134 | }
135 | ]
136 | },
137 | {
138 | "source": "./DotLiquid/",
139 | "target": "./",
140 | "condition": "(ViewEngine == \"dotliquid\") && (!Solution) && (Paket)",
141 | "modifiers": [
142 | {
143 | "condition": "(!Solution)",
144 | "exclude": [ "tests/**/*", "src/**/*" ]
145 | }
146 | ]
147 | },
148 | {
149 | "source": "./DotLiquid/",
150 | "target": "./",
151 | "condition": "(ViewEngine == \"dotliquid\") && (Solution)",
152 | "modifiers": [
153 | {
154 | "condition": "(ExcludeTests)",
155 | "exclude": [ "**/AppName.1.Tests/**/*" ]
156 | },
157 | {
158 | "condition": "(!Paket)",
159 | "exclude": [ "**/paket.*" ]
160 | }
161 | ]
162 | },
163 | {
164 | "source": "./None/src/AppName.1/",
165 | "target": "./",
166 | "condition": "(ViewEngine == \"none\") && (!Solution)",
167 | "modifiers": [
168 | {
169 | "condition": "(!Paket)",
170 | "exclude": [ "**/paket.*" ]
171 | }
172 | ]
173 | },
174 | {
175 | "source": "./None/",
176 | "target": "./",
177 | "condition": "(ViewEngine == \"none\") && (!Solution) && (Paket)",
178 | "modifiers": [
179 | {
180 | "condition": "(!Solution)",
181 | "exclude": [ "tests/**/*", "src/**/*" ]
182 | }
183 | ]
184 | },
185 | {
186 | "source": "./None/",
187 | "target": "./",
188 | "condition": "(ViewEngine == \"none\") && (Solution)",
189 | "modifiers": [
190 | {
191 | "condition": "(ExcludeTests)",
192 | "exclude": [ "**/AppName.1.Tests/**/*" ]
193 | },
194 | {
195 | "condition": "(!Paket)",
196 | "exclude": [ "**/paket.*" ]
197 | }
198 | ]
199 | },
200 | {
201 | "source": "./Paket/",
202 | "target": "./",
203 | "condition": "(Paket)",
204 | "modifiers": [
205 | {
206 | "condition": "(ExcludeTests) || (!Solution)",
207 | "exclude": [ "**/AppName.1.Tests/**/*" ]
208 | }
209 | ]
210 | },
211 | {
212 | "source": "./_Default/",
213 | "target": "./",
214 | "condition": "(Solution)"
215 | }
216 | ],
217 | "postActions": [{
218 | "condition": "(OS != \"Windows_NT\") && (Solution)",
219 | "description": "Make scripts executable",
220 | "manualInstructions": [{
221 | "text": "Run 'chmod +x *.sh'"
222 | }],
223 | "actionId": "cb9a6cf3-4f5c-4860-b9d2-03a574959774",
224 | "args": {
225 | "+x": "*.sh"
226 | },
227 | "continueOnError": true
228 | }]
229 | }
--------------------------------------------------------------------------------
/.psscripts/build-functions.ps1:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------
2 | # Generic functions
3 | # ----------------------------------------------
4 |
5 | function Test-IsWindows
6 | {
7 | <#
8 | .DESCRIPTION
9 | Checks to see whether the current environment is Windows or not.
10 |
11 | .EXAMPLE
12 | if (Test-IsWindows) { Write-Host "Hello Windows" }
13 | #>
14 |
15 | [environment]::OSVersion.Platform -ne "Unix"
16 | }
17 |
18 | function Get-UbuntuVersion
19 | {
20 | <#
21 | .DESCRIPTION
22 | Gets the Ubuntu version.
23 |
24 | .EXAMPLE
25 | $ubuntuVersion = Get-UbuntuVersion
26 | #>
27 |
28 | $version = Invoke-Cmd "lsb_release -r -s" -Silent
29 | return $version
30 | }
31 |
32 | function Invoke-UnsafeCmd (
33 | [string] $Cmd,
34 | [switch] $Silent)
35 | {
36 | <#
37 | .DESCRIPTION
38 | Runs a shell or bash command, but doesn't throw an error if the command didn't exit with 0.
39 |
40 | .PARAMETER cmd
41 | The command to be executed.
42 |
43 | .EXAMPLE
44 | Invoke-Cmd -Cmd "dotnet new classlib"
45 |
46 | .NOTES
47 | Use this PowerShell command to execute any CLI commands which might not exit with 0 on a success.
48 | #>
49 |
50 | if (!($Silent.IsPresent)) { Write-Host $cmd -ForegroundColor DarkCyan }
51 | if (Test-IsWindows) { $cmd = "cmd.exe /C $cmd" }
52 | Invoke-Expression -Command $cmd
53 | }
54 |
55 | function Invoke-Cmd (
56 | [string] $Cmd,
57 | [switch] $Silent)
58 | {
59 | <#
60 | .DESCRIPTION
61 | Runs a shell or bash command and throws an error if the command didn't exit with 0.
62 |
63 | .PARAMETER cmd
64 | The command to be executed.
65 |
66 | .EXAMPLE
67 | Invoke-Cmd -Cmd "dotnet new classlib"
68 |
69 | .NOTES
70 | Use this PowerShell command to execute any dotnet CLI commands in order to ensure that they behave the same way in the case of an error across different environments (Windows, OSX and Linux).
71 | #>
72 |
73 | if ($Silent.IsPresent) { Invoke-UnsafeCmd $cmd -Silent } else { Invoke-UnsafeCmd $cmd }
74 | if ($LastExitCode -ne 0) { Write-Error "An error occured when executing '$Cmd'."; return }
75 | }
76 |
77 | function Remove-OldBuildArtifacts
78 | {
79 | <#
80 | .DESCRIPTION
81 | Deletes all the bin and obj folders from the current- and all sub directories.
82 | #>
83 |
84 | Write-Host "Deleting old build artifacts..." -ForegroundColor Magenta
85 |
86 | Get-ChildItem -Include "bin", "obj" -Recurse -Directory `
87 | | ForEach-Object {
88 | Write-Host "Removing folder $_" -ForegroundColor DarkGray
89 | Remove-Item $_ -Recurse -Force }
90 | }
91 |
92 | function Get-NuspecVersion ($nuspecFile)
93 | {
94 | <#
95 | .DESCRIPTION
96 | Gets the value of a .nuspec file.
97 |
98 | .PARAMETER cmd
99 | The relative or absolute path to the .nuspec file.
100 | #>
101 |
102 | [xml] $xml = Get-Content $nuspecFile
103 | [string] $version = $xml.package.metadata.version
104 | $version
105 | }
106 |
107 | function Test-CompareVersions ($version, [string]$gitTag)
108 | {
109 | Write-Host "Matching version against git tag..." -ForegroundColor Magenta
110 | Write-Host "Project version: $version" -ForegroundColor Cyan
111 | Write-Host "Git tag version: $gitTag" -ForegroundColor Cyan
112 |
113 | if (!$gitTag.EndsWith($version))
114 | {
115 | Write-Error "Version and Git tag do not match."
116 | }
117 | }
118 |
119 | # ----------------------------------------------
120 | # .NET functions
121 | # ----------------------------------------------
122 |
123 | function dotnet-info { Invoke-Cmd "dotnet --info" -Silent }
124 | function dotnet-version { Invoke-Cmd "dotnet --version" -Silent }
125 | function dotnet-restore ($project, $argv) { Invoke-Cmd "dotnet restore $project $argv" }
126 | function dotnet-build ($project, $argv) { Invoke-Cmd "dotnet build $project $argv" }
127 | function dotnet-test ($project, $argv) { Invoke-Cmd "dotnet test $project $argv" }
128 | function dotnet-run ($project, $argv) { Invoke-Cmd "dotnet run --project $project $argv" }
129 | function dotnet-pack ($project, $argv) { Invoke-Cmd "dotnet pack $project $argv" }
130 | function dotnet-publish ($project, $argv) { Invoke-Cmd "dotnet publish $project $argv" }
131 |
132 | function Get-DotNetRuntimeVersion
133 | {
134 | <#
135 | .DESCRIPTION
136 | Runs the dotnet --info command and extracts the .NET Runtime version number.
137 | .NOTES
138 | The .NET Runtime version can sometimes be useful for other dotnet CLI commands (e.g. dotnet xunit -fxversion ".NET Runtime version").
139 | #>
140 |
141 | $info = dotnet-info
142 | [System.Array]::Reverse($info)
143 | $version = $info | Where-Object { $_.Contains(" Version") } | Select-Object -First 1
144 | $version.Split(":")[1].Trim()
145 | }
146 |
147 | function Write-DotnetVersions
148 | {
149 | <#
150 | .DESCRIPTION
151 | Writes the .NET SDK and Runtime version to the current host.
152 | #>
153 |
154 | $sdkVersion = dotnet-version
155 | $runtimeVersion = Get-DotNetRuntimeVersion
156 | Write-Host ".NET SDK version: $sdkVersion" -ForegroundColor Cyan
157 | Write-Host ".NET Runtime version: $runtimeVersion" -ForegroundColor Cyan
158 | }
159 |
160 | function Get-DesiredSdk
161 | {
162 | <#
163 | .DESCRIPTION
164 | Gets the desired .NET SDK version from the global.json file.
165 | #>
166 |
167 | Get-Content "global.json" `
168 | | ConvertFrom-Json `
169 | | ForEach-Object { $_.sdk.version.ToString() }
170 | }
171 |
172 |
173 | # ----------------------------------------------
174 | # AppVeyor functions
175 | # ----------------------------------------------
176 |
177 | function Test-IsAppVeyorBuild { return ($env:APPVEYOR -eq $true) }
178 | function Test-IsAppVeyorBuildTriggeredByGitTag { return ($env:APPVEYOR_REPO_TAG -eq $true) }
179 | function Get-AppVeyorGitTag { return $env:APPVEYOR_REPO_TAG_NAME }
180 |
181 | function Update-AppVeyorBuildVersion ($version)
182 | {
183 | if (Test-IsAppVeyorBuild)
184 | {
185 | Write-Host "Updating AppVeyor build version..." -ForegroundColor Magenta
186 | $buildVersion = "$version-$env:APPVEYOR_BUILD_NUMBER"
187 | Write-Host "Setting AppVeyor build version to $buildVersion."
188 | Update-AppveyorBuild -Version $buildVersion
189 | }
190 | }
191 |
192 | # ----------------------------------------------
193 | # Host Writing functions
194 | # ----------------------------------------------
195 |
196 | function Write-BuildHeader ($projectTitle)
197 | {
198 | $header = " $projectTitle ";
199 | $bar = ""
200 | for ($i = 0; $i -lt $header.Length; $i++) { $bar += "-" }
201 |
202 | Write-Host ""
203 | Write-Host $bar -ForegroundColor DarkYellow
204 | Write-Host $header -ForegroundColor DarkYellow
205 | Write-Host $bar -ForegroundColor DarkYellow
206 | Write-Host ""
207 | }
208 |
209 | function Write-SuccessFooter ($msg)
210 | {
211 | $footer = " $msg ";
212 | $bar = ""
213 | for ($i = 0; $i -lt $footer.Length; $i++) { $bar += "-" }
214 |
215 | Write-Host ""
216 | Write-Host $bar -ForegroundColor Green
217 | Write-Host $footer -ForegroundColor Green
218 | Write-Host $bar -ForegroundColor Green
219 | Write-Host ""
220 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | # Giraffe Template
4 |
5 | Giraffe web application template for the `dotnet new` command.
6 |
7 | [](https://www.nuget.org/packages/giraffe-template/)
8 |
9 | [](https://ci.appveyor.com/project/dustinmoris/giraffe-template/history?branch=develop)
10 |
11 | ## Table of contents
12 |
13 | - [Giraffe Template](#giraffe-template)
14 | - [Table of contents](#table-of-contents)
15 | - [Installation](#installation)
16 | - [Updating the template](#updating-the-template)
17 | - [Basics](#basics)
18 | - [Template Options](#template-options)
19 | - [ViewEngine](#viewengine)
20 | - [Solution](#solution)
21 | - [ExcludeTests](#excludetests)
22 | - [Paket](#paket)
23 | - [Known Issues](#known-issues)
24 | - [Cyclic reference](#cyclic-reference)
25 | - [.NET Core 2.0 issues](#net-core-20-issues)
26 | - [Using Visual Studio](#using-visual-studio)
27 | - [Example:](#example)
28 | - [Nightly builds and NuGet feed](#nightly-builds-and-nuget-feed)
29 | - [Contributing](#contributing)
30 | - [Examples](#examples)
31 | - [Default](#default)
32 | - [Installing the new template](#installing-the-new-template)
33 | - [Creating a test project for each permutation](#creating-a-test-project-for-each-permutation)
34 | - [Creating and testing all test projects for all permutations](#creating-and-testing-all-test-projects-for-all-permutations)
35 | - [Creating and testing all permutations and updating the `paket.lock` file afterwards](#creating-and-testing-all-permutations-and-updating-the-paketlock-file-afterwards)
36 | - [Testling the template locally](#testling-the-template-locally)
37 | - [More information](#more-information)
38 | - [License](#license)
39 |
40 | ## Installation
41 |
42 | The easiest way to install the Giraffe template is by running the following command in your terminal:
43 |
44 | ```
45 | dotnet new install "giraffe-template::*"
46 | ```
47 |
48 | This will pull and install the latest [giraffe-template NuGet package](https://www.nuget.org/packages/giraffe-template/) into your .NET environment and make it available to subsequent `dotnet new` commands.
49 |
50 | ## Updating the template
51 |
52 | Whenever there is a new version of the Giraffe template you can update it by re-running the [instructions from the installation](#installation).
53 |
54 | You can also explicitly set the version when installing the template:
55 |
56 | ```console
57 | dotnet new install "giraffe-template::1.4.0"
58 | ```
59 |
60 | ## Basics
61 |
62 | After the template has been installed you can create a new Giraffe web application by simply running `dotnet new giraffe` in your terminal:
63 |
64 | ```console
65 | dotnet new giraffe
66 | ```
67 |
68 | If you wish to use [Paket](https://fsprojects.github.io/Paket/) for your dependency management use the `--Paket` or `-P` parameter when creating a new application:
69 |
70 | ```console
71 | dotnet new giraffe --Paket
72 | ```
73 |
74 | The template uses HTTPS redirection when run in production which is the default unless explicitly overridden. If you don't have a certificate configured for HTTPS, be sure to set `ASPNETCORE_ENVIRONMENT=Development`. In order to test production mode during development you can generate a self signed certificate using this guide: https://docs.microsoft.com/en-us/dotnet/core/additional-tools/self-signed-certificates-guide
75 |
76 | The Giraffe template only supports the F# language at the moment (given that Giraffe is an F# web framework this is on purpose).
77 |
78 | Further information and more help can be found by running `dotnet new giraffe --help` in your terminal.
79 |
80 | ## Template Options
81 |
82 | ### ViewEngine
83 |
84 | The Giraffe template supports four project templates, three different view engines and one API only template:
85 |
86 | - `giraffe` (default)
87 | - `razor`
88 | - `dotliquid`
89 | - `none`
90 |
91 | Use the `--ViewEngine` parameter (short `-V`) to set one of the supported values from above:
92 |
93 | ```console
94 | dotnet new giraffe --ViewEngine razor
95 | ```
96 |
97 | The same command can be abbreviated using the `-V` parameter:
98 |
99 | ```console
100 | dotnet new giraffe -V razor
101 | ```
102 |
103 | If you do not specify the `--ViewEngine` parameter then the `dotnet new giraffe` command will automatically create a Giraffe web application with the `Giraffe.ViewEngine` templating engine.
104 |
105 | ### Solution
106 |
107 | When running `dotnet new giraffe` the created project will only be a single Giraffe project which can be added to an existing .NET Core solution. However, when generating a new Giraffe project from a blank sheet then the `--Solution` (or short `-S`) parameter can simplify the generation of an entire solution, including a `.sln` file and accompanied test projects:
108 |
109 | ```console
110 | dotnet new giraffe --Solution
111 | ```
112 |
113 | This will create the following structure:
114 |
115 | ```text
116 | src/
117 | - AppName/
118 | - Views/
119 | - ...
120 | - WebRoot/
121 | - ...
122 | - Models.fs
123 | - Program.fs
124 | ...
125 | tests/
126 | - AppName.Tests/
127 | - Tests.fs
128 | ...
129 | build.bat
130 | build.sh
131 | AppName.sln
132 | README.md
133 | ```
134 |
135 | ### ExcludeTests
136 |
137 | When creating a new Giraffe application with the `--Solution` (`-S`) flag enabled, then by default the outputted project structure will include a unit test project as well. If this is not desired then add the `--ExcludeTests` or short handed `-E` parameter to prevent tests from being created:
138 |
139 | ```
140 | dotnet new giraffe -S -E
141 | ```
142 |
143 | ### Paket
144 |
145 | If you prefer [Paket](https://fsprojects.github.io/) for managing your project dependencies then specify the `--Paket` (or `-P`) parameter to do so:
146 |
147 | ```
148 | dotnet new giraffe --Paket
149 | ```
150 |
151 | This will exclude the package references from the `.fsproj` files and include the needed `paket.dependencies` and `paket.references` files.
152 |
153 | For more information regarding the NuGet management and restore options via Paket please see the official [Paket documentation](https://fsprojects.github.io/) for details.
154 |
155 | ## Known Issues
156 |
157 | ### Cyclic reference
158 |
159 | Please be aware that you cannot name your project "giraffe" (`dotnet new giraffe -o giraffe`) as this will lead the .NET Core CLI to fail with the error `NU1108-Cycle detected` when trying to resolve the project's dependencies.
160 |
161 | The same happens if you run a blanket `dotnet new giraffe` from within a folder which is called `Giraffe` as well.
162 |
163 | ### .NET Core 2.0 issues
164 |
165 | The `dotnet new giraffe` command was temporarily broken in certain versions of .NET Core 2.x where all templates with a single supported language (e.g. like Giraffe which only supports F#) were throwing an error.
166 |
167 | The affected SDKs are `2.1.x` where `x < 300`. The issue has been fixed in the SDK versions `2.1.300+`.
168 |
169 | If you do run into this issue the workaround is to explicitly specify the language:
170 |
171 | ```console
172 | dotnet new giraffe -lang F#
173 | ```
174 |
175 | ### Using Visual Studio
176 |
177 | The basic giraffe template doesn't work with `IIS Express` which may be the default IIS used by Visual Studio 2017 to build & publish your application. Make sure to change your drop-down (the top of your window, next to the other Configuration Manager settings) IIS setting to be the name of your project and *NOT* `IIS Express`.
178 |
179 | ##### Example:
180 |
181 | 
182 |
183 | ## Nightly builds and NuGet feed
184 |
185 | All official Giraffe packages are published to the official and public NuGet feed.
186 |
187 | Unofficial builds (such as pre-release builds from the `develop` branch and pull requests) produce unofficial pre-release NuGet packages which can be pulled from the project's public NuGet feed on AppVeyor:
188 |
189 | ```url
190 | https://ci.appveyor.com/nuget/giraffe-template
191 | ```
192 |
193 | If you add this source to your NuGet CLI or project settings then you can pull unofficial NuGet packages for quick feature testing or urgent hot fixes.
194 |
195 | ## Contributing
196 |
197 | Please use the `./build.ps1` PowerShell script to build and test the Giraffe template before submitting a PR.
198 |
199 | The `./build.ps1` PowerShell script comes with the following feature switches:
200 |
201 | | Switch | Description |
202 | | :----- | :---------- |
203 | | No switch | The default script without a switch will build all projects and run all tests before producing a Giraffe template NuGet package. | `./build.ps1` |
204 | | `InstallTemplate` | After successfully creating a new NuGet package for the Giraffe template the `-InstallTemplate` switch will uninstall any existing Giraffe templates before installing the freshly built template again. |
205 | | `CreatePermutations` | The `-CreatePermutations` switch does everything what the `-InstallTemplate` switch does plus it will create a new test project for each individual permutation of the Giraffe template options. All test projects will be created under the `.temp` folder. An existing folder of the same name will be cleared before creating all test projects. |
206 | | `TestPermutations` | The `-TestPermutations` switch does everything what the `-CreatePermutations` switch does plus it will build all test projects and execute their unit tests. This is the most comprehensive build and will likely take several minutes before completing. It is recommended to run this build before submitting a PR. |
207 | | `UpdatePaketDependencies` | The `-UpdatePaketDependencies` switch does everything what the `-TestPermutations` switch does plus it will update the Giraffe NuGet dependencies for all Paket enabled test projects. After updating the Giraffe dependency it will automatically copy the upated `paket.lock` file into the correct template of the `./src` folder. It is recommended to run this build when changing any dependencies for one or many templates. |
208 |
209 | ### Examples
210 |
211 | #### Default
212 |
213 | Windows:
214 |
215 | ```powershell
216 | > ./build.ps1
217 | ```
218 |
219 | macOS and Linux:
220 |
221 | ```powershell
222 | $ pwsh ./build.ps1
223 | ```
224 |
225 | #### Installing the new template
226 |
227 | Windows:
228 |
229 | ```powershell
230 | > ./build.ps1 -InstallTemplate
231 | ```
232 |
233 | macOS and Linux:
234 |
235 | ```powershell
236 | $ pwsh ./build.ps1 -InstallTemplate
237 | ```
238 |
239 | #### Creating a test project for each permutation
240 |
241 | Windows:
242 |
243 | ```powershell
244 | > ./build.ps1 -CreatePermutations
245 | ```
246 |
247 | macOS and Linux:
248 |
249 | ```powershell
250 | $ pwsh ./build.ps1 -CreatePermutations
251 | ```
252 |
253 | #### Creating and testing all test projects for all permutations
254 |
255 | Windows:
256 |
257 | ```powershell
258 | > ./build.ps1 -TestPermutations
259 | ```
260 |
261 | macOS and Linux:
262 |
263 | ```powershell
264 | $ pwsh ./build.ps1 -TestPermutations
265 | ```
266 |
267 | #### Creating and testing all permutations and updating the `paket.lock` file afterwards
268 |
269 | Windows:
270 |
271 | ```powershell
272 | > ./build.ps1 -UpdatePaketDependencies
273 | ```
274 |
275 | macOS and Linux:
276 |
277 | ```powershell
278 | $ pwsh ./build.ps1 -UpdatePaketDependencies
279 | ```
280 |
281 | #### Testling the template locally
282 |
283 | If you already have giraffe-template installed, then
284 |
285 | ```console
286 | $ dotnet new uninstall giraffe-template
287 | ```
288 |
289 | This will install from the local file system
290 |
291 | ```console
292 | dotnet new install ./src/ --force
293 | ```
294 |
295 | To uninstall later:
296 |
297 | ```console
298 | $ dotnet new uninstall /giraffe-template/src
299 | ```
300 |
301 | To use the template:
302 |
303 | ```console
304 | dotnet new giraffe
305 | ```
306 |
307 | Test it locally:
308 |
309 | ```console
310 | dotnet run --project giraffe-template.fsproj
311 | ```
312 |
313 | Remember to remove the template generated files
314 |
315 | ## More information
316 |
317 | For more information about Giraffe, how to set up a development environment, contribution guidelines and more please visit the [main documentation](https://github.com/giraffe-fsharp/Giraffe#table-of-contents) page.
318 |
319 | ## License
320 |
321 | [Apache 2.0](https://raw.githubusercontent.com/giraffe-fsharp/giraffe-template/master/LICENSE)
322 |
--------------------------------------------------------------------------------