-
Notifications
You must be signed in to change notification settings - Fork 15
/
rakefile.rb
137 lines (114 loc) · 4.43 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
require File.join(File.dirname(__FILE__), 'libs/albacore/albacore.rb')
def get_version_from_file
file = File.new('VERSION','r')
return file.gets.chomp
end
BASE_VERSION = get_version_from_file
CONFIGURATION = :Release
ROOT_DIR = File.dirname(__FILE__) + "/"
SRC_PATH = ROOT_DIR + "src/"
LIBS_PATH = ROOT_DIR + "libs/"
OUTPUT_PATH = ROOT_DIR + "bin/"
DIST_PATH = ROOT_DIR + "dist/"
TEST_OUTPUT_PATH = ROOT_DIR + "bin/Tests/"
XUNIT32_CONSOLE_PATH = LIBS_PATH + "xunit-1.6.1/xunit.console.clr4.x86.exe"
DOTNET_VERSION = :net40
CI_BUILD_NUMBER_PARAM_NAME = 'BUILD_NUMBER'
begin
gitcommit = `git log -1 --pretty=format:%H`
rescue
gitcommit = "nogit"
end
NIGHTLY = ENV['NIGHTLY'].nil? ? 'true' : ENV['NIGHTLY'].downcase
CI_BUILD_NUMBER = ENV[CI_BUILD_NUMBER_PARAM_NAME] || 0
if ENV[CI_BUILD_NUMBER_PARAM_NAME] == nil || NIGHTLY == 'true' then
# if we are not running under teamcity or someother CI like hudson.
# or if nightly is true.
# generate the version number based on VERSION file.
VERSION_NO = "#{BASE_VERSION}.#{CI_BUILD_NUMBER}"
else
# if we are running inside teamcity, then it passes the full version
# so ignore the VERSION file and overwrite the VERSION_NO and VERSION_LONG
VERSION_NO = ENV['BUILD_NUMBER']
end
if NIGHTLY == 'true' then
VERSION_LONG = "#{VERSION_NO}-nightly-#{gitcommit[0..5]}"
else
VERSION_LONG = "#{VERSION_NO}-#{gitcommit[0..5]}"
end
puts
puts "Base Version: #{BASE_VERSION}"
puts "Version Number: #{VERSION_NO} : #{VERSION_LONG} "
print "CI Build Number: "
print CI_BUILD_NUMBER
print " (not running under CI mode)" if CI_BUILD_NUMBER == 0
puts
puts "Git Commit Hash: #{gitcommit}"
puts
task :default => :full
task :full => [:build_release,:test,:precompile_samples_webapplication,:package_binaries]
desc "Run Tests"
task :test => [:main_test]
desc "Prepare build"
task :prepare => [:clean] do
mkdir OUTPUT_PATH unless File.exists?(OUTPUT_PATH)
mkdir DIST_PATH unless File.exists?(DIST_PATH)
mkdir TEST_OUTPUT_PATH unless File.exists?(TEST_OUTPUT_PATH)
cp "LICENSE.txt", OUTPUT_PATH
cp "README.md" , OUTPUT_PATH
cp LIBS_PATH + "RestSharp/RestSharp.License.txt", OUTPUT_PATH
cp LIBS_PATH + "RestSharp/Newtonsoft.Json.License.txt", OUTPUT_PATH
end
desc "Clean build outputs"
task :clean => [:clean_msbuild] do
FileUtils.rm_rf OUTPUT_PATH
FileUtils.rm_rf DIST_PATH
end
desc "Clean solution outputs"
msbuild :clean_msbuild do |msb|
msb.properties :configuration => CONFIGURATION
msb.solution = SRC_PATH + "FacebookSharp.sln"
msb.targets :Clean
end
desc "Build solution (default)"
msbuild :build_release => [:prepare] do |msb|
msb.properties :configuration => CONFIGURATION
msb.solution = SRC_PATH + "FacebookSharp.sln"
msb.targets :Build
end
desc "Create a zip package for the release binaries"
zip :package_binaries => [:build_release] do |zip|
zip.directories_to_zip OUTPUT_PATH
zip.output_file = "FacebookSharp-#{VERSION_LONG}-bin.zip"
zip.output_path = DIST_PATH
end
desc "Create a source package (requires git in PATH)"
task :package_source do
mkdir DIST_PATH unless File.exists?(DIST_PATH)
sh "git archive HEAD --format=zip > dist/FacebookSharp-#{VERSION_LONG}-src.zip"
end
xunit :main_test => [:build_release] do |xunit|
xunit.command = XUNIT32_CONSOLE_PATH
xunit.assembly = SRC_PATH + "Tests/FacebookSharp.Tests/bin/Release/FacebookSharp.Tests.dll"
xunit.html_output = TEST_OUTPUT_PATH
xunit.options '/nunit ' + TEST_OUTPUT_PATH + 'FacebookSharp.Tests.nUnit.xml', '/xml ' + TEST_OUTPUT_PATH + 'FacebookSharp.Tests.xUnit.xml'
end
aspnetcompiler :precompile_samples_webapplication_task => [:build_release] do |c|
c.physical_path = "src/Samples/FacebookSharp.Samples.WebApplication"
c.target_path = "bin/Samples/FacebookSharp.Samples.WebApplication"
c.updateable = true
c.force = true
end
task :precompile_samples_webapplication => [:build_release,:precompile_samples_webapplication_task] do
root_path = OUTPUT_PATH + 'Samples/FacebookSharp.Samples.WebApplication/'
files_to_remove =
[root_path + 'FacebookSharp.Samples.WebApplication.csproj',
root_path + 'FacebookSharp.Samples.WebApplication.csproj.user']
files_to_remove.each{|file| File.delete(file) if File.exist?(file)}
FileUtils.rm_rf root_path + 'obj'
FileUtils.rm_rf root_path + 'Properties'
end
def dotnet_path
include Configuration::NetVersion
return get_net_version DOTNET_VERSION
end