Skip to content

Commit 6c5df57

Browse files
committed
Merge branch 'develop'
2 parents abd6573 + 06be900 commit 6c5df57

File tree

10 files changed

+171
-77
lines changed

10 files changed

+171
-77
lines changed

.gitattributes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
* text=auto
1+
* text=auto
2+
*.sh text eol=lf

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ language: csharp
22
sudo: required
33
dist: trusty
44

5-
dotnet: 2.1.4
5+
dotnet: 2.1.400
66
mono:
77
- 4.6.1
88
- 4.8.1
@@ -16,6 +16,7 @@ before_install:
1616
- curl https://packages.microsoft.com/config/ubuntu/14.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list
1717
- sudo apt-get update
1818
- sudo apt-get install -y powershell
19+
- sudo pwsh ./install-dotnet.ps1
1920

2021
script:
2122
- export FrameworkPathOverride=$(dirname $(which mono))/../lib/mono/4.5/

RELEASE_NOTES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Release Notes
22
=============
33

4+
## 1.0.0
5+
6+
- Updated Giraffe to version `2.0.0`.
7+
- Removed all other (redundant) dependencies.
8+
49
## 0.1.0-beta-110
510

611
- Updated Giraffe to version `1.1.0`.

appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ environment:
44
DOTNET_CLI_TELEMETRY_OPTOUT: 1
55
init:
66
- git config --global core.autocrlf true
7+
install:
8+
- ps: .\install-dotnet.ps1
79
build: off
810
build_script:
911
- ps: .\build.ps1 -Release -Pack

build.ps1

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ function Invoke-Cmd ($cmd)
2929
if ($LastExitCode -ne 0) { Write-Error "An error occured when executing '$cmd'."; return }
3030
}
3131

32-
function dotnet-info { Invoke-Cmd "dotnet --info" }
33-
function dotnet-version { Invoke-Cmd "dotnet --version" }
34-
function dotnet-build ($project, $argv) { Invoke-Cmd "dotnet build $project $argv" }
35-
function dotnet-run ($project, $argv) { Invoke-Cmd "dotnet run --project $project $argv" }
36-
function dotnet-test ($project, $argv) { Invoke-Cmd "dotnet test $project $argv" }
37-
function dotnet-pack ($project, $argv) { Invoke-Cmd "dotnet pack $project $argv" }
38-
3932
function Get-DotNetRuntimeVersion
4033
{
4134
$info = dotnet-info
@@ -44,12 +37,52 @@ function Get-DotNetRuntimeVersion
4437
$version.Split(":")[1].Trim()
4538
}
4639

47-
function dotnet-xunit ($project, $argv)
40+
function Get-TargetFrameworks ($projFile)
41+
{
42+
[xml]$proj = Get-Content $projFile
43+
44+
if ($proj.Project.PropertyGroup.TargetFrameworks -ne $null) {
45+
($proj.Project.PropertyGroup.TargetFrameworks).Split(";")
46+
}
47+
else {
48+
@($proj.Project.PropertyGroup.TargetFramework)
49+
}
50+
}
51+
52+
function Get-NetCoreTargetFramework ($projFile)
53+
{
54+
Get-TargetFrameworks $projFile | where { $_ -like "netstandard*" -or $_ -like "netcoreapp*" }
55+
}
56+
57+
function dotnet-info { Invoke-Cmd "dotnet --info" }
58+
function dotnet-version { Invoke-Cmd "dotnet --version" }
59+
function dotnet-run ($project, $argv) { Invoke-Cmd "dotnet run --project $project $argv" }
60+
function dotnet-pack ($project, $argv) { Invoke-Cmd "dotnet pack $project $argv" }
61+
62+
function dotnet-build ($project, $argv)
63+
{
64+
if ($OnlyNetStandard.IsPresent) {
65+
$fw = Get-NetCoreTargetFramework $project
66+
$argv = "-f $fw " + $argv
67+
}
68+
69+
Invoke-Cmd "dotnet build $project $argv"
70+
}
71+
72+
function dotnet-test ($project, $argv)
4873
{
49-
$fxversion = Get-DotNetRuntimeVersion
50-
Push-Location (Get-Item $project).Directory.FullName
51-
Invoke-Cmd "dotnet xunit -fxversion $fxversion $argv"
52-
Pop-Location
74+
# Currently dotnet test does not work for net461 on Linux/Mac
75+
# See: https://github.com/Microsoft/vstest/issues/1318
76+
#
77+
# Previously dotnet-xunit was a great alternative, however after
78+
# issues with the maintenance dotnet xunit has been discontinued
79+
# after xunit 2.4: https://xunit.github.io/releases/2.4
80+
if(!(Test-IsWindows) -or $OnlyNetStandard.IsPresent) {
81+
$fw = Get-NetCoreTargetFramework $project;
82+
$argv = "-f $fw " + $argv
83+
}
84+
85+
Invoke-Cmd "dotnet test $project $argv"
5386
}
5487

5588
function Write-DotnetVersion
@@ -108,26 +141,6 @@ function Remove-OldBuildArtifacts
108141
Remove-Item $_ -Recurse -Force }
109142
}
110143

111-
function Get-TargetFrameworks ($projFile)
112-
{
113-
[xml]$proj = Get-Content $projFile
114-
($proj.Project.PropertyGroup.TargetFrameworks).Split(";")
115-
}
116-
117-
function Get-NetCoreTargetFramework ($projFile)
118-
{
119-
Get-TargetFrameworks $projFile | where { $_ -like "netstandard*" -or $_ -like "netcoreapp*" }
120-
}
121-
122-
function Get-FrameworkArg ($projFile)
123-
{
124-
if ($OnlyNetStandard.IsPresent) {
125-
$fw = Get-NetCoreTargetFramework $projFile
126-
"-f $fw"
127-
}
128-
else { "" }
129-
}
130-
131144
# ----------------------------------------------
132145
# Main
133146
# ----------------------------------------------
@@ -149,19 +162,13 @@ Remove-OldBuildArtifacts
149162
$configuration = if ($Release.IsPresent) { "Release" } else { "Debug" }
150163

151164
Write-Host "Building Giraffe.TokenRouter..." -ForegroundColor Magenta
152-
$framework = Get-FrameworkArg $src
153-
dotnet-build $src "-c $configuration $framework"
165+
dotnet-build $src "-c $configuration"
154166

155167
if (!$ExcludeTests.IsPresent -and !$Run.IsPresent)
156168
{
157169
Write-Host "Building and running tests..." -ForegroundColor Magenta
158-
$framework = Get-FrameworkArg $tests
159-
160-
dotnet-build $tests $framework
161-
162-
$xunitArgs = ""
163-
if(!(Test-IsWindows)) { $tfw = Get-NetCoreTargetFramework $tests; $xunitArgs = "-framework $tfw" }
164-
dotnet-xunit $tests $xunitArgs
170+
dotnet-build $tests
171+
dotnet-test $tests
165172
}
166173

167174
if ($Pack.IsPresent)

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"projects": [ "src", "tests" ],
33
"sdk": {
4-
"version": "2.1.4"
4+
"version": "2.1.400"
55
}
66
}

install-dotnet.ps1

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# ----------------------------------------------------------
2+
# Install script to check and download the correct .NET SDK
3+
# ----------------------------------------------------------
4+
5+
function Test-IsWindows
6+
{
7+
[environment]::OSVersion.Platform -ne "Unix"
8+
}
9+
10+
function Invoke-Cmd ($cmd)
11+
{
12+
Write-Host $cmd -ForegroundColor DarkCyan
13+
if (Test-IsWindows) { $cmd = "cmd.exe /C $cmd" }
14+
Invoke-Expression -Command $cmd
15+
if ($LastExitCode -ne 0) { Write-Error "An error occured when executing '$cmd'."; return }
16+
}
17+
18+
function dotnet-version { Invoke-Cmd "dotnet --version" }
19+
20+
function Get-DesiredSdk
21+
{
22+
Get-Content "global.json" | ConvertFrom-Json | % { $_.sdk.version.ToString() }
23+
}
24+
25+
function Get-NetCoreSdk ($version)
26+
{
27+
$os = if (Test-IsWindows) { "windows" } else { "linux" }
28+
29+
$response = Invoke-WebRequest `
30+
-Uri "https://www.microsoft.com/net/download/thank-you/dotnet-sdk-$version-$os-x64-binaries" `
31+
-Method Get `
32+
-MaximumRedirection 0 `
33+
34+
$downloadLink =
35+
$response.Links `
36+
| Where-Object { $_.onclick -eq "recordManualDownload()" } `
37+
| Select-Object -Expand href
38+
39+
$tempFile = [System.IO.Path]::GetTempFileName()
40+
$webClient = New-Object System.Net.WebClient
41+
$webClient.DownloadFile($downloadLink, $tempFile)
42+
return $tempFile
43+
}
44+
45+
function Install-NetCoreSdk ($sdkZipPath)
46+
{
47+
$env:DOTNET_INSTALL_DIR = "$pwd\.dotnetsdk"
48+
New-Item $env:DOTNET_INSTALL_DIR -ItemType Directory -Force
49+
50+
Add-Type -AssemblyName System.IO.Compression.FileSystem;
51+
[System.IO.Compression.ZipFile]::ExtractToDirectory($sdkZipPath, $env:DOTNET_INSTALL_DIR)
52+
$env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"
53+
}
54+
55+
# ----------------------------------------------
56+
# Install .NET Core SDK
57+
# ----------------------------------------------
58+
59+
$ErrorActionPreference = "Stop"
60+
61+
# Rename the global.json before making the dotnet --version call
62+
# This will prevent AppVeyor to fail because it might not find
63+
# the desired SDK specified in the global.json
64+
$globalJson = Get-Item "global.json"
65+
Rename-Item -Path $globalJson.FullName -NewName "global.json.bak" -Force
66+
67+
# Get the current .NET Core SDK version
68+
$currentSdk = dotnet-version
69+
70+
# After we established the current installed .NET SDK we can put the global.json back
71+
Rename-Item -Path ($globalJson.FullName + ".bak") -NewName "global.json" -Force
72+
73+
$desiredSdk = Get-DesiredSdk
74+
75+
if ($desiredSdk -eq $currentSdk)
76+
{
77+
Write-Host "The current .NET SDK matches the project's desired .NET SDK: $desiredSDK" -ForegroundColor Green
78+
return
79+
}
80+
81+
Write-Host "The current .NET SDK ($currentSdk) doesn't match the project's desired .NET SDK ($desiredSdk)." -ForegroundColor Yellow
82+
Write-Host "Attempting to download and install the correct .NET SDK..."
83+
84+
$sdkZipPath = Get-NetCoreSdk $desiredSdk
85+
Install-NetCoreSdk $sdkZipPath
86+
87+
Write-Host ".NET SDK installation complete." -ForegroundColor Green
88+
dotnet-version

src/Giraffe.TokenRouter/Giraffe.TokenRouter.fsproj

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<AssemblyName>Giraffe.TokenRouter</AssemblyName>
4-
<Version>0.1.0-beta-110</Version>
4+
<Version>1.0.0</Version>
5+
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
6+
7+
<!-- General info -->
58
<Description>Alternative routing API for Giraffe web applications which is aimed at maximum performance.</Description>
69
<Copyright>Copyright 2018 Dustin Moris Gorski</Copyright>
7-
<NeutralLanguage>en-GB</NeutralLanguage>
810
<Authors>Dustin Moris Gorski and contributors</Authors>
9-
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
11+
<NeutralLanguage>en-GB</NeutralLanguage>
12+
13+
<!-- Build config -->
1014
<DebugType>portable</DebugType>
11-
<WarningsAsErrors>1</WarningsAsErrors>
1215
<Optimize>True</Optimize>
1316
<OutputType>Library</OutputType>
17+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
18+
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
19+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
20+
21+
<!-- NuGet package config -->
1422
<PackageId>Giraffe.TokenRouter</PackageId>
1523
<PackageTags>Giraffe;TokenRouter;Routing;ASP.NET Core;FSharp;Functional;Http;Web;Framework;Micro;Service</PackageTags>
1624
<PackageReleaseNotes>https://raw.githubusercontent.com/giraffe-fsharp/Giraffe.TokenRouter/master/RELEASE_NOTES.md</PackageReleaseNotes>
@@ -21,17 +29,10 @@
2129
<RepositoryType>git</RepositoryType>
2230
<RepositoryUrl>https://github.com/giraffe-fsharp/Giraffe.TokenRouter</RepositoryUrl>
2331
<IncludeSymbols>true</IncludeSymbols>
24-
<NetStandardImplicitPackageVersion>2.0</NetStandardImplicitPackageVersion>
25-
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
2632
</PropertyGroup>
2733

2834
<ItemGroup>
29-
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.*" />
30-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.*" />
31-
<PackageReference Include="Microsoft.Extensions.FileProviders.Physical" Version="2.0.*" />
32-
<PackageReference Include="Microsoft.Extensions.Primitives" Version="2.0.*" />
33-
<PackageReference Include="Microsoft.AspNetCore.Antiforgery" Version="2.0.*" />
34-
<PackageReference Include="Giraffe" Version="1.1.*" />
35+
<PackageReference Include="Giraffe" Version="2.0.*" />
3536
</ItemGroup>
3637

3738
<ItemGroup>

tests/Giraffe.TokenRouter.Tests/Giraffe.TokenRouter.Tests.fsproj

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
4+
<TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks>
55
<AssemblyName>Giraffe.TokenRouter.Tests</AssemblyName>
66
<DebugType>portable</DebugType>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.*" />
11-
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.0.*" />
12-
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.0.*" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.*" />
11+
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.1.*" />
12+
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.1.*" />
1313
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.0.*" />
14-
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.*" />
15-
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.*" />
16-
<PackageReference Include="System.Net.Http" Version="4.3.*" />
17-
<PackageReference Include="xunit" Version="2.3.*" />
18-
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.*" />
14+
<PackageReference Include="xunit" Version="2.4.*" />
15+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.*" />
1916
<PackageReference Include="NSubstitute" Version="3.1.*" />
20-
<PackageReference Include="FsCheck" Version="3.0.0-*" />
21-
<PackageReference Include="FsCheck.Xunit" Version="3.0.0-*" />
22-
<PackageReference Include="Newtonsoft.Json" Version="10.0.*" />
23-
<PackageReference Include="Giraffe" Version="1.1.*" />
24-
</ItemGroup>
25-
26-
<ItemGroup>
27-
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.*" />
28-
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.*" />
17+
<PackageReference Include="Giraffe" Version="2.0.*" />
2918
</ItemGroup>
3019

3120
<ItemGroup>

tests/Giraffe.TokenRouter.Tests/TokenRouterTests.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,7 @@ type DebugTests(output:ITestOutputHelper) =
14961496
Assert.Equal(expected, body)
14971497
}
14981498

1499+
[<Fact>]
14991500
member __.``Test routePorts function`` () =
15001501
let ctx = Substitute.For<HttpContext>()
15011502
let notFound = (setStatusCode 404 >=> text "Not Found")
@@ -1522,9 +1523,8 @@ type DebugTests(output:ITestOutputHelper) =
15221523

15231524
let expected = "newpassword2"
15241525
ctx.Request.Method.ReturnsForAnyArgs "POST" |> ignore
1525-
ctx.Request.Path.ReturnsForAnyArgs (PathString("/api/newpassword2")) |> ignore
1526-
ctx.Request.Host.Port.HasValue.ReturnsForAnyArgs true |> ignore
1527-
ctx.Request.Host.Port.Value.ReturnsForAnyArgs 9002 |> ignore
1526+
ctx.Request.Path.ReturnsForAnyArgs (PathString("/api2/newpassword2")) |> ignore
1527+
ctx.Request.Host.ReturnsForAnyArgs (HostString("", 9002)) |> ignore
15281528
ctx.Response.Body <- new MemoryStream()
15291529

15301530
task {

0 commit comments

Comments
 (0)