-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
126 lines (101 loc) · 2.72 KB
/
Rakefile
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
require "albacore"
require "fileutils"
require "centroid"
Config = Centroid::Config.from_file "config.json"
ROOT = File.expand_path "."
desc "Install NuGet dependencies"
task :install do
Config.packages.configs.each do |file|
nuget "install #{file}"
end
end
desc "Run tests"
task :default => :test
namespace :build do
desc "Build for debugging"
build :debug do |b|
b.sln = Config.build.solution
b.prop "Configuration", "Debug"
b.logging = "minimal"
end
desc "Build for release"
build :release do |b|
b.sln = Config.build.solution
b.prop "Configuration", "Release"
b.logging = "minimal"
end
end
desc "Run tests"
test_runner :test => ["build:debug", "clean:test"] do |tr|
tr.exe = Config.tools.nunit
tr.files = [Config.test.dll]
tr.add_parameter "-xml=#{File.join(ROOT, Config.test.results)}"
end
namespace :clean do
desc "Clean all output"
task :all => ["clean:test", "clean:release"]
desc "Clean test output"
task :test do
clean Config.test.output
end
desc "Clean release output"
task :release do
clean Config.release.output.prep
clean release_lib
clean release_tools
clean Config.release.output.pack
end
end
namespace :release do
desc "Pack NuGet package"
task :pack => ["build:release", "clean:release"] do
FileUtils.cp Config.release.nuspec, release_nuspec
Config.release.lib.each do |lib|
FileUtils.cp lib, release_lib
end unless Config.send(:actual_key, "lib", Config.release.raw_config).nil?
Config.release.tools.each do |tool|
FileUtils.cp tool, release_tools
end unless Config.send(:actual_key, "tools", Config.release.raw_config).nil?
nuget "pack #{release_nuspec} -OutputDirectory #{Config.release.output.pack}"
end
desc "Push NuGet package"
task :push do
puts "Pushing #{release_nupkg}"
nuget "push #{release_nupkg}"
end
end
desc "Pack and push NuGet package"
task :release => ["release:pack", "release:push"]
class Tools
include ::Albacore::CrossPlatformCmd
def initialize(executable)
@parameters = []
@executable = executable
mono_command
end
def execute(parameters)
parameters = parameters.split " "
@parameters.push *parameters
system @executable, *(@parameters)
end
end
def nuget(command)
Tools.new(Config.tools.nuget).execute "#{command}"
end
def clean(dir)
FileUtils.rm_rf dir
FileUtils.mkdir_p dir
end
def release_lib
File.join Config.release.output.prep, "lib"
end
def release_tools
File.join Config.release.output.prep, "tools"
end
def release_nuspec
File.join Config.release.output.prep, File.basename(Config.release.nuspec)
end
def release_nupkg
pattern = File.join Config.release.output.pack, Config.release.nupkg_pattern
Dir[pattern].first
end