-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.ps1
61 lines (53 loc) · 1.94 KB
/
common.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
Import-Module .\Build\psake-contrib\teamcity.psm1
properties {
$BaseDir = Resolve-Path ".\"
$SolutionFile = Resolve-Path $BaseDir\*.sln
$OutputDir = "$BaseDir\Out\"
$NuGetOutputDir = "$OutputDir\NuGet\"
$TestAssemblies= @("*.Tests.Unit.dll","*.Tests.Integration.dll","*.Tests.dll")
$NUnitPath = "$BaseDir\packages\NUnit.*\tools\nunit-console.exe"
$NuGetPath = "$BaseDir\packages\NuGet.Commandline.*\tools\NuGet.exe"
}
$framework = '4.0'
task default -depends Build
task Init {
Write-Host $BaseDir
}
task Clean -depends Init {
Remove-Item $OutputDir -recurse -force -ErrorAction SilentlyContinue -WhatIf:$Whatif
Remove-Item $NuGetOutputDir -recurse -force -ErrorAction SilentlyContinue -WhatIf:$Whatif
exec { msbuild /target:Clean /verbosity:minimal "$SolutionFile" }
}
task Build -depends Clean{
exec { msbuild /nologo /verbosity:minimal "$SolutionFile" "/p:OutDir=$OutputDir" }
}
task Test -depends Build {
$Tests = (Get-ChildItem "$OutputDir" -Recurse -Include $TestAssemblies)
$NUnit = Resolve-Path $NUnitPath
if(!$NUnit){
throw "Could not find package NUnit at $NUnitPath, install with Install-Package NUnit"
}
if($Tests){
TeamCity-TestSuiteStarted "Started a test suite"
$old = pwd
cd $OutputDir
exec { & $NUnit /nologo $Tests }
cd $old
TeamCity-TestSuiteFinished "Finished a test suite"
}else{
Write-Host "Nothing to test ($TestAssemblies)"
}
}
task PackNuget {
Remove-Item $NuGetOutputDir -recurse -force -ErrorAction SilentlyContinue
New-Item $NuGetOutputDir -ItemType directory | out-null
$NuGet = Resolve-Path $NuGetPath
if(!$NuGet){
throw "Could not find package NuGet.CommandLine at $NuGetPath, install with Install-Package NuGet.CommandLine"
}
$specs = (Get-ChildItem "$BaseDir" -Recurse -Include "*.nuspec")
foreach ($spec in $specs){
$project = $spec.FullName.Replace("nuspec", "csproj")
exec { & $NuGet pack $project -Build -Symbols -OutputDirectory $NuGetOutputDir -Properties Configuration=Release}
}
}