Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Commit

Permalink
Correcting build
Browse files Browse the repository at this point in the history
  • Loading branch information
jbogard committed Jun 25, 2020
1 parent 0038a48 commit 53e29f6
Showing 1 changed file with 6 additions and 36 deletions.
42 changes: 6 additions & 36 deletions Build.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
function Test-Project
{
param([string] $DirectoryName)
& dotnet test -c Release ("""" + $DirectoryName + """")
}

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

<#
Expand All @@ -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 }

0 comments on commit 53e29f6

Please sign in to comment.