diff --git a/Build.ps1 b/Build.ps1 index 1045a94..1289143 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -1,9 +1,3 @@ -function Test-Project -{ - param([string] $DirectoryName) - & dotnet test -c Release ("""" + $DirectoryName + """") -} - # Taken from psake https://github.com/psake/psake <# @@ -27,39 +21,15 @@ function Exec throw ("Exec: " + $errorMessage) } } -######################## -# THE BUILD! -######################## - -Push-Location $PSScriptRoot -if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse } +$artifacts = ".\artifacts" -$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL]; -$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; -$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"] -$commitHash = $(git rev-parse --short HEAD) -$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""] -$versionSuffix = @{ $true = "--version-suffix=$($suffix)"; $false = ""}[$suffix -ne ""] +if(Test-Path $artifacts) { Remove-Item $artifacts -Force -Recurse } -echo "build: Package version suffix is $suffix" -echo "build: Build version suffix is $buildSuffix" - -exec { dotnet build -c Release --version-suffix=$buildSuffix -v q /nologo } +exec { & dotnet clean -c Release } -foreach ($test in ls test/*.Tests) { - Push-Location $test - - echo "build: Testing project in $test" - - try { - & dotnet test -c Release --no-build --no-restore - if($LASTEXITCODE -ne 0) { exit 3 } - } finally { - Pop-Location - } -} +exec { & dotnet build -c Release } -exec { dotnet pack .\src\MediatR.Extensions.Microsoft.DependencyInjection -c Release -o ..\..\artifacts --include-symbols --no-build $versionSuffix } +exec { & dotnet test -c Release -r $artifacts --no-build -l trx --verbosity=normal } -Pop-Location +exec { dotnet pack .\src\MediatR.Extensions.Microsoft.DependencyInjection -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }