forked from AutoMapper/AutoMapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.ps1
94 lines (76 loc) · 3.08 KB
/
default.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Framework '4.5.1x86'
properties {
$base_dir = resolve-path .
$build_dir = "$base_dir\build"
$source_dir = "$base_dir\src"
$result_dir = "$build_dir\results"
$global:config = "debug"
}
task default -depends local
task local -depends init, compile, test
task ci -depends clean, release, local, benchmark
task clean {
rd "$source_dir\artifacts" -recurse -force -ErrorAction SilentlyContinue | out-null
rd "$base_dir\build" -recurse -force -ErrorAction SilentlyContinue | out-null
}
task init {
# Make sure per-user dotnet is installed
Install-Dotnet
}
task release {
$global:config = "release"
}
task compile -depends clean {
$version = if ($env:APPVEYOR_BUILD_NUMBER -ne $NULL) { $env:APPVEYOR_BUILD_NUMBER } else { '0' }
exec { dotnet restore $source_dir\AutoMapper }
exec { dotnet build $source_dir\AutoMapper -c $config }
exec { dotnet pack $source_dir\AutoMapper -c $config --version-suffix $version}
exec { & $source_dir\.nuget\Nuget.exe restore $source_dir\AutoMapper.NoProjectJson.sln }
exec { msbuild /t:Clean /t:Build /p:Configuration=$config /v:q /p:NoWarn=1591 /nologo $source_dir\AutoMapper.NoProjectJson.sln }
}
task benchmark {
exec { & $source_dir\Benchmark\bin\$config\Benchmark.exe }
}
task test {
$testRunners = @(gci $source_dir\packages -rec -filter Fixie.Console.exe)
if ($testRunners.Length -ne 1)
{
throw "Expected to find 1 Fixie.Console.exe, but found $($testRunners.Length)."
}
$testRunner = $testRunners[0].FullName
exec { & $testRunner $source_dir/UnitTests/bin/$config/AutoMapper.UnitTests.Net4.dll }
exec { & $testRunner $source_dir/UnitTests.Portable/bin/$config/AutoMapper.UnitTests.Portable.dll }
exec { & $testRunner $source_dir/IntegrationTests.Net4/bin/$config/AutoMapper.IntegrationTests.Net4.dll }
}
function Install-Dotnet
{
$dotnetcli = where-is('dotnet')
if($dotnetcli -eq $null)
{
$dotnetPath = "$pwd\.dotnet"
$dotnetCliVersion = if ($env:DOTNET_CLI_VERSION -eq $null) { 'Latest' } else { $env:DOTNET_CLI_VERSION }
$dotnetInstallScriptUrl = 'https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/install.ps1'
$dotnetInstallScriptPath = '.\scripts\obtain\install.ps1'
md -Force ".\scripts\obtain\" | Out-Null
curl $dotnetInstallScriptUrl -OutFile $dotnetInstallScriptPath
& .\scripts\obtain\install.ps1 -Channel "preview" -version $dotnetCliVersion -InstallDir $dotnetPath -NoPath
$env:Path = "$dotnetPath;$env:Path"
}
}
function where-is($command) {
(ls env:\path).Value.split(';') | `
where { $_ } | `
%{ [System.Environment]::ExpandEnvironmentVariables($_) } | `
where { test-path $_ } |`
%{ ls "$_\*" -include *.bat,*.exe,*cmd } | `
%{ $file = $_.Name; `
if($file -and ($file -eq $command -or `
$file -eq ($command + '.exe') -or `
$file -eq ($command + '.bat') -or `
$file -eq ($command + '.cmd'))) `
{ `
$_.FullName `
} `
} | `
select -unique
}