From 8d97e73b08bac6db6e01d1b49a9f2e8b27296eb9 Mon Sep 17 00:00:00 2001 From: Dustin Moris Gorski Date: Sun, 19 Aug 2018 09:39:35 +0100 Subject: [PATCH] Updated Giraffe to latest version Updated Giraffe and ASP.NET Core dependencies to latest version. --- .gitattributes | 3 +- .travis.yml | 3 +- RELEASE_NOTES.md | 4 + appveyor.yml | 2 + build.ps1 | 88 ++++++++++--------- global.json | 2 +- install-dotnet.ps1 | 88 +++++++++++++++++++ .../GiraffeDotLiquidSample.Tests.fsproj | 16 ++-- .../GiraffeDotLiquidSample.fsproj | 10 +-- .../Giraffe.DotLiquid.fsproj | 28 +++--- .../Giraffe.DotLiquid.Tests.fsproj | 14 +-- 11 files changed, 176 insertions(+), 82 deletions(-) create mode 100644 install-dotnet.ps1 diff --git a/.gitattributes b/.gitattributes index 2125666..1312090 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ -* text=auto \ No newline at end of file +* text=auto +*.sh text eol=lf \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 800fa90..dc19cab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: csharp sudo: required dist: trusty -dotnet: 2.1.4 +dotnet: 2.1.400 mono: - 4.6.1 - 4.8.1 @@ -16,6 +16,7 @@ before_install: - curl https://packages.microsoft.com/config/ubuntu/14.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list - sudo apt-get update - sudo apt-get install -y powershell + - sudo pwsh ./install-dotnet.ps1 script: - export FrameworkPathOverride=$(dirname $(which mono))/../lib/mono/4.5/ diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 21d710d..b0e80a3 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,6 +1,10 @@ Release Notes ============= +## 1.2.0 + +Upgraded to Giraffe `2.0.0` and the latest ASP.NET Core `2.1.*` NuGet packages. + ## 1.1.0 Upgraded Giraffe to `1.1.0`. diff --git a/appveyor.yml b/appveyor.yml index ed18806..dccdf9e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,6 +4,8 @@ environment: DOTNET_CLI_TELEMETRY_OPTOUT: 1 init: - git config --global core.autocrlf true +install: + - ps: .\install-dotnet.ps1 build: off build_script: - ps: .\build.ps1 -Release -Pack diff --git a/build.ps1 b/build.ps1 index 7992d76..6584322 100644 --- a/build.ps1 +++ b/build.ps1 @@ -38,12 +38,52 @@ function Write-DotnetVersion Write-Host ".NET Core runtime version: $dotnetVersion" -ForegroundColor Cyan } -function dotnet-restore ($project, $argv) { Invoke-Cmd "dotnet restore $project $argv" } -function dotnet-build ($project, $argv) { Invoke-Cmd "dotnet build $project $argv" } +function Get-TargetFrameworks ($projFile) +{ + [xml]$proj = Get-Content $projFile + + if ($proj.Project.PropertyGroup.TargetFrameworks -ne $null) { + ($proj.Project.PropertyGroup.TargetFrameworks).Split(";") + } + else { + @($proj.Project.PropertyGroup.TargetFramework) + } +} + +function Get-NetCoreTargetFramework ($projFile) +{ + Get-TargetFrameworks $projFile | where { $_ -like "netstandard*" -or $_ -like "netcoreapp*" } +} + function dotnet-run ($project, $argv) { Invoke-Cmd "dotnet run --project $project $argv" } -function dotnet-test ($project, $argv) { Invoke-Cmd "dotnet test $project $argv" } function dotnet-pack ($project, $argv) { Invoke-Cmd "dotnet pack $project $argv" } +function dotnet-build ($project, $argv) +{ + if ($OnlyNetStandard.IsPresent) { + $fw = Get-NetCoreTargetFramework $project + $argv = "-f $fw " + $argv + } + + Invoke-Cmd "dotnet build $project $argv" +} + +function dotnet-test ($project, $argv) +{ + # Currently dotnet test does not work for net461 on Linux/Mac + # See: https://github.com/Microsoft/vstest/issues/1318 + # + # Previously dotnet-xunit was a great alternative, however after + # issues with the maintenance dotnet xunit has been discontinued + # after xunit 2.4: https://xunit.github.io/releases/2.4 + if(!(Test-IsWindows) -or $OnlyNetStandard.IsPresent) { + $fw = Get-NetCoreTargetFramework $project; + $argv = "-f $fw " + $argv + } + + Invoke-Cmd "dotnet test $project $argv" +} + function Test-Version ($project) { if ($env:APPVEYOR_REPO_TAG -eq $true) @@ -88,26 +128,6 @@ function Remove-OldBuildArtifacts Remove-Item $_ -Recurse -Force } } -function Get-TargetFrameworks ($projFile) -{ - [xml]$proj = Get-Content $projFile - ($proj.Project.PropertyGroup.TargetFrameworks).Split(";") -} - -function Get-NetCoreTargetFramework ($projFile) -{ - Get-TargetFrameworks $projFile | where { $_ -like "netstandard*" -or $_ -like "netcoreapp*" } -} - -function Get-FrameworkArg ($projFile) -{ - if ($OnlyNetStandard.IsPresent) { - $fw = Get-NetCoreTargetFramework $projFile - "-f $fw" - } - else { "" } -} - # ---------------------------------------------- # Main # ---------------------------------------------- @@ -130,34 +150,21 @@ Remove-OldBuildArtifacts $configuration = if ($Release.IsPresent) { "Release" } else { "Debug" } Write-Host "Building Giraffe.DotLiquid..." -ForegroundColor Magenta -$framework = Get-FrameworkArg $giraffeDotLiquid -dotnet-restore $giraffeDotLiquid -dotnet-build $giraffeDotLiquid "-c $configuration $framework" +dotnet-build $giraffeDotLiquid "-c $configuration" if (!$ExcludeTests.IsPresent -and !$Run.IsPresent) { Write-Host "Building and running tests..." -ForegroundColor Magenta - $framework = Get-FrameworkArg $giraffeDotLiquidTests - # Currently dotnet test does not work for net461 on Linux/Mac - # See: https://github.com/Microsoft/vstest/issues/1318 - if (!(Test-IsWindows)) { - Write-Warning "Running tests only for .NET Core build, because dotnet test does not support net4x tests on Linux/Mac at the moment (see: https://github.com/Microsoft/vstest/issues/1318)." - $fw = Get-NetCoreTargetFramework $giraffeDotLiquidTests - $framework = "-f $fw" - } - dotnet-restore $giraffeDotLiquidTests - dotnet-build $giraffeDotLiquidTests $framework - dotnet-test $giraffeDotLiquidTests $framework + + dotnet-build $giraffeDotLiquidTests + dotnet-test $giraffeDotLiquidTests } if (!$ExcludeSamples.IsPresent -and !$Run.IsPresent) { Write-Host "Building and testing samples..." -ForegroundColor Magenta - - dotnet-restore $sampleApp dotnet-build $sampleApp - dotnet-restore $sampleAppTests dotnet-build $sampleAppTests dotnet-test $sampleAppTests } @@ -165,7 +172,6 @@ if (!$ExcludeSamples.IsPresent -and !$Run.IsPresent) if ($Run.IsPresent) { Write-Host "Launching sample application..." -ForegroundColor Magenta - dotnet-restore $sampleApp dotnet-build $sampleApp dotnet-run $sampleApp } diff --git a/global.json b/global.json index a09404e..b11d921 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "projects": [ "src", "tests" ], "sdk": { - "version": "2.1.4" + "version": "2.1.400" } } \ No newline at end of file diff --git a/install-dotnet.ps1 b/install-dotnet.ps1 new file mode 100644 index 0000000..7f3770e --- /dev/null +++ b/install-dotnet.ps1 @@ -0,0 +1,88 @@ +# ---------------------------------------------------------- +# Install script to check and download the correct .NET SDK +# ---------------------------------------------------------- + +function Test-IsWindows +{ + [environment]::OSVersion.Platform -ne "Unix" +} + +function Invoke-Cmd ($cmd) +{ + Write-Host $cmd -ForegroundColor DarkCyan + if (Test-IsWindows) { $cmd = "cmd.exe /C $cmd" } + Invoke-Expression -Command $cmd + if ($LastExitCode -ne 0) { Write-Error "An error occured when executing '$cmd'."; return } +} + +function dotnet-version { Invoke-Cmd "dotnet --version" } + +function Get-DesiredSdk +{ + Get-Content "global.json" | ConvertFrom-Json | % { $_.sdk.version.ToString() } +} + +function Get-NetCoreSdk ($version) +{ + $os = if (Test-IsWindows) { "windows" } else { "linux" } + + $response = Invoke-WebRequest ` + -Uri "https://www.microsoft.com/net/download/thank-you/dotnet-sdk-$version-$os-x64-binaries" ` + -Method Get ` + -MaximumRedirection 0 ` + + $downloadLink = + $response.Links ` + | Where-Object { $_.onclick -eq "recordManualDownload()" } ` + | Select-Object -Expand href + + $tempFile = [System.IO.Path]::GetTempFileName() + $webClient = New-Object System.Net.WebClient + $webClient.DownloadFile($downloadLink, $tempFile) + return $tempFile +} + +function Install-NetCoreSdk ($sdkZipPath) +{ + $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetsdk" + New-Item $env:DOTNET_INSTALL_DIR -ItemType Directory -Force + + Add-Type -AssemblyName System.IO.Compression.FileSystem; + [System.IO.Compression.ZipFile]::ExtractToDirectory($sdkZipPath, $env:DOTNET_INSTALL_DIR) + $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path" +} + +# ---------------------------------------------- +# Install .NET Core SDK +# ---------------------------------------------- + +$ErrorActionPreference = "Stop" + +# Rename the global.json before making the dotnet --version call +# This will prevent AppVeyor to fail because it might not find +# the desired SDK specified in the global.json +$globalJson = Get-Item "global.json" +Rename-Item -Path $globalJson.FullName -NewName "global.json.bak" -Force + +# Get the current .NET Core SDK version +$currentSdk = dotnet-version + +# After we established the current installed .NET SDK we can put the global.json back +Rename-Item -Path ($globalJson.FullName + ".bak") -NewName "global.json" -Force + +$desiredSdk = Get-DesiredSdk + +if ($desiredSdk -eq $currentSdk) +{ + Write-Host "The current .NET SDK matches the project's desired .NET SDK: $desiredSDK" -ForegroundColor Green + return +} + +Write-Host "The current .NET SDK ($currentSdk) doesn't match the project's desired .NET SDK ($desiredSdk)." -ForegroundColor Yellow +Write-Host "Attempting to download and install the correct .NET SDK..." + +$sdkZipPath = Get-NetCoreSdk $desiredSdk +Install-NetCoreSdk $sdkZipPath + +Write-Host ".NET SDK installation complete." -ForegroundColor Green +dotnet-version \ No newline at end of file diff --git a/samples/GiraffeDotLiquidSample.Tests/GiraffeDotLiquidSample.Tests.fsproj b/samples/GiraffeDotLiquidSample.Tests/GiraffeDotLiquidSample.Tests.fsproj index c494a07..fc69e91 100644 --- a/samples/GiraffeDotLiquidSample.Tests/GiraffeDotLiquidSample.Tests.fsproj +++ b/samples/GiraffeDotLiquidSample.Tests/GiraffeDotLiquidSample.Tests.fsproj @@ -1,24 +1,18 @@ - netcoreapp2.0 + netcoreapp2.1 GiraffeDotLiquidSample.Tests portable true - - + + - - - - - - - - + + diff --git a/samples/GiraffeDotLiquidSample/GiraffeDotLiquidSample.fsproj b/samples/GiraffeDotLiquidSample/GiraffeDotLiquidSample.fsproj index 332ab21..508f245 100644 --- a/samples/GiraffeDotLiquidSample/GiraffeDotLiquidSample.fsproj +++ b/samples/GiraffeDotLiquidSample/GiraffeDotLiquidSample.fsproj @@ -1,28 +1,22 @@ - netcoreapp2.0 + netcoreapp2.1 portable GiraffeDotLiquidSample Exe - GiraffeDotLiquidSample - 2.0 false $(MSBuildThisFileDirectory) - + - - - - diff --git a/src/Giraffe.DotLiquid/Giraffe.DotLiquid.fsproj b/src/Giraffe.DotLiquid/Giraffe.DotLiquid.fsproj index aa6e57d..cf6de8b 100755 --- a/src/Giraffe.DotLiquid/Giraffe.DotLiquid.fsproj +++ b/src/Giraffe.DotLiquid/Giraffe.DotLiquid.fsproj @@ -1,16 +1,25 @@  Giraffe.DotLiquid - 1.1.0 + 1.2.0 + net461;netstandard2.0 + + DotLiquid templating engine http handlers for the Giraffe web framework. Copyright 2018 Dustin Moris Gorski - en-GB Dustin Moris Gorski and contributors - net461;netstandard2.0 + en-GB + + portable - 1 True Library + true + false + true + true + + Giraffe.DotLiquid Giraffe;DotLiquid;ASP.NET Core;Lambda;FSharp;Functional;Http;Web;Framework;Micro;Service https://raw.githubusercontent.com/giraffe-fsharp/Giraffe.DotLiquid/master/RELEASE_NOTES.md @@ -21,17 +30,12 @@ git https://github.com/giraffe-fsharp/Giraffe.DotLiquid true - 2.0 - false - true - - - - - + + + diff --git a/tests/Giraffe.DotLiquid.Tests/Giraffe.DotLiquid.Tests.fsproj b/tests/Giraffe.DotLiquid.Tests/Giraffe.DotLiquid.Tests.fsproj index 8f4d883..8e74273 100644 --- a/tests/Giraffe.DotLiquid.Tests/Giraffe.DotLiquid.Tests.fsproj +++ b/tests/Giraffe.DotLiquid.Tests/Giraffe.DotLiquid.Tests.fsproj @@ -1,20 +1,20 @@ - net461;netcoreapp2.0 + net461;netcoreapp2.1 Giraffe.DotLiquid.Tests portable - - - + + + - - + + - +