Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinmoris committed Aug 19, 2018
2 parents 167deba + 8d97e73 commit ed3474c
Show file tree
Hide file tree
Showing 11 changed files with 176 additions and 82 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* text=auto
* text=auto
*.sh text eol=lf
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/
Expand Down
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
88 changes: 47 additions & 41 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
# ----------------------------------------------
Expand All @@ -130,42 +150,28 @@ 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
}

if ($Run.IsPresent)
{
Write-Host "Launching sample application..." -ForegroundColor Magenta
dotnet-restore $sampleApp
dotnet-build $sampleApp
dotnet-run $sampleApp
}
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"projects": [ "src", "tests" ],
"sdk": {
"version": "2.1.4"
"version": "2.1.400"
}
}
88 changes: 88 additions & 0 deletions install-dotnet.ps1
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>GiraffeDotLiquidSample.Tests</AssemblyName>
<DebugType>portable</DebugType>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.*" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.0.*" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.*" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.*" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.0.*" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.0.*" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.0.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.*" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.0.*" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.*" />
<PackageReference Include="xunit" Version="2.3.*" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.*" />
<PackageReference Include="xunit" Version="2.4.*" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.*" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 2 additions & 8 deletions samples/GiraffeDotLiquidSample/GiraffeDotLiquidSample.fsproj
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
<DebugType>portable</DebugType>
<AssemblyName>GiraffeDotLiquidSample</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>GiraffeDotLiquidSample</PackageId>
<RuntimeFrameworkVersion>2.0</RuntimeFrameworkVersion>
<EnableDefaultContentItems>false</EnableDefaultContentItems>
<RunWorkingDirectory>$(MSBuildThisFileDirectory)</RunWorkingDirectory>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.*" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.*" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Giraffe.DotLiquid\Giraffe.DotLiquid.fsproj" />
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.*" />
</ItemGroup>

<ItemGroup>
<Watch Include="**\*.liquid" Exclude="bin\**\*" />
</ItemGroup>
Expand Down
28 changes: 16 additions & 12 deletions src/Giraffe.DotLiquid/Giraffe.DotLiquid.fsproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>Giraffe.DotLiquid</AssemblyName>
<Version>1.1.0</Version>
<Version>1.2.0</Version>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>

<!-- General info -->
<Description>DotLiquid templating engine http handlers for the Giraffe web framework.</Description>
<Copyright>Copyright 2018 Dustin Moris Gorski</Copyright>
<NeutralLanguage>en-GB</NeutralLanguage>
<Authors>Dustin Moris Gorski and contributors</Authors>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
<NeutralLanguage>en-GB</NeutralLanguage>

<!-- Build config -->
<DebugType>portable</DebugType>
<WarningsAsErrors>1</WarningsAsErrors>
<Optimize>True</Optimize>
<OutputType>Library</OutputType>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>

<!-- NuGet config -->
<PackageId>Giraffe.DotLiquid</PackageId>
<PackageTags>Giraffe;DotLiquid;ASP.NET Core;Lambda;FSharp;Functional;Http;Web;Framework;Micro;Service</PackageTags>
<PackageReleaseNotes>https://github.com/raw/giraffe-fsharp/Giraffe.DotLiquid/master/RELEASE_NOTES.md</PackageReleaseNotes>
Expand All @@ -21,17 +30,12 @@
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/giraffe-fsharp/Giraffe.DotLiquid</RepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<NetStandardImplicitPackageVersion>2.0</NetStandardImplicitPackageVersion>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.0.*" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.0.*" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.*" />
<PackageReference Include="Microsoft.Extensions.Primitives" Version="2.0.*" />
<PackageReference Include="Giraffe" Version="1.1.*" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.1.*" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.1.*" />
<PackageReference Include="Giraffe" Version="2.0.*" />
<PackageReference Include="DotLiquid" Version="2.0.*" />
</ItemGroup>

Expand Down
Loading

0 comments on commit ed3474c

Please sign in to comment.