Skip to content

Commit 0931068

Browse files
committed
Merge branch 'develop'
2 parents db98bed + 543f2f6 commit 0931068

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1841
-5398
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,4 +296,7 @@ __pycache__/
296296

297297
#custom
298298

299-
.temp
299+
.temp
300+
301+
#Ionide
302+
.ionide

.psscripts/build-functions.ps1

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,24 @@ function Test-CompareVersions ($version, [string]$gitTag)
145145
}
146146
}
147147

148+
function Add-ToPathVariable ($path)
149+
{
150+
if (Test-IsWindows)
151+
{
152+
$updatedPath = "$path;$env:Path"
153+
[Environment]::SetEnvironmentVariable("Path", $updatedPath, "Process")
154+
[Environment]::SetEnvironmentVariable("Path", $updatedPath, "User")
155+
[Environment]::SetEnvironmentVariable("Path", $updatedPath, "Machine")
156+
}
157+
else
158+
{
159+
$updatedPath = "$path`:$env:PATH"
160+
[Environment]::SetEnvironmentVariable("PATH", $updatedPath, "Process")
161+
[Environment]::SetEnvironmentVariable("PATH", $updatedPath, "User")
162+
[Environment]::SetEnvironmentVariable("PATH", $updatedPath, "Machine")
163+
}
164+
}
165+
148166
# ----------------------------------------------
149167
# .NET Core functions
150168
# ----------------------------------------------
@@ -270,17 +288,18 @@ function Get-NetCoreSdkFromWeb ($version)
270288

271289
$os = if (Test-IsWindows) { "windows" } else { "linux" }
272290
$ext = if (Test-IsWindows) { ".zip" } else { ".tar.gz" }
291+
$uri = "https://www.microsoft.com/net/download/thank-you/dotnet-sdk-$version-$os-x64-binaries"
292+
Write-Host "Finding download link..."
273293

274-
$response = Invoke-WebRequest `
275-
-Uri "https://www.microsoft.com/net/download/thank-you/dotnet-sdk-$version-$os-x64-binaries" `
276-
-Method Get `
277-
-MaximumRedirection 0 `
294+
$response = Invoke-WebRequest -Uri $uri
278295

279296
$downloadLink =
280297
$response.Links `
281298
| Where-Object { $_.onclick -eq "recordManualDownload()" } `
282299
| Select-Object -Expand href
283300

301+
Write-Host "Creating temporary file..."
302+
284303
$tempFile = [System.IO.Path]::GetTempFileName() + $ext
285304

286305
$webClient = New-Object System.Net.WebClient
@@ -303,13 +322,11 @@ function Install-NetCoreSdkFromArchive ($sdkArchivePath)
303322

304323
if (Test-IsWindows)
305324
{
306-
$env:DOTNET_INSTALL_DIR = [System.IO.Path]::Combine($pwd, ".dotnetsdk")
307-
New-Item $env:DOTNET_INSTALL_DIR -ItemType Directory -Force | Out-Null
308-
Write-Host "Created folder '$env:DOTNET_INSTALL_DIR'."
309-
Expand-Archive -LiteralPath $sdkArchivePath -DestinationPath $env:DOTNET_INSTALL_DIR -Force
310-
Write-Host "Extracted '$sdkArchivePath' to folder '$env:DOTNET_INSTALL_DIR'."
311-
$env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"
312-
Write-Host "Added '$env:DOTNET_INSTALL_DIR' to the environment variables."
325+
$dotnetInstallDir = [System.IO.Path]::Combine($pwd, ".dotnetsdk")
326+
New-Item $dotnetInstallDir -ItemType Directory -Force | Out-Null
327+
Write-Host "Created folder '$dotnetInstallDir'."
328+
Expand-Archive -LiteralPath $sdkArchivePath -DestinationPath $dotnetInstallDir -Force
329+
Write-Host "Extracted '$sdkArchivePath' to folder '$dotnetInstallDir'."
313330
}
314331
else
315332
{
@@ -318,9 +335,11 @@ function Install-NetCoreSdkFromArchive ($sdkArchivePath)
318335
Write-Host "Created folder '$dotnetInstallDir'."
319336
Invoke-Cmd "tar -xf $sdkArchivePath -C $dotnetInstallDir"
320337
Write-Host "Extracted '$sdkArchivePath' to folder '$dotnetInstallDir'."
321-
$env:PATH = "$env:PATH:$dotnetInstallDir"
322-
Write-Host "Added '$dotnetInstallDir' to the environment variables."
323338
}
339+
340+
Add-ToPathVariable $dotnetInstallDir
341+
Write-Host "Added '$dotnetInstallDir' to the PATH environment variable:"
342+
Write-Host $env:PATH
324343
}
325344

326345
function Install-NetCoreSdkForUbuntu ($ubuntuVersion, $sdkVersion)

.psscripts/nuget-updates.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function Get-NuGetPackageInfo ($nugetPackageId, $currentVersion)
77
$url = "https://api-v2v3search-0.nuget.org/query?q=$nugetPackageId&prerelease=false"
88
$result = Invoke-RestMethod -Uri $url -Method Get
99
$latestVersion = $result.data[0].version
10-
$upgradeAvailable = !$latestVersion.StartsWith($currentVersion.Replace("*", ""))
10+
$upgradeAvailable = $currentVersion -and !$latestVersion.StartsWith($currentVersion.Replace("*", ""))
1111

1212
[PSCustomObject]@{
1313
PackageName = $nugetPackageId;
@@ -31,9 +31,9 @@ filter Highlight-Upgrades
3131

3232
Write-Host ""
3333
Write-Host ""
34-
Write-Host "--------------------------------------------------"
35-
Write-Host " Scanning all projects for NuGet package upgrades "
36-
Write-Host "--------------------------------------------------"
34+
Write-Host "--------------------------------------------------" -ForegroundColor DarkYellow
35+
Write-Host " Scanning all projects for NuGet package upgrades " -ForegroundColor DarkYellow
36+
Write-Host "--------------------------------------------------" -ForegroundColor DarkYellow
3737
Write-Host ""
3838

3939
$projects = Get-ChildItem "$PSScriptRoot\..\**\*.*proj" -Recurse | % { $_.FullName }

README.md

Lines changed: 92 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
1-
# Giraffe Template
2-
31
![Giraffe](https://raw.githubusercontent.com/giraffe-fsharp/Giraffe/master/giraffe.png)
42

3+
# Giraffe Template
4+
55
Giraffe web application template for the `dotnet new` command.
66

77
[![NuGet Info](https://buildstats.info/nuget/giraffe-template)](https://www.nuget.org/packages/giraffe-template/)
88

9+
[![Build History](https://buildstats.info/appveyor/chart/dustinmoris/giraffe-template?branch=develop)](https://ci.appveyor.com/project/dustinmoris/giraffe-template/history?branch=develop)
10+
911
## Table of contents
1012

1113
- [Installation](#installation)
12-
- [Basics](#basics)
13-
- [Optional parameters](#optional-parameters)
14-
- [--ViewEngine](#--viewengine)
15-
- [--IncludeTests](#--includetests)
16-
- [--UsePaket](#--usepaket)
1714
- [Updating the template](#updating-the-template)
15+
- [Basics](#basics)
16+
- [Template Options](#template-options)
17+
- [ViewEngine](#viewengine)
18+
- [Solution](#solution)
19+
- [ExcludeTests](#excludetests)
20+
- [Paket](#paket)
21+
- [Known Issues](#known-issues)
22+
- [Cyclic reference](#cyclic-reference)
23+
- [.NET Core 2.0 issues](#net-core-20-issues)
24+
- [Using Visual Studio](#using-visual-studio)
1825
- [Nightly builds and NuGet feed](#nightly-builds-and-nuget-feed)
1926
- [Contributing](#contributing)
2027
- [More information](#more-information)
@@ -28,119 +35,139 @@ The easiest way to install the Giraffe template is by running the following comm
2835
dotnet new -i "giraffe-template::*"
2936
```
3037

31-
This will pull and install the [giraffe-template NuGet package](https://www.nuget.org/packages/giraffe-template/) in your .NET environment and make it available to subsequent `dotnet new` commands.
38+
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.
3239

33-
## Basics
34-
35-
After the template has been installed you can create a new Giraffe web application by simply running `dotnet new giraffe` in your terminal:
40+
## Updating the template
3641

37-
```
38-
dotnet new giraffe
39-
```
42+
Whenever there is a new version of the Giraffe template you can update it by re-running the [instructions from the installation](#installation).
4043

41-
If you wish to use [Paket](https://fsprojects.github.io/Paket/) for your dependency management use the `--UsePaket` parameter when creating a new application:
44+
You can also explicitly set the version when installing the template:
4245

4346
```
44-
dotnet new giraffe --UsePaket
47+
dotnet new -i "giraffe-template::0.11.0"
4548
```
4649

47-
The Giraffe template only supports the F# language at the moment.
48-
49-
Please be also 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.
50-
51-
Further information and more help can be found by running `dotnet new giraffe --help` in your terminal.
52-
53-
### ATTENTION: dotnet new bug in some versions of .NET Core 2.0
54-
55-
Affected SDKs:
56-
57-
- .NET SDK 2.1.X where X < 300
58-
- This was fixed in SDK versions 2.1.300+
59-
- Why? It's a bug in the templating engine: (https://github.com/dotnet/templating/issues/1373)
60-
- This affects all templates which support only one language (like Giraffe which only supports F#)
61-
- The behavior is such that when you run `dotnet new [template]` you may not get any errors and it will just output the `--help` text for the template & CLI.
50+
## Basics
6251

63-
How can I know what version of the SDK I use?
52+
After the template has been installed you can create a new Giraffe web application by simply running `dotnet new giraffe` in your terminal:
6453

6554
```
66-
dotnet --info
55+
dotnet new giraffe
6756
```
6857

69-
Short term fix:
70-
71-
Just specify the language when invoking, like
58+
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:
7259

7360
```
74-
dotnet new giraffe -lang F#
61+
dotnet new giraffe --Paket
7562
```
7663

77-
Long term fix:
64+
The Giraffe template only supports the F# language at the moment (given that Giraffe is an F# web framework this is on purpose).
7865

79-
Upgrade your SDK to versions 2.1.300+ (.NET Core 2.1)
66+
Further information and more help can be found by running `dotnet new giraffe --help` in your terminal.
8067

81-
## Optional parameters
68+
## Template Options
8269

83-
### --ViewEngine
70+
### ViewEngine
8471

85-
The Giraffe template supports three different view engines:
72+
The Giraffe template supports four project templates, three different view engines and one API only template:
8673

8774
- `giraffe` (default)
8875
- `razor`
8976
- `dotliquid`
9077
- `none`
9178

92-
You can optionally specify the `--ViewEngine` parameter (short `-V`) to pass in one of the supported values:
79+
Use the `--ViewEngine` parameter (short `-V`) to set one of the supported values from above:
9380

9481
```
9582
dotnet new giraffe --ViewEngine razor
9683
```
9784

98-
The same using the abbreviated `-V` parameter:
85+
The same command can be abbreviated using the `-V` parameter:
9986

10087
```
10188
dotnet new giraffe -V razor
10289
```
10390

104-
If you do not specify the `--ViewEngine` parameter then the `dotnet new giraffe` command will automatically create a Giraffe web application with the default `GiraffeViewEngine` engine.
91+
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.
10592

106-
### --IncludeTests
93+
### Solution
10794

108-
When creating a new Giraffe web application you can optionally specify the `--IncludeTests` (short `-I`) parameter to automatically generate a default unit test project for your application:
95+
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:
10996

11097
```
111-
dotnet new giraffe --IncludeTests
98+
dotnet new giraffe --Solution
11299
```
113100

114-
This parameter can also be combined with other parameters:
101+
This will create the following structure:
115102

116103
```
117-
dotnet new giraffe --ViewEngine razor --IncludeTests
104+
src/
105+
- AppName/
106+
- Views/
107+
- ...
108+
- WebRoot/
109+
- ...
110+
- Models.fs
111+
- Program.fs
112+
...
113+
tests/
114+
- AppName.Tests/
115+
- Tests.fs
116+
...
117+
build.bat
118+
build.sh
119+
AppName.sln
120+
README.md
118121
```
119122

120-
### --UsePaket
123+
### ExcludeTests
121124

122-
If you prefer [Paket](https://fsprojects.github.io/) for managing your project dependencies then you can specify `--UsePaket` (`-U` for short):
125+
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:
123126

124127
```
125-
dotnet new giraffe --UsePaket
128+
dotnet new giraffe -S -E
126129
```
127130

128-
This will exclude the package references from the *fsproj* file and include the needed *paket.dependencies* and *paket.references* files.
131+
### Paket
129132

130-
> If you do not run *build.bat* (or *build.sh* on **nix) before running `dotnet restore` you need to manually run `./.paket/paket.exe install` (or `mono ./.paket/paket.exe install`).
133+
If you prefer [Paket](https://fsprojects.github.io/) for managing your project dependencies then specify the `--Paket` (or `-P`) parameter to do so:
131134

132-
See the [Paket documentation](https://fsprojects.github.io/) for more details.
135+
```
136+
dotnet new giraffe --Paket
137+
```
133138

134-
## Updating the template
139+
This will exclude the package references from the `.fsproj` files and include the needed `paket.dependencies` and `paket.references` files.
135140

136-
Whenever there is a new version of the Giraffe template you can update it by re-running the [instructions from the installation](#installation).
141+
For more information regarding the NuGet management and restore options via Paket please see the official [Paket documentation](https://fsprojects.github.io/) for details.
137142

138-
You can also explicitly set the version when installing the template:
143+
## Known Issues
144+
145+
### Cyclic reference
146+
147+
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.
148+
149+
The same happens if you run a blanket `dotnet new giraffe` from within a folder which is called `Giraffe` as well.
150+
151+
### .NET Core 2.0 issues
152+
153+
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.
154+
155+
The affected SDKs are `2.1.x` where `x < 300`. The issue has been fixed in the SDK versions `2.1.300+`.
156+
157+
If you do run into this issue the workaround is to explicitly specify the language:
139158

140159
```
141-
dotnet new -i "giraffe-template::0.11.0"
160+
dotnet new giraffe -lang F#
142161
```
143162

163+
### Using Visual Studio
164+
165+
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`.
166+
167+
##### Example:
168+
169+
![IIS Express Giraffe Template](https://user-images.githubusercontent.com/3818802/39714515-5535b446-51f8-11e8-9b76-9c89a3e70eea.png)
170+
144171
## Nightly builds and NuGet feed
145172

146173
All official Giraffe packages are published to the official and public NuGet feed.
@@ -153,12 +180,6 @@ https://ci.appveyor.com/nuget/giraffe-template
153180

154181
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.
155182

156-
## Using Visual Studio
157-
158-
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`. Example:
159-
160-
![](https://user-images.githubusercontent.com/3818802/39714515-5535b446-51f8-11e8-9b76-9c89a3e70eea.png)
161-
162183
## Contributing
163184

164185
Please use the `./build.ps1` PowerShell script to build and test the Giraffe template before submitting a PR.
@@ -183,7 +204,7 @@ Windows:
183204
> ./build.ps1
184205
```
185206

186-
MacOS and Linux:
207+
macOS and Linux:
187208

188209
```powershell
189210
$ pwsh ./build.ps1
@@ -197,7 +218,7 @@ Windows:
197218
> ./build.ps1 -InstallTemplate
198219
```
199220

200-
MacOS and Linux:
221+
macOS and Linux:
201222

202223
```powershell
203224
$ pwsh ./build.ps1 -InstallTemplate
@@ -211,7 +232,7 @@ Windows:
211232
> ./build.ps1 -CreatePermutations
212233
```
213234

214-
MacOS and Linux:
235+
macOS and Linux:
215236

216237
```powershell
217238
$ pwsh ./build.ps1 -CreatePermutations
@@ -225,7 +246,7 @@ Windows:
225246
> ./build.ps1 -TestPermutations
226247
```
227248

228-
MacOS and Linux:
249+
macOS and Linux:
229250

230251
```powershell
231252
$ pwsh ./build.ps1 -TestPermutations
@@ -239,7 +260,7 @@ Windows:
239260
> ./build.ps1 -UpdatePaketDependencies
240261
```
241262

242-
MacOS and Linux:
263+
macOS and Linux:
243264

244265
```powershell
245266
$ pwsh ./build.ps1 -UpdatePaketDependencies

0 commit comments

Comments
 (0)