Skip to content

Commit

Permalink
task: unit tests get run in build script
Browse files Browse the repository at this point in the history
  • Loading branch information
alastairtree committed Feb 26, 2018
1 parent 4ba893b commit 7b5324b
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,2 +1,42 @@
dotnet restore
dotnet build -c Release
Set-StrictMode -Version latest
$ErrorActionPreference = "Stop"


# Taken from psake https://github.com/psake/psake

<#
.SYNOPSIS
This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode
to see if an error occcured. If an error is detected then an exception is thrown.
This function allows you to run command-line programs without having to
explicitly check the $lastexitcode variable.
.EXAMPLE
exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed"
#>
function Exec
{
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)][scriptblock]$cmd,
[Parameter(Position=1,Mandatory=0)][string]$errorMessage = ("Error executing command {0}" -f $cmd)
)
& $cmd
if ($lastexitcode -ne 0) {
throw ("Exec: " + $errorMessage)
}
}

$config = "release"

Exec { dotnet restore }

Exec { dotnet build --configuration $config --no-restore }

Get-ChildItem .\**\*.csproj -Recurse | Where-Object { $_.Name -match ".*Test(s)?.csproj$"} | ForEach-Object {
Exec { dotnet test $_.FullName --configuration $config --no-build --no-restore }
}

if (Get-Command "Push-AppveyorArtifact" -errorAction SilentlyContinue)
{
Get-ChildItem .\*\bin\$config\*.nupkg -Recurse | ForEach-Object { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
}

0 comments on commit 7b5324b

Please sign in to comment.