forked from machine/machine.specifications
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrakefile.include.rb
111 lines (98 loc) · 3.1 KB
/
rakefile.include.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
desc "Prepares necessary configuration for build"
task :configure do
target = ENV['target'] || 'Debug'
build_config = {
:target => target,
:sign_assembly => ENV.include?('SIGN_ASSEMBLY'),
:out_dir => "Build/#{target}/",
:nunit_framework => "net-3.5",
:mspec_options => (["--teamcity"] if ENV.include?('TEAMCITY_PROJECT_NAME')) || []
}
configatron.solution = Configatron::Delayed.new do
FileList.new("*.sln").to_a[0]
end
configatron.project = Configatron::Delayed.new do
"#{configatron.solution.gsub(".sln", "")}#{'-Signed' if configatron.sign_assembly}"
end
configatron.distribution.dir = Configatron::Delayed.new do
ENV.include?('TEAMCITY_PROJECT_NAME') ? "Distribution/" : "../nugets"
end
configatron.version.full = Configatron::Delayed.new do
`gitflowversion`.scan(/NugetVersion":"(.*)"/)[0][0][0,20]
end
configatron.version.short = Configatron::Delayed.new do
`gitflowversion`.scan(/ShortVersion":"(.*)"/)[0][0]
end
configatron.configure_from_hash build_config
#configatron.protect_all!
puts configatron.inspect
end
desc "Prepares the working directory for a new build"
task :clean do
filesToClean = FileList.new
filesToClean.include('teamcity-info.xml')
filesToClean.include('Source/**/obj')
filesToClean.include('Build')
filesToClean.include('Distribution')
filesToClean.include('Specs')
filesToClean.include('**/*.template')
# Clean template results.
filesToClean.map! do |f|
next f.ext if f.pathmap('%x') == '.template'
f
end
FileUtils.rm_rf filesToClean
Dir.mkdir 'Distribution'
Dir.mkdir 'Specs'
end
task :restore do
nopts = %W(
nuget restore #{configatron.solution}
)
sh(*nopts)
end
desc "Run a simple clean/build"
msbuild :build do |msb|
msb.solution = configatron.solution
msb.targets = [:Clean, :Build]
msb.use :net4
msb.verbosity = :minimal
msb.properties = {
:Configuration => configatron.target,
:TrackFileAccess => false,
:SolutionDir => File.expand_path('.'),
:SignAssembly => configatron.sign_assembly,
:Platform => 'Any CPU'
}
end
desc "Run all nunit tests"
nunit :tests => [:rebuild] do |cmd|
cmd.command = "packages/NUnit.Runners.2.6.3/tools/nunit-console-x86.exe"
cmd.assemblies = FileList.new("#{configatron.out_dir}/Tests/*.Tests.dll").to_a
#cmd.results_path = "Specs/test-report.xml"
#cmd.no_logo
cmd.parameters = [
"/framework=#{configatron.nunit_framework}",
"/nothread",
"/work=Specs"
]
end
task :templates do
#Write teamcity build number
puts "##teamcity[buildNumber '#{configatron.version.short}']"
#Prepare templates
FileList.new('**/*.template').each do |template|
QuickTemplate.new(template).exec(configatron)
end
end
desc "Package build artifacts as a NuGet package and a symbols package"
task :createpackage => [ :default ] do
FileList.new('**/*.nuspec').exclude(/packages/).each do |nuspec|
opts = %W(
nuget pack #{nuspec} -Symbols -Version #{configatron.version.full} -OutputDirectory #{configatron.distribution.dir}
)
sh(*opts) do |ok, status|
ok or fail "Command failed with status (#{status.exitstatus})"
end
end
end