This repository has been archived by the owner on May 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.ps1
117 lines (96 loc) · 3.49 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
110
111
112
113
114
115
116
117
Properties {
### Directories
$base_directory = resolve-path .
$src_directory = "$base_directory\src"
$output_directory = "$base_directory\build"
$dist_directory = "$base_directory\distribution"
$tests_dir = "$base_directory\src\tests"
$package_dir = "$base_directory\packages"
### Tools
$nuget = "$base_directory\.nuget\nuget.exe"
$nunit = "$package_dir\nunit.runners*\tools\nunit-console.exe"
### AppVeyor-related
$appVeyorConfig = "$base_directory\appveyor.yml"
$appVeyor = $env:APPVEYOR
### Project information
$solution = "Hepsi.Http.Client.sln"
$sln_file = "$base_directory\$solution"
$target_config = "Release"
### Build information
$buildNumber = 0;
$version = "1.0.1.0"
$preRelease = $null
}
## Tasks
Task default -Depends Clean, RunUnitTests, RunApiTests, CreateNuGetPackage
Task appVeyor -Depends Clean, CreateNuGetPackage
Task Restore {
"Restoring NuGet packages for '$solution'..."
Exec { .$nuget restore $solution }
}
Task Clean {
rmdir $output_directory -ea SilentlyContinue -recurse
rmdir $dist_directory -ea SilentlyContinue -recurse
exec { msbuild /nologo /verbosity:quiet $sln_file /p:Configuration=$target_config /t:Clean /p:Outdir="$output_directory" }
}
task UpdateVersion {
"Updating version number..."
$vSplit = $version.Split('.')
if($vSplit.Length -ne 4)
{
throw "Version number is invalid. Must be in the form of 0.0.0.0"
}
$major = $vSplit[0]
$minor = $vSplit[1]
$patch = $vSplit[2]
$assemblyFileVersion = "$major.$minor.$patch.$buildNumber"
$assemblyVersion = "$major.$minor.$patch.$buildNumber"
$versionAssemblyInfoFile = "$src_directory/Shared/VersionAssemblyInfo.cs"
"using System.Reflection;" > $versionAssemblyInfoFile
"" >> $versionAssemblyInfoFile
"[assembly: AssemblyVersion(""$assemblyVersion"")]" >> $versionAssemblyInfoFile
"[assembly: AssemblyFileVersion(""$assemblyFileVersion"")]" >> $versionAssemblyInfoFile
}
Task Compile -Depends UpdateVersion {
"Compiling '$solution'..."
exec { msbuild /nologo /verbosity:q $sln_file /p:Configuration=$target_config /p:TargetFrameworkVersion=v4.5 /p:Outdir="$output_directory" }
}
Task RunUnitTests -Depends Compile {
"Runing Unit Tests for '$solution'..."
$project = "Hepsi.Http.Client.UnitTests"
.$nunit "$output_directory\$project.dll" /noxml
if (!$?) {
exit 1
}
}
Task RunApiTests -Depends Compile {
"Runing Unit Tests for '$solution'..."
$project = "Hepsi.Http.Client.ApiTests"
.$nunit "$output_directory\$project.dll" /noxml
if (!$?) {
exit 1
}
}
Task CreateNuGetPackage -Depends Compile {
"Creating nuget package..."
$vSplit = $version.Split('.')
if($vSplit.Length -ne 4)
{
throw "Version number is invalid. Must be in the form of 0.0.0.0"
}
$major = $vSplit[0]
$minor = $vSplit[1]
$patch = $vSplit[2]
$packageVersion = "$major.$minor.$patch"
if($preRelease){
$packageVersion = "$packageVersion-$preRelease"
}
if ($buildNumber -ne 0){
$packageVersion = $packageVersion + "-build" + $buildNumber.ToString().PadLeft(5,'0')
}
mkdir $dist_directory -ea SilentlyContinue
copy-item $src_directory\Hepsi.Http.Client\Hepsi.Http.Client.nuspec $dist_directory
copy-item $src_directory\Hepsi.Http.Client.Testing\Hepsi.Http.Client.Testing.nuspec $dist_directory
exec { . $nuget pack $dist_directory\Hepsi.Http.Client.nuspec -BasePath $dist_directory -o $dist_directory -version $packageVersion }
exec { . $nuget pack $dist_directory\Hepsi.Http.Client.Testing.nuspec -BasePath $dist_directory -o $dist_directory -version $packageVersion }
}