-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile.rb
155 lines (134 loc) · 6.11 KB
/
Rakefile.rb
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#Habanero.Testability
require "./rake-tasks/init"
#______________________________________________________________________________
#---------------------------------SETTINGS-------------------------------------
$binaries_baselocation = "bin"
$nuget_baselocation = "nugetArtifacts"
$app_version ='9.9.9.999'
#------------------------build settings--------------------------
msbuild_settings = {
:properties => {:configuration => :release},
:targets => [:clean, :rebuild],
:verbosity => :minimal,
#:use => :net35 ;uncomment to use .net 3.5 - default is 4.0
}
#------------------------dependency settings---------------------
#------------------------project settings------------------------
$solution = 'source/Habanero.Testability - 2010.sln'
$solutionNuget = '"source/Habanero.Testability - 2010.sln"'
$major_version = ''
$minor_version = ''
$patch_version = ''
$nuget_apikey = ''
$nuget_sourceurl = ''
$nuget_publish_version = 'Trunk'
#______________________________________________________________________________
#---------------------------------TASKS----------------------------------------
desc "Runs the build all task"
task :default, [:major, :minor, :patch] => [:setupvars, :build]
desc "Pulls habanero deps from local nuget, builds, tests and pushes testability"
task :build_test_push_internal, [:major, :minor, :patch, :apikey, :sourceurl] => [:build_internal, :nugetpush]
desc "Pulls habanero deps from local nuget, builds and tests"
task :build_internal, [:major, :minor, :patch, :sourceurl] => [:setupvars, :installNugetPackages, :build]
desc "Builds Testability, including tests"
task :build, [:major, :minor, :patch] => [:clean, :update_packages, :set_assembly_version, :msbuild, :copy_to_nuget, :test]
#------------------------Setup Versions---------
desc "Setup Variables"
task :setupvars, :major, :minor, :patch, :apikey, :sourceurl do |t, args|
puts cyan("Setup Variables")
args.with_defaults(:major => "0")
args.with_defaults(:minor => "0")
args.with_defaults(:patch => "0000")
args.with_defaults(:apikey => "")
args.with_defaults(:sourceurl => "")
$major_version = "#{args[:major]}"
$minor_version = "#{args[:minor]}"
$patch_version = "#{args[:patch]}"
$nuget_apikey = "#{args[:apikey]}"
$nuget_sourceurl = "#{args[:sourceurl]}"
$app_version = "#{$major_version}.#{$minor_version}.#{$patch_version}.0"
puts cyan("Assembly Version #{$app_version}")
puts cyan("Nuget key: #{$nuget_apikey} for: #{$nuget_sourceurl}")
end
desc "Updates packages with nuget"
updatenugetpackages :update_packages do |nuget|
puts cyan("Updating nuget packages")
nuget.solution = $solutionNuget
end
task :set_assembly_version do
puts green("Setting Shared AssemblyVersion to: #{$app_version}")
file_path = "source/Common/AssemblyInfoShared.cs"
outdata = File.open(file_path).read.gsub(/"9.9.9.999"/, "\"#{$app_version}\"")
File.open(file_path, 'w') do |out|
out << outdata
end
end
#------------------------build Testability--------------------
desc "Cleans the bin folder"
task :clean do
puts cyan("Cleaning bin folder")
FileUtils.rm_rf 'bin'
FileUtils.rm_rf $nuget_baselocation
end
desc "Builds the solution with msbuild"
msbuild :msbuild do |msb|
puts cyan("Building #{$solution} with msbuild")
msb.update_attributes msbuild_settings
msb.solution = $solution
end
desc "Runs the tests"
nunit :test do |nunit|
puts cyan("Running tests")
nunit.assemblies 'bin\Habanero.Testability.Tests.dll',
'bin\Habanero.Testability.Testers.Tests.dll'
end
def copy_nuget_files_to location
FileSystem.ensure_dir_exists "#{location}/"
FileUtils.cp "#{$binaries_baselocation}/Habanero.Testability.dll", location
FileUtils.cp "#{$binaries_baselocation}/Habanero.Testability.Helpers.dll", location
FileUtils.cp "#{$binaries_baselocation}/Habanero.Testability.Testers.dll", location
end
task :copy_to_nuget do
puts cyan("Copying files to the nuget folder")
copy_nuget_files_to $nuget_baselocation
end
desc "Install nuget packages"
getnugetpackages :installNugetPackages do |ip|
puts cyan("Install local nuget packages, Version : #{$nuget_publish_version}")
ip.package_names = ["Habanero.Base.#{$nuget_publish_version}",
"Habanero.BO.#{$nuget_publish_version}",
"Habanero.Smooth.#{$nuget_publish_version}"]
ip.SourceUrl = "#{$nuget_sourceurl}/nuget"
ip.Version = $app_version
end
desc "Pushes Testability to Nuget"
task :nugetpush => [:publishTestabilityNugetPackage,
:publishTestabilityHelpersNugetPackage,
:publishTestabilityTestersNugetPackage ]
desc "Publish the Habanero.Testability nuget package"
pushnugetpackagesonline :publishTestabilityNugetPackage do |package|
package.InputFileWithPath = "bin/Habanero.Testability.dll"
package.Nugetid = "Habanero.Testability.#{$nuget_publish_version}"
package.Version = $app_version
package.Description = "Testability"
package.ApiKey = "#{$nuget_apikey}"
package.SourceUrl = "#{$nuget_sourceurl}"
end
desc "Publish the Habanero.Testability.Helpers nuget package"
pushnugetpackagesonline :publishTestabilityHelpersNugetPackage do |package|
package.InputFileWithPath = "bin/Habanero.Testability.Helpers.dll"
package.Nugetid = "Habanero.Testability.Helpers.#{$nuget_publish_version}"
package.Version = $app_version
package.Description = "Habanero.Testability.Helpers"
package.ApiKey = "#{$nuget_apikey}"
package.SourceUrl = "#{$nuget_sourceurl}"
end
desc "Publish the Habanero.Testability.Testers nuget package"
pushnugetpackagesonline :publishTestabilityTestersNugetPackage do |package|
package.InputFileWithPath = "bin/Habanero.Testability.Testers.dll"
package.Nugetid = "Habanero.Testability.Testers.#{$nuget_publish_version}"
package.Version = $app_version
package.Description = "Habanero.Testability.Testers"
package.ApiKey = "#{$nuget_apikey}"
package.SourceUrl = "#{$nuget_sourceurl}"
end