This repository has been archived by the owner on Nov 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.ps1
109 lines (86 loc) · 4.01 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
properties {
$version = "1.0.0.0"
$versionSeries = $version
$versionInfo = $version
$projectName = "Drey"
$rootDir = Resolve-Path .\
$artifactsDir = "$rootDir\package"
$reportsDir = "$rootDir\reports"
$testDir = "$rootDir\tests"
$sourceDir = "$rootDir\source"
$dotCoverFolder = ""
$configuration = "Release"
}
task default -depends Clean, UpdateVersion, Compile, RunTests, Package
task Clean {
Remove-Item $artifactsDir -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item $reportsDir -Force -Recurse -ErrorAction SilentlyContinue
exec { msbuild Drey.sln /nologo /verbosity:quiet /p:PlatformTarget=AnyCPU /p:Configuration=$configuration /t:Clean }
}
task UpdateVersion {
$assemblyInfoFilePath = "$rootDir\CommonAssemblyInfo.cs";
$tmpFile = $assemblyInfoFilePath + ".tmp";
$newAssemblyVersion = 'AssemblyVersion("' + $versionSeries + '")';
$newAssemblyFileVersion = 'AssemblyFileVersion("' + $version + '")';
$newAssemblyInfoVersion = 'AssemblyInformationalVersion("' + $versionInfo + '")';
# - Keeping these for debugging purposes.
#Write-Host "Assembly Version: $newAssemblyVersion";
#Write-Host "Assembly File Version: $newAssemblyFileVersion";
#Write-Host "Assembly Info Version: $newAssemblyInfoVersion";
Get-Content $assemblyInfoFilePath |
%{$_ -replace 'AssemblyVersion\("(\d+)\.(\d+)(\.(\d+)\.(\d+)|\.*)"\)', $newAssemblyVersion } |
%{$_ -replace 'AssemblyFileVersion\("(\d+)\.(\d+)(\.(\d+)\.(\d+)|\.*)"\)', $newAssemblyFileVersion } |
%{$_ -replace 'AssemblyInformationalVersion\("(\d+)\.(\d+)(\.(\d+)\.(\d+)|\.*)"\)', $newAssemblyInfoVersion } |
Out-File -Encoding UTF8 $tmpFile
Move-Item $tmpFile $assemblyInfoFilePath -force
}
task Compile {
exec { msbuild Drey.sln /nologo /verbosity:quiet /p:PlatformTarget=AnyCPU /p:Configuration=$configuration /p:PackagePath=$artifactsDir /p:Version=$version /t:Rebuild }
}
task RunTests {
if ($dotCoverFolder) {
$dotCover = "$dotCoverFolder\dotCover.exe"
} else {
$dotCover = "$rootDir\..\..\tools\dotCover\dotCover.exe"
}
$xunitRunner = "$rootDir\packages\xunit.runner.console.2.1.0\tools\xunit.console.x86.exe"
Write-Host $dotCover
$dotCoverAvailableForUse = (Test-Path $dotCover)
$allPassed = $true
Get-ChildItem $testDir -Recurse -Include *Tests.csproj, *Tests.*.csproj | % {
$project = $_.BaseName
if(!(Test-Path $reportsDir\xUnit\$project)) {
New-Item $reportsDir\xUnit\$project -Type Directory
}
try {
if ($dotCoverAvailableForUse) {
#dotCover is available - execute tests with coverage
$testAssembly = "$testDir\$project\bin\$configuration\$project.dll"
exec { .$dotCover cover /AnalyseTargetArguments=False /TargetExecutable="$xunitRunner" /TargetArguments="$testAssembly" /Output="$reportsDir\xUnit\$project\$project.dcvr" }
TeamCity-ImportDotNetCoverageResult "dotcover" "$reportsDir\xUnit\$project\$project.dcvr"
} else {
#not teamcity build - just run xunit
exec { .$xunitRunner "$testDir\$project\bin\$configuration\$project.dll" -html "$reportsDir\xUnit\$project\index.html" }
}
} catch {
$allPassed = $false
}
}
if ($allPassed -ne $true) {
Write-Error "One or more tests failed."
}
}
task Package {
if (!(Test-Path $artifactsDir)) {
New-Item $artifactsDir -Type Directory
}
Get-ChildItem "$rootDir" -Recurse -Include *.nuspec -Exclude Drey.nuspec,Drey.Sdk.nuspec | % {
$project = $_.BaseName
$nuspec = $_.FullName
Write-Host "Creating nupkg for: $project"
Write-Host "Project Folder: $projectFolder"
.nuget\nuget.exe pack "$nuspec" -NoDefaultExcludes -NoPackageAnalysis -OutputDirectory "$artifactsDir" -Version "$versionInfo" -Properties "Configuration=$configuration"
}
.nuget\nuget.exe pack ".\source\Drey\Drey.nuspec" -NoDefaultExcludes -NoPackageAnalysis -OutputDirectory "$artifactsDir" -Version "$versionInfo" -Properties "Configuration=$configuration"
.nuget\nuget.exe pack ".\source\Drey\Drey.Sdk.nuspec" -NoDefaultExcludes -NoPackageAnalysis -OutputDirectory "$artifactsDir" -Version "$versionInfo" -Properties "Configuration=$configuration"
}