This repository was archived by the owner on Nov 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdefault.ps1
More file actions
128 lines (109 loc) · 4.23 KB
/
default.ps1
File metadata and controls
128 lines (109 loc) · 4.23 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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
if((Get-Module | Where-Object {$_.Name -eq "psake"}) -eq $null)
{
Write-Host "psake module not found, importing it"
$scriptPath = Split-Path $MyInvocation.InvocationName
Import-Module .\tools\psake.4.2.0.1\tools\psake.psm1
}
Import-Module .\tools\SetVersion.psm1
function Get-VersionNumber
{
$completeVersionNumber = ""
$buildNumber = $Env:BUILD_NUMBER
if([string]::IsNullOrEmpty($buildNumber))
{
$completeVersionNumber = $majorMinorVersion + ".*"
}
else
{
#running in TeamCity
$completeVersionNumber = $majorMinorVersion + "." + $buildNumber
}
return ,$completeVersionNumber
}
properties {
$configuration = "Release"
$rootLocation = get-location
$srcRoot = "$rootLocation\src"
$projectBaseName = "ServiceStack.Text.TupleSerializer"
$csprojFile = "$srcRoot\$projectBaseName\$projectBaseName.csproj"
$unitTestNamePart = "UnitTests"
$testDllFileName = "$projectBaseName.$unitTestNamePart.dll"
$testOutputPath = "$srcRoot\$projectBaseName.$unitTestNamePart\bin\$configuration"
$testDll = "$testOutputPath\$testDllFileName"
$ssTextv4Dll = "$rootLocation\tools\ServiceStack.Text.4\lib\net40\ServiceStack.Text.dll"
$ssTextV4TestOutputPath = "$rootLocation\ssTextv4Test"
$ssTextV4TestDllFullPath = "$ssTextV4TestOutputPath\$testDllFileName"
$slnFile = "$srcRoot\$projectBaseName.sln"
$nuspecFile ="$srcRoot\$projectBaseName\$projectBaseName.nuspec"
$framework = "4.0"
$xunitRunner = ".\tools\xunit.runners.1.9.1\tools\xunit.console.clr4.exe"
$nugetOutputDir = ".\ReleasePackages"
$nugetExe = "$rootLocation\tools\nuget\nuget.exe"
$versionFile = ".\MajorMinorVersion.txt"
$majorMinorVersion = Get-Content $versionFile
$completeVersionNumber = Get-VersionNumber
$gitHubRepoUrl = "https://github.com/Chatham/ServiceStack.Text.TupleSerializer"
$versionSwitch = ""
if(!$completeVersionNumber.EndsWith(".*"))
{
#running in TeamCity
$versionSwitch = "-Version $completeVersionNumber"
Write-Host "##teamcity[buildNumber '$completeVersionNumber']"
}
}
task Default -depends Pack
task Clean -depends SetVersion {
exec { msbuild "$slnFile" /t:Clean /p:Configuration=$configuration }
}
task Compile -depends Clean {
exec { msbuild "$slnFile" /p:Configuration=$configuration }
}
task Test -depends Compile {
exec { .$xunitRunner "$testDll" }
}
task TestSsTextV4 -depends Compile {
mkdir -path "$ssTextV4TestOutputPath" -force
cp "$testOutputPath\*.*" "$ssTextV4TestOutputPath"
cp "$ssTextv4Dll" "$ssTextV4TestOutputPath" -force
exec { .$xunitRunner "$ssTextV4TestDllFullPath" }
}
task SetReleaseNotes -depends Test,TestSsTextV4 {
$releaseNotesText = $Env:ReleaseNotes
$vcsNumber = $Env:BUILD_VCS_NUMBER
if(![string]::IsNullOrEmpty($vcsNumber))
{
Write-Host "Found VCS number: $vcsNumber"
$releaseNotesText += [System.Environment]::NewLine + [System.Environment]::NewLine + "Includes changes up to and including: $gitHubRepoUrl/commit/$vcsNumber" + [System.Environment]::NewLine
}
else
{
Write-Host "No VCS number found."
}
if(![string]::IsNullOrEmpty($releaseNotesText))
{
Write-Host "Setting release notes to:"
Write-Host "$releaseNotesText"
$nuspecContents = [Xml](Get-Content "$nuspecFile")
$releaseNotesNode = $nuspecContents.package.metadata.SelectSingleNode("releaseNotes")
if($releaseNotesNode -eq $null)
{
$releaseNotesNode = $nuspecContents.CreateElement('releaseNotes')
$ignore = $nuspecContents.package.metadata.AppendChild($releaseNotesNode)
}
$ignore = $releaseNotesNode.InnerText = $releaseNotesText
$nuspecContents.Save("$nuspecFile")
}
else
{
Write-Host "No release notes added."
}
}
task Pack -depends SetReleaseNotes {
mkdir -path "$nugetOutputDir" -force
$completeVersionNumber = Get-VersionNumber
exec { invoke-expression "& '$nugetExe' pack '$csprojFile' -Symbols -Properties Configuration=$configuration -OutputDirectory '$nugetOutputDir' $versionSwitch" }
}
task SetVersion {
Write-Host "Setting version to $completeVersionNumber"
Set-Version $completeVersionNumber
}