@@ -2,25 +2,31 @@ require 'rubygems'
2
2
require 'albacore'
3
3
4
4
load 'support/platform.rb'
5
- load 'support/buildUtils.rb'
6
5
load 'VERSION.txt'
7
6
8
7
ROOT_NAMESPACE = 'Fleck'
9
8
RESULTS_DIR = 'build/test-reports'
10
9
PRODUCT = ROOT_NAMESPACE
11
10
COPYRIGHT = 'Copyright Jason Staten 2010-2011. All rights reserved.' ;
12
11
COMMON_ASSEMBLY_INFO = 'src/CommonAssemblyInfo.cs' ;
13
- CLR_VERSION = 'v4.0'
14
12
COMPILE_TARGET = 'Debug'
13
+ COMPILE_PLATFORM = 'Any CPU'
15
14
CLR_TOOLS_VERSION = 'v4.0.30319'
15
+ BUILD_RUNNER = Platform . nix? ? 'xbuild' : 'msbuild'
16
16
17
17
props = { :archive => 'artifacts' , :stage => 'stage' }
18
18
19
+
19
20
desc 'Compiles and runs unit tests'
20
21
task :all => [ :default ]
21
22
22
- desc '**Default**, compiles and runs tests'
23
- task :default => [ :compile , :test ]
23
+ desc 'Compiles and runs tests'
24
+ task :default => [ :build , :test ]
25
+
26
+ desc 'Build application'
27
+ task :build => [ :clean , :version , :compile ] do
28
+ copyOutputFiles "src/#{ ROOT_NAMESPACE } /bin/#{ COMPILE_TARGET } " , "*.{dll,pdb}" , props [ :archive ]
29
+ end
24
30
25
31
desc 'Update the version information for the build'
26
32
assemblyinfo :version do |asm |
50
56
51
57
desc 'Prepares the working directory for a new build'
52
58
task :clean do
53
- puts ( 'recreating the build directory' )
59
+ Rake ::Task [ "clean:#{ BUILD_RUNNER } " ] . execute
60
+ buildDir = props [ :archive ]
61
+ rm_r buildDir if Dir . exists? ( buildDir )
62
+ rm_r RESULTS_DIR if Dir . exists? ( RESULTS_DIR )
63
+ mkdir_p buildDir
64
+ mkdir_p RESULTS_DIR
65
+ end
66
+
67
+ namespace :clean do
68
+ msbuild :msbuild do |msb |
69
+ clean_solution ( msb )
70
+ end
71
+ xbuild :xbuild do |xb |
72
+ clean_solution ( xb )
73
+ end
74
+
75
+ def clean_solution ( command )
76
+ command . targets :Clean
77
+ command . solution = "src/#{ ROOT_NAMESPACE } .sln"
78
+ command . properties = {
79
+ :configuration => COMPILE_TARGET ,
80
+ :platform => COMPILE_PLATFORM
81
+ }
82
+ end
83
+ end
84
+
85
+ desc 'Prepares the working directory for a new build'
86
+ task :clean do
87
+ Rake ::Task [ "clean:#{ BUILD_RUNNER } " ] . execute
54
88
buildDir = props [ :archive ]
55
89
rm_r buildDir if Dir . exists? ( buildDir )
56
90
rm_r RESULTS_DIR if Dir . exists? ( RESULTS_DIR )
@@ -59,23 +93,36 @@ task :clean do
59
93
end
60
94
61
95
desc 'Compiles the app'
62
- task :compile => [ :clean , :version ] do
63
- MSBuildRunner . compile :compilemode => COMPILE_TARGET ,
64
- :solutionfile => "src/#{ ROOT_NAMESPACE } .sln" ,
65
- :clrversion => CLR_TOOLS_VERSION
66
- copyOutputFiles "src/#{ ROOT_NAMESPACE } /bin/#{ COMPILE_TARGET } " , "*.{dll,pdb}" , props [ :archive ]
96
+ task :compile do
97
+ Rake ::Task [ "compile:#{ BUILD_RUNNER } " ] . execute
67
98
end
68
99
69
- desc 'Runs unit tests'
70
- task :test do
71
- runner = NUnitRunner . new :compilemode => COMPILE_TARGET ,
72
- :source => 'src' ,
73
- :platform => 'x86' ,
74
- :results => RESULTS_DIR
100
+ namespace :compile do
101
+ msbuild :msbuild do |msb |
102
+ compile_solution ( msb )
103
+ end
104
+ xbuild :xbuild do |xb |
105
+ compile_solution ( xb )
106
+ end
107
+
108
+ def compile_solution ( command )
109
+ command . solution = "src/#{ ROOT_NAMESPACE } .sln"
110
+ command . properties = {
111
+ :configuration => COMPILE_TARGET ,
112
+ :platform => COMPILE_PLATFORM
113
+ }
114
+ end
115
+ end
116
+
117
+ task :test do |nunit |
118
+ runner = Dir [ '**/nunit-console.exe' ] . first
119
+ raise "nunit-console.exe not found" if runner . nil?
120
+ assemblies = Dir [ "**/#{ COMPILE_TARGET } /*.Tests.dll" ] . reject { |a |a =~ /\/ obj\/ / }
75
121
76
- runner . executeTests [ 'Fleck.Tests' ]
122
+ sh " #{ Platform . runtime ( runner ) } #{ assemblies . join } "
77
123
end
78
124
79
125
def copyOutputFiles ( fromDir , filePattern , outDir )
80
126
copy Dir [ File . join ( fromDir , filePattern ) ] , outDir
81
127
end
128
+
0 commit comments