1- Framework ' 4.5.1x86'
2-
3- properties {
4- $base_dir = resolve-path .
5- $source_dir = " $base_dir \src"
6- $result_dir = " $base_dir \results"
7- $artifacts_dir = " $base_dir \artifacts"
8- $global :config = " debug"
9- }
10-
11-
12- task default - depends local
13- task local - depends init, compile, test
14- task ci - depends clean , release, local
15-
16- task clean {
17- Remove-Item " $artifacts_dir " - recurse - force - ErrorAction SilentlyContinue | out-null
18- Remove-Item " $result_dir " - recurse - force - ErrorAction SilentlyContinue | out-null
19- }
20-
21- task init {
22-
23- # Make sure per-user dotnet is installed
24-
25- Install-Dotnet
26- }
27-
28- task release {
29-
30- $global :config = " release"
31-
32- }
33-
34- task compile - depends clean {
35-
36- $tag = $ (git tag - l -- points- at HEAD)
37- $revision = @ { $true = " {0:00000}" -f [convert ]::ToInt32(" 0" + $env: APPVEYOR_BUILD_NUMBER , 10 ); $false = " local" }[$env: APPVEYOR_BUILD_NUMBER -ne $NULL ];
38- $suffix = @ { $true = " " ; $false = " ci-$revision " }[$tag -ne $NULL -and $revision -ne " local" ]
39- $commitHash = $ (git rev- parse -- short HEAD)
40- $buildSuffix = @ { $true = " $ ( $suffix ) -$ ( $commitHash ) " ; $false = " $ ( $branch ) -$ ( $commitHash ) " }[$suffix -ne " " ]
41-
42- $buildParam = @ { $true = " " ; $false = " --version-suffix=$buildSuffix " }[$tag -ne $NULL -and $revision -ne " local" ]
43- $packageParam = @ { $true = " " ; $false = " --version-suffix=$suffix " }[$tag -ne $NULL -and $revision -ne " local" ]
44-
45- Write-Output " build: Tag is $tag "
46- Write-Output " build: Package version suffix is $suffix "
47- Write-Output " build: Build version suffix is $buildSuffix "
48-
49- # restore all project references (creating project.assets.json for each project)
50- exec { dotnet restore $base_dir \AutoMapper.Collection.EFCore.sln / nologo }
51-
52- exec { dotnet build $base_dir \AutoMapper.Collection.EFCore.sln - c $config $buildParam -- no- restore / nologo }
53-
54- exec { dotnet pack $base_dir \AutoMapper.Collection.EFCore.sln - c $config -- include- symbols -- no- build -- no- restore -- output $artifacts_dir $packageParam / nologo}
55-
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+ }
5623}
5724
58- task test {
25+ $artifacts = " .\artifacts "
5926
60- exec { dotnet test $source_dir \AutoMapper.Collection.EntityFrameworkCore.Tests - c $config -- no - build -- no - restore -- results - directory $result_dir -- logger trx / nologo }
27+ if ( Test-Path $artifacts ) { Remove-Item $artifacts - Force - Recurse }
6128
62- }
29+ exec { & dotnet clean - c Release }
6330
64- function Install-Dotnet
65- {
66- $dotnetcli = Get-CommandLocation - command ' dotnet'
31+ exec { & dotnet build - c Release }
6732
68- if ($null -eq $dotnetcli )
69- {
70- $dotnetPath = " $pwd \.dotnet"
71- $dotnetCliVersion = if ($null -eq $env: DOTNET_CLI_VERSION ) { ' Latest' } else { $env: DOTNET_CLI_VERSION }
72- [Net.ServicePointManager ]::SecurityProtocol = [Net.SecurityProtocolType ]::Tls12;
73- & ([scriptblock ]::Create((Invoke-WebRequest - useb ' https://dot.net/v1/dotnet-install.ps1' ))) - Channel " LTS" - version $dotnetCliVersion - InstallDir $dotnetPath - NoPath
74- $env: Path = " $dotnetPath ;$env: Path "
75- }
76- }
33+ exec { & dotnet test - c Release - r $artifacts -- no- build - l trx -- verbosity= normal }
7734
78- function Get-CommandLocation {
79- param ($command )
80- (Get-ChildItem env:\path).Value.split(' ;' ) | `
81- Where-Object { $_ } | `
82- ForEach-Object { [System.Environment ]::ExpandEnvironmentVariables($_ ) } | `
83- Where-Object { test-path $_ } |`
84- ForEach-Object { Get-ChildItem " $_ \*" - include * .bat, * .exe, * .cmd } | `
85- ForEach-Object { $file = $_.Name ; `
86- if ($file -and ($file -eq $command -or `
87- $file -eq ($command + ' .exe' ) -or `
88- $file -eq ($command + ' .bat' ) -or `
89- $file -eq ($command + ' .cmd' ))) `
90- { `
91- $_.FullName `
92- } `
93- } | `
94- Select-Object - unique
95- }
35+ exec { & dotnet pack .\AutoMapper.Collection.EFCore.sln - c Release - o $artifacts -- no- build }
0 commit comments