-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdefault.ps1
More file actions
65 lines (53 loc) · 2 KB
/
default.ps1
File metadata and controls
65 lines (53 loc) · 2 KB
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
Properties {
$projects = $null
$configuration = "Release"
$source_folder = $null
$solution = $null
$build_meta = $null
}
Task Default -Depends Build
Task Publish -Depends Package {
$version = getVersionBase
foreach($project in $projects) {
Get-ChildItem | Where-Object -FilterScript {
($_.Name.Contains("$project.$version")) -and !($_.Name.Contains(".symbols")) -and ($_.Extension -eq '.nupkg')
} | ForEach-Object {
exec { nuget push $_.FullName }
}
}
}
Task Package -Depends Test {
foreach($project in $projects) {
Get-ChildItem -Path "$project\*.csproj" | ForEach-Object {
exec { nuget pack -sym $_.FullName -Prop Configuration=$configuration }
}
}
}
Task Test -Depends Build {
Get-ChildItem $source_folder -Recurse -Include *Tests.csproj | % {
Exec { & ".\packages\xunit.runners.1.9.2\tools\xunit.console.clr4.exe" "$($_.DirectoryName)\bin\$configuration\$($_.BaseName).dll" /noshadow }
}
}
Task Build -Depends Clean,Set-Versions {
Exec { msbuild "$solution" /t:Build /p:Configuration=$configuration }
}
Task Clean {
Exec { msbuild "$solution" /t:Clean /p:Configuration=$configuration }
}
Task Set-Versions {
$version = getVersionBase
if ($build_meta) {
"##teamcity[buildNumber '$version+$build_meta']" | Write-Host
} else {
"##teamcity[buildNumber '$version']" | Write-Host
}
Get-ChildItem -Recurse -Force | Where-Object { $_.Name -eq "AssemblyInfo.cs" } | ForEach-Object {
(Get-Content $_.FullName) | ForEach-Object {
($_ -replace 'AssemblyVersion\(.*\)', ('AssemblyVersion("' + $version + '")')) -replace 'AssemblyFileVersion\(.*\)', ('AssemblyFileVersion("' + $version + '")')
} | Set-Content $_.FullName -Encoding UTF8
}
}
function getVersionBase {
$versionInfo = (Get-Content "version.json") -join "`n" | ConvertFrom-Json
"$($versionInfo.major).$($versionInfo.minor).$($versionInfo.patch)";
}