|
| 1 | +# Taken from psake https://github.com/psake/psake |
| 2 | + |
| 3 | +<# |
| 4 | +.SYNOPSIS |
| 5 | + This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode |
| 6 | + to see if an error occcured. If an error is detected then an exception is thrown. |
| 7 | + This function allows you to run command-line programs without having to |
| 8 | + explicitly check the $lastexitcode variable. |
| 9 | +.EXAMPLE |
| 10 | + exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed" |
| 11 | +#> |
| 12 | +function Exec |
| 13 | +{ |
| 14 | + [CmdletBinding()] |
| 15 | + param( |
| 16 | + [Parameter(Position=0,Mandatory=1)][scriptblock]$cmd, |
| 17 | + [Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd) |
| 18 | + ) |
| 19 | + & $cmd |
| 20 | + if ($lastexitcode -ne 0) { |
| 21 | + throw ("Exec: " + $errorMessage) |
| 22 | + } |
| 23 | +} |
| 24 | + |
| 25 | +if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse } |
| 26 | + |
| 27 | +exec { & dotnet restore } |
| 28 | + |
| 29 | +$tag = $(git tag -l --points-at HEAD) |
| 30 | +$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; |
| 31 | +$suffix = @{ $true = ""; $false = "ci-$revision"}[$tag -ne $NULL -and $revision -ne "local"] |
| 32 | +$commitHash = $(git rev-parse --short HEAD) |
| 33 | +$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""] |
| 34 | + |
| 35 | +echo "build: Tag is $tag" |
| 36 | +echo "build: Package version suffix is $suffix" |
| 37 | +echo "build: Build version suffix is $buildSuffix" |
| 38 | + |
| 39 | +exec { & dotnet build JWTSimpleServer.sln -c Release --version-suffix=$buildSuffix -v q /nologo } |
| 40 | + |
| 41 | +echo "running tests" |
| 42 | + |
| 43 | +try { |
| 44 | + |
| 45 | +Push-Location -Path .\tests\UnitTests |
| 46 | + |
| 47 | +exec { & dotnet xunit -configuration Release --fx-version 2.0.0 } |
| 48 | +} finally { |
| 49 | +Pop-Location |
| 50 | +} |
| 51 | + |
| 52 | +try { |
| 53 | + |
| 54 | + Push-Location -Path .\tests\FunctionalTests |
| 55 | + |
| 56 | + exec { & dotnet xunit -configuration Release --fx-version 2.0.0 } |
| 57 | + } finally { |
| 58 | + Pop-Location |
| 59 | + } |
| 60 | + |
| 61 | + |
| 62 | +if ($suffix -eq "") { |
| 63 | + exec { & dotnet pack .\src\JWTSimpleServer\JWTSimpleServer.csproj -c Release -o ..\..\artifacts --include-symbols --no-build } |
| 64 | + exec { & dotnet pack .\src\JWTSimpleServer.EntityFrameworkCoreRefreshTokenStore\JWTSimpleServer.EntityFrameworkCoreRefreshTokenStore.csproj -c Release -o ..\..\artifacts --include-symbols --no-build } |
| 65 | + exec { & dotnet pack .\src\JWTSimpleServer.InMemoryRefreshTokenStore\JWTSimpleServer.InMemoryRefreshTokenStore.csproj -c Release -o ..\..\artifacts --include-symbols --no-build } |
| 66 | + exec { & dotnet pack .\src\JWTSimpleServer.MessagePackRefreshTokenStore\JWTSimpleServer.MessagePackRefreshTokenStore.csproj -c Release -o ..\..\artifacts --include-symbols --no-build } |
| 67 | +exec { & dotnet pack .\src\JWTSimpleServer.RedisDistributedRefreshTokenStore\JWTSimpleServer.RedisDistributedRefreshTokenStore.csproj -c Release -o ..\..\artifacts --include-symbols --no-build } |
| 68 | +} else { |
| 69 | + exec { & dotnet pack .\src\JWTSimpleServer\JWTSimpleServer.csproj -c Release -o ..\..\artifacts --include-symbols --no-build --version-suffix=$suffix } |
| 70 | + exec { & dotnet pack .\src\JWTSimpleServer.EntityFrameworkCoreRefreshTokenStore\JWTSimpleServer.EntityFrameworkCoreRefreshTokenStore.csproj -c Release -o ..\..\artifacts --include-symbols --no-build --version-suffix=$suffix } |
| 71 | + exec { & dotnet pack .\src\JWTSimpleServer.InMemoryRefreshTokenStore\JWTSimpleServer.InMemoryRefreshTokenStore.csproj -c Release -o ..\..\artifacts --include-symbols --no-build --version-suffix=$suffix } |
| 72 | + exec { & dotnet pack .\src\JWTSimpleServer.MessagePackRefreshTokenStore\JWTSimpleServer.MessagePackRefreshTokenStore.csproj -c Release -o ..\..\artifacts --include-symbols --no-build --version-suffix=$suffix } |
| 73 | +exec { & dotnet pack .\src\JWTSimpleServer.RedisDistributedRefreshTokenStore\JWTSimpleServer.RedisDistributedRefreshTokenStore.csproj -c Release -o ..\..\artifacts --include-symbols --no-build --version-suffix=$suffix } |
| 74 | +} |
| 75 | + |
0 commit comments