rakeoff 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,3 +5,5 @@ $: << File.join(root_dir, 'rakeoff', 'tasks')
5
5
  $: << File.join(root_dir, 'rakeoff', 'support')
6
6
 
7
7
  Dir.glob(File.join(root_dir, '**/*.rb')).each {|file| require file }
8
+
9
+ include Terminal
@@ -1,12 +1,13 @@
1
1
  require 'rake'
2
- require 'terminal'
3
2
 
4
3
  class AspnetCompile
5
- def execute(session)
6
- session.solution.projects.select { |project| project.is_webapp }.each do |project|
4
+ def execute(working_dir, framework_version)
5
+ Dir.glob("#{working_dir}/**/Web.config", File::FNM_CASEFOLD).each do |path|
7
6
  print_heading 'Aspnet Compile'
8
- puts "Compiling #{project.name} at #{project.directory}".yellow
9
- sh "%windir%/microsoft.net/framework/#{session.framework_version}/aspnet_compiler.exe -p #{project.directory} -v / -nologo"
7
+
8
+ path = File.dirname(path)
9
+ puts "PreCompiling web project at #{path}".yellow
10
+ sh "%windir%/microsoft.net/framework/#{framework_version}/aspnet_compiler.exe -p #{path} -v / -nologo"
10
11
  end
11
12
  end
12
13
  end
@@ -4,10 +4,27 @@ class Compile
4
4
  def execute(name, session, options)
5
5
  print_heading name
6
6
 
7
+ matches = Dir.glob("#{session.working_dir}/*.sln", File::FNM_CASEFOLD)
8
+
9
+ if matches.empty?
10
+ raise NoSolutionFile, "No *.sln file found in #{session.working_dir}".red
11
+ end
12
+
13
+ if matches.length > 1
14
+ raise MultipleSolutionFiles, "Multiple solution files found at #{session.working_dir}. Don't know which one to build!".red
15
+ end
16
+
17
+ match = matches.first
18
+
7
19
  multi_core = session.framework_version[1,1].to_i > 2 ? '/m' : ''
8
20
  msbuild_path = "%windir%/microsoft.net/framework/#{session.framework_version}/msbuild.exe"
9
21
 
10
- sh "#{msbuild_path} /t:Clean;Build /p:Configuration=#{session.configuration} #{options} /p:TrackFileAccess=false #{multi_core} /consoleloggerparameters:ErrorsOnly #{session.solution.path}"
22
+ sh "#{msbuild_path} /t:Clean;Build /p:Configuration=#{session.configuration} #{options} /p:TrackFileAccess=false #{multi_core} /consoleloggerparameters:ErrorsOnly #{match}"
11
23
  end
12
-
13
24
  end
25
+
26
+ class NoSolutionFile < StandardError
27
+ end
28
+
29
+ class MultipleSolutionFiles < StandardError
30
+ end
@@ -0,0 +1,22 @@
1
+
2
+ class DefaultTasks
3
+ def initialize(session, tools)
4
+ @session = session
5
+ @tools = tools
6
+ end
7
+
8
+ def setup
9
+ @tools.download(@session.tools_dir, @session.tools_download_uri)
10
+
11
+ AspnetCompileTask.new(:aspnetcompile)
12
+ CleanTask.new(:clean)
13
+ TokensTask.new(:tokens)
14
+
15
+ CompileTask.new(:compile, '')
16
+ CompileTask.new(:publish, "/property:OutDir=#{@session.output_dir}/publish/")
17
+
18
+ TestsTask.new(:unit_tests, "**/[b][i][n]/#{@session.configuration}/*.Unit?Tests.dll")
19
+ TestsTask.new(:integration_tests, "**/[b][i][n]/#{@session.configuration}/*.Integration?Tests.dll")
20
+ TestsTask.new(:acceptance_tests, "**/[b][i][n]/#{@session.configuration}/*.Acceptance?Tests.dll")
21
+ end
22
+ end
@@ -1,74 +1,66 @@
1
1
  require 'logging'
2
- require 'solution'
3
2
  require 'terminal'
4
- require 'yaml'
5
3
 
6
4
  class Session
7
5
  include Logging
8
6
 
9
7
  # build options
10
- attr_accessor :agent_name, :is_build_agent, :framework_version, :configuration
8
+ attr_accessor :agent_name, :is_build_agent, :framework_version, :configuration, :environment
11
9
 
12
10
  # directories
13
11
  attr_accessor :working_dir, :tools_dir, :output_dir
14
12
 
15
- attr_accessor :solution, :globals_file, :tokens_pattern
13
+ attr_accessor :globals_file, :tokens_pattern, :tools_download_uri
16
14
 
17
- def set_values
18
- print_heading 'Build Info'
15
+ def initialize(&block)
16
+ block ||= proc {}
19
17
 
20
18
  set_defaults
21
- override_defaults_from_yaml
19
+ instance_eval(&block)
20
+
21
+ correct_windows_paths
22
22
  print_session_info
23
- end
24
-
25
- def load_solution
26
- @solution = Solution.new(@working_dir)
27
- end
23
+ create_tasks
24
+ end
28
25
 
29
26
  private
30
27
 
31
- def set_defaults
28
+ def set_defaults
32
29
  @agent_name = ENV['COMPUTERNAME']
30
+
33
31
  @framework_version = 'v4.0.30319'
34
32
  @configuration = 'Release'
33
+ @environment = ENV['ENVIRONMENT'].nil? ? 'local' : ENV['ENVIRONMENT']
35
34
 
36
35
  @working_dir = Dir.getwd
37
36
  @tools_dir = File.join(@working_dir, '../tools')
38
- @output_dir = File.join(@working_dir + '/_output')
37
+ @output_dir = File.join(@working_dir, '/_output')
39
38
 
40
39
  @globals_file = './Globals.config'
41
40
  @tokens_pattern = '*.master.{^cs}'
42
- end
43
-
44
- def override_defaults_from_yaml
45
- file = File.join(@working_dir, '/rakefile.yml')
46
-
47
- if(!File.exists?(file))
48
- puts "No rakefile.yml found at #{@working_dir}, using defaults...".yellow
49
- return
50
- end
51
-
52
- yaml = YAML.load_file(file)
41
+ @tools_download_uri = 'https://bitbucket.org/robertbeal/rakeoff/downloads/tools.zip'
42
+ end
53
43
 
54
- if yaml.nil?
55
- puts "Unable to read 'rakefile.yml', it may be invalid".yellow
56
- return
57
- end
44
+ def create_tasks
45
+ tasks = DefaultTasks.new(self, Tools.new)
46
+ tasks.setup
47
+ end
58
48
 
59
- yaml.each_key do |variable|
60
- if (self.instance_variable_defined?('@' + variable))
61
- self.instance_variable_set('@' + variable, yaml[variable])
62
- end
63
- end
49
+ def correct_windows_paths
50
+ @working_dir.gsub!('\\', '/')
51
+ @tools_dir.gsub!('\\', '/')
52
+ @output_dir.gsub!('\\', '/')
64
53
  end
65
54
 
66
55
  def print_session_info
56
+ print_heading 'Build Info'
57
+
67
58
  puts "Agent = #{@agent_name}"
68
59
  puts ''
69
60
 
70
- puts "Build Framework = #{@framework_version}"
71
- puts "Build Configuration = #{@configuration}"
61
+ puts "Building For = #{@environment}"
62
+ puts "Framework Version = #{@framework_version}"
63
+ puts "Configuration = #{@configuration}"
72
64
  puts "Token File Pattern = #{@tokens_pattern}"
73
65
  puts "Global Tokens File = #{@globals_file}"
74
66
  puts ''
@@ -14,8 +14,14 @@ module Logging
14
14
  end
15
15
 
16
16
  def configure_logger_for(classname)
17
+ level = Logger::ERROR
18
+
19
+ if(defined?(LOGGING_LEVEL))
20
+ level = LOGGING_LEVEL
21
+ end
22
+
17
23
  logger = Logger.new(STDOUT)
18
- logger.level = LOGGING_LEVEL
24
+ logger.level = level
19
25
  logger.progname = classname
20
26
  logger
21
27
  end
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ require 'term/ansicolor'
3
+ require 'win32console' unless !(RUBY_PLATFORM =~ /mswin32/)
4
+
5
+ class String
6
+ include Term::ANSIColor
7
+ end
8
+
9
+ module Terminal
10
+ def print_heading(message)
11
+ return if message.nil? or message.empty?
12
+
13
+ is_build_agent = !ENV['teamcity.version'].nil?
14
+
15
+ if(is_build_agent)
16
+ puts "##teamcity[progressMessage '#{message}']"
17
+ else
18
+ puts ''
19
+ puts message.cyan
20
+ puts ("#" * (message.length+2)).cyan
21
+ end
22
+ end
23
+ end
24
+
25
+
@@ -0,0 +1,19 @@
1
+ require 'rake'
2
+ include Rake::DSL
3
+ include Logging
4
+
5
+ class Task
6
+ def initialize(name, *args, &body)
7
+ args || args = []
8
+ args.insert 0, name
9
+
10
+ # allows you to define your own overriden tasks
11
+ # hardcoded tasks are added first, then user dynamic ones, then finally rakeoff dynamic ones
12
+ if(Rake::Task.task_defined?(name))
13
+ logger.info 'Unable to overwrite task #{name} as it already exists'.yellow
14
+ return
15
+ end
16
+
17
+ Rake::Task.define_task(*args, &body)
18
+ end
19
+ end
@@ -1,4 +1,4 @@
1
- require 'support/task_helper'
1
+ require 'task'
2
2
  require 'aspnetcompile'
3
3
 
4
4
  class AspnetCompileTask
@@ -8,6 +8,6 @@ class AspnetCompileTask
8
8
  task.execute(SESSION)
9
9
  }
10
10
 
11
- create_task(name, *args, &body)
11
+ Task.new(name, *args, &body)
12
12
  end
13
13
  end
@@ -1,4 +1,4 @@
1
- require 'support/task_helper'
1
+ require 'task'
2
2
  require 'clean'
3
3
 
4
4
  class CleanTask
@@ -8,6 +8,6 @@ class CleanTask
8
8
  task.execute
9
9
  }
10
10
 
11
- create_task(name, *args, &body)
11
+ Task.new(name, *args, &body)
12
12
  end
13
13
  end
@@ -1,4 +1,4 @@
1
- require 'support/task_helper'
1
+ require 'task'
2
2
  require 'compile'
3
3
 
4
4
  class CompileTask
@@ -8,6 +8,6 @@ class CompileTask
8
8
  task.execute(name.to_s.capitalize, SESSION, options)
9
9
  }
10
10
 
11
- create_task(name, *args, &body)
11
+ Task.new(name, *args, &body)
12
12
  end
13
13
  end
@@ -1,4 +1,4 @@
1
- require 'support/task_helper'
1
+ require 'task'
2
2
  require 'robocopy'
3
3
 
4
4
  class RobocopyTask
@@ -8,6 +8,6 @@ class RobocopyTask
8
8
  task.execute(source, destination, parameters)
9
9
  }
10
10
 
11
- create_task(name, *args, &body)
11
+ Task.new(name, *args, &body)
12
12
  end
13
13
  end
@@ -1,4 +1,4 @@
1
- require 'support/task_helper'
1
+ require 'task'
2
2
  require 'tests'
3
3
 
4
4
  class TestsTask
@@ -8,6 +8,6 @@ class TestsTask
8
8
  task.execute(pattern)
9
9
  }
10
10
 
11
- create_task(name, *args, &body)
11
+ Task.new(name, *args, &body)
12
12
  end
13
13
  end
@@ -1,13 +1,13 @@
1
- require 'support/task_helper'
1
+ require 'task'
2
2
  require 'tokens'
3
3
 
4
4
  class TokensTask
5
5
  def initialize(name, *args)
6
6
  body = proc {
7
7
  task = Tokens.new(SESSION.globals_file, SESSION.tokens_pattern, TokensWriter.new)
8
- task.find_and_replace(SESSION.working_dir)
8
+ task.find_and_replace(SESSION.working_dir, SESSION.environment)
9
9
  }
10
10
 
11
- create_task(name, *args, &body)
11
+ Task.new(name, *args, &body)
12
12
  end
13
13
  end
@@ -12,34 +12,27 @@ class NUnit
12
12
  def execute(pattern)
13
13
  print_heading("Tests - #{pattern}")
14
14
 
15
- if(there_are_test_projects_for(pattern))
15
+ projects = get_test_projects_for(pattern)
16
+
17
+ if(!projects.empty?)
18
+ project_list = projects.join(' ').strip
19
+
16
20
  if(ENV["NUNIT_RUNNER"].nil?)
17
- mkdir_p "#{@session.output_dir}/test-reports"
18
- sh "#{@session.tools_dir}/nunit/nunit-console.exe #{assemblies} /xml=#{@session.output_dir}/test-reports/nunit.xml"
21
+ mkdir_p File.join(@session.output_dir, '/test-reports')
22
+ nunit = Dir.glob(File.join(@session.tools_dir, '/**/nunit-console.exe')).last
23
+
24
+ sh "#{nunit} #{project_list} /xml=#{File.join(@session.output_dir, '/test-reports/nunit.xml')}"
19
25
  else
20
- sh "#{ENV["NUNIT_RUNNER"]} v4.0 x86 NUnit-2.5.3 #{assemblies}"
26
+ sh "#{ENV["NUNIT_RUNNER"]} v4.0 x86 NUnit-2.5.3 #{project_list}"
21
27
  end
22
28
  end
23
29
  end
24
30
 
25
31
  private
26
32
 
27
- def there_are_test_projects_for(pattern)
28
- projects = @session.solution.get_projects(pattern)
29
-
30
- if(projects.length == 0)
31
- puts "No test projects found matching pattern #{pattern}".yellow
32
- return false
33
- end
34
-
35
- get_assemblies(projects)
36
-
37
- return true
33
+ def get_test_projects_for(pattern)
34
+ projects = Dir.glob(pattern, File::FNM_CASEFOLD).reject {|f| File.directory?(f) }
35
+ puts "No test projects found matching pattern #{pattern}".yellow if(projects.length == 0)
36
+ return projects
38
37
  end
39
-
40
- def get_assemblies(projects)
41
- files = []
42
- projects.each { |project| files << project.dll_path(@session.configuration) + ' ' }
43
- @assemblies = files.join.strip
44
- end
45
38
  end
@@ -9,12 +9,12 @@ class Tokens
9
9
  @globals = {}
10
10
  end
11
11
 
12
- def find_and_replace(path)
12
+ def find_and_replace(path, default)
13
13
  print_heading 'Tokenising'
14
14
 
15
15
  read_tokens_file(@globals_file)
16
16
 
17
- @files = Dir.glob("#{path}/**/#{@tokens_pattern}")
17
+ @files = Dir.glob("#{path}/**/#{@tokens_pattern}", File::FNM_CASEFOLD)
18
18
  puts "#{@files.length} config(s) found for tokenising"
19
19
  puts ''
20
20
 
@@ -24,11 +24,15 @@ class Tokens
24
24
  puts "Tokensing - #{file}"
25
25
  puts "Environments - #{@environments.keys.join(', ')}"
26
26
 
27
+ if !@environments.has_key?(default)
28
+ raise InvalidEnvironment, "Environment #{default} is not recognised. Possible environments are #{@environments.keys.join(', ')}".red
29
+ end
30
+
27
31
  @environments.each_pair do |environment, values|
28
32
  @writer.write_for(environment, file, values, @globals, true)
29
33
  end
30
34
 
31
- @writer.write_for('', file, @environments.values[0], @globals, false)
35
+ @writer.write_for('', file, @environments[default], @globals, false)
32
36
  puts ''
33
37
  end
34
38
  end
@@ -49,6 +53,9 @@ class Tokens
49
53
 
50
54
  end
51
55
 
56
+ class InvalidEnvironment < StandardError
57
+ end
58
+
52
59
  def keys_for(environment, values)
53
60
  environment = environment.to_s.downcase
54
61
 
@@ -0,0 +1,22 @@
1
+ require 'terminal'
2
+
3
+ class Tools
4
+
5
+ def download(tools_dir, download_url)
6
+ FileUtils.mkdir_p(tools_dir) if !File.directory?(tools_dir)
7
+
8
+ if(Dir.glob("#{tools_dir}/*.*").empty?)
9
+ print_heading 'Tools'
10
+ puts "Tools directory does not exist at #{tools_dir}".yellow
11
+ puts "Downloading tools from BitBucket..."
12
+ puts ''
13
+
14
+ bin = File.path(File.join(File.dirname(__FILE__), "../../", "bin"))
15
+
16
+ File.delete('tools.zip') if File.exists?('tools.zip')
17
+ sh "#{bin}/wget.exe -O tools.zip #{download_url}"
18
+ sh "#{bin}/unzip.exe -qo tools.zip -d #{tools_dir}"
19
+ File.delete('tools.zip') if File.exists?('tools.zip')
20
+ end
21
+ end
22
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rakeoff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-19 00:00:00.000000000Z
12
+ date: 2012-05-11 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &25612880 !ruby/object:Gem::Requirement
16
+ requirement: &23617460 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - =
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.9.2.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *25612880
24
+ version_requirements: *23617460
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rubyzip
27
- requirement: &25612320 !ruby/object:Gem::Requirement
27
+ requirement: &23616900 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - =
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.9.6.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *25612320
35
+ version_requirements: *23616900
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: term-ansicolor
38
- requirement: &25611760 !ruby/object:Gem::Requirement
38
+ requirement: &23616420 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - =
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.0.7
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *25611760
46
+ version_requirements: *23616420
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: logger
49
- requirement: &25611220 !ruby/object:Gem::Requirement
49
+ requirement: &23615900 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - =
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.2.8
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *25611220
57
+ version_requirements: *23615900
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &25610700 !ruby/object:Gem::Requirement
60
+ requirement: &23615340 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - =
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 2.9.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *25610700
68
+ version_requirements: *23615340
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: mocha
71
- requirement: &25610160 !ruby/object:Gem::Requirement
71
+ requirement: &23614760 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - =
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.10.5
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *25610160
79
+ version_requirements: *23614760
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rdoc
82
- requirement: &25609640 !ruby/object:Gem::Requirement
82
+ requirement: &23614240 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - =
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '3.12'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *25609640
90
+ version_requirements: *23614240
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: bundler
93
- requirement: &25609120 !ruby/object:Gem::Requirement
93
+ requirement: &23613720 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - =
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 1.1.3
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *25609120
101
+ version_requirements: *23613720
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: jeweler
104
- requirement: &25608600 !ruby/object:Gem::Requirement
104
+ requirement: &23613200 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - =
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 1.8.3
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *25608600
112
+ version_requirements: *23613200
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: simplecov
115
- requirement: &25603940 !ruby/object:Gem::Requirement
115
+ requirement: &23612640 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *25603940
123
+ version_requirements: *23612640
124
124
  description: A common set of build tasks typically used when creating projects in
125
125
  .Net
126
126
  email: robertbeal@gmail.com
@@ -134,24 +134,22 @@ files:
134
134
  - lib/rakeoff/aspnetcompile.rb
135
135
  - lib/rakeoff/clean.rb
136
136
  - lib/rakeoff/compile.rb
137
- - lib/rakeoff/project.rb
137
+ - lib/rakeoff/default_tasks.rb
138
138
  - lib/rakeoff/robocopy.rb
139
139
  - lib/rakeoff/session.rb
140
- - lib/rakeoff/solution.rb
141
140
  - lib/rakeoff/support/logging.rb
142
- - lib/rakeoff/support/task_helper.rb
143
- - lib/rakeoff/tasks.rb
141
+ - lib/rakeoff/support/terminal.rb
142
+ - lib/rakeoff/task.rb
144
143
  - lib/rakeoff/tasks/aspnetcompile_task.rb
145
144
  - lib/rakeoff/tasks/clean_task.rb
146
145
  - lib/rakeoff/tasks/compile_task.rb
147
- - lib/rakeoff/tasks/off_task.rb
148
146
  - lib/rakeoff/tasks/robocopy_task.rb
149
147
  - lib/rakeoff/tasks/tests_task.rb
150
148
  - lib/rakeoff/tasks/tokens_task.rb
151
- - lib/rakeoff/terminal.rb
152
149
  - lib/rakeoff/tests.rb
153
150
  - lib/rakeoff/tokens.rb
154
151
  - lib/rakeoff/tokens_writer.rb
152
+ - lib/rakeoff/tools.rb
155
153
  - LICENSE.txt
156
154
  - README.rdoc
157
155
  homepage: http://bitbucket.org/robertbeal/rakeoff
@@ -169,7 +167,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
169
167
  version: '0'
170
168
  segments:
171
169
  - 0
172
- hash: 2105016353616213847
170
+ hash: 4523683861892498821
173
171
  required_rubygems_version: !ruby/object:Gem::Requirement
174
172
  none: false
175
173
  requirements:
@@ -1,30 +0,0 @@
1
-
2
- class Project
3
-
4
- attr_accessor :name, :path, :directory, :assembly_name, :dll_path, :is_webapp
5
-
6
- def initialize(path)
7
- if !File.exists?(path)
8
- raise ProjectDoesNotExist, "Project does not exist at #{path}".red
9
- end
10
-
11
- @path = path
12
- @name = File.basename(path).gsub('.csproj', '')
13
- @directory = File.dirname(@path)
14
-
15
- match = File.read(path).match('<AssemblyName>(.*)</AssemblyName>')
16
- @assembly_name = match.nil? ? nil : match[1]
17
- @is_webapp = File.exist?(@directory + '/Web.config')
18
- end
19
-
20
- def include(expression)
21
- return File.read(path).include?(expression)
22
- end
23
-
24
- def dll_path(configuration)
25
- return @path.gsub(@name + '.csproj', "bin/#{configuration}/#{@assembly_name}.dll")
26
- end
27
- end
28
-
29
- class ProjectDoesNotExist < StandardError
30
- end
@@ -1,67 +0,0 @@
1
- require 'logging'
2
- require 'project'
3
-
4
- class Solution
5
- include Logging
6
-
7
- attr_accessor :name, :path, :directory, :projects
8
-
9
- def initialize(path)
10
- find_solution(path)
11
- find_projects
12
- end
13
-
14
- def get_projects(pattern)
15
- return @projects.select {|project| project.path.include?(pattern) }
16
- end
17
-
18
- private
19
-
20
- def find_solution(path)
21
- logger.info "Searching for solution files at: #{path}/*.sln"
22
- matches = Dir.glob("#{path}/**/*.sln")
23
-
24
- if matches.empty?
25
- raise NoSolutionFile, "No *.sln file found in #{path}".red
26
- end
27
-
28
- if matches.length > 1
29
- raise MultipleSolutionFiles, "Multiple solution files found. Don't know which one to build!".red
30
- end
31
-
32
- match = matches.first
33
-
34
- @name = match.to_s.match(/.*\/(.*).sln/)[1]
35
- @path = match
36
- @directory = File.dirname(match)
37
- end
38
-
39
- def find_projects
40
- @projects = []
41
- logger.info "Reading projects in solution #{@path}"
42
-
43
- readlines(@path).each do |line|
44
- match = line.match(/,\s\"(.*\.csproj)\"/)
45
- path = match.nil? ? nil : match[1]
46
-
47
- if(!path.nil?)
48
- path = File.join(File.expand_path(@directory), path).gsub('\\', '/')
49
-
50
- logger.info "Creating project instance for path #{path}"
51
- projects.push(Project.new(path))
52
- end
53
- end
54
- end
55
-
56
- def readlines(file)
57
- lines = []
58
- File.open(file, 'r').each { |line| lines << line }
59
- return lines
60
- end
61
- end
62
-
63
- class NoSolutionFile < StandardError
64
- end
65
-
66
- class MultipleSolutionFiles < StandardError
67
- end
@@ -1,34 +0,0 @@
1
- require 'rake'
2
- include Rake::DSL
3
-
4
- def create_task(name, *args, &body)
5
- args || args = []
6
- args.insert 0, name
7
-
8
- # allows you to define your own overriden tasks
9
- # hardcoded tasks are added first, then user dynamic ones, then finally rakeoff dyanmic ones
10
- if(task_exists(name))
11
- return
12
- end
13
-
14
- # make sure the off task is our own and not overriden
15
- if(task_exists(name) && name == 'off')
16
- remove_task(name)
17
- end
18
-
19
- Rake::Task.define_task(*args, &body)
20
- end
21
-
22
- def task_exists(name)
23
- return Rake::Task.task_defined?(name)
24
- end
25
-
26
- def remove_task(task_name)
27
- Rake.application.remove_task(task_name)
28
- end
29
-
30
- Rake::TaskManager.class_eval do
31
- def remove_task(task_name)
32
- @tasks.delete(task_name.to_s)
33
- end
34
- end
@@ -1,15 +0,0 @@
1
-
2
- class Tasks
3
- def initialize
4
- AspnetCompileTask.new(:aspnetcompile)
5
- CleanTask.new(:clean)
6
- TokensTask.new(:tokens)
7
-
8
- CompileTask.new(:compile, '')
9
- CompileTask.new(:publish, "/property:OutDir=#{SESSION.output_dir}/publish/")
10
-
11
- TestsTask.new(:unit_tests, '.Unit.Tests')
12
- TestsTask.new(:integration_tests, '.Integration.Tests')
13
- TestsTask.new(:acceptance_tests, '.Acceptance.Tests')
14
- end
15
- end
@@ -1,13 +0,0 @@
1
- require 'support/task_helper'
2
- require 'session'
3
- require 'tasks'
4
-
5
- task :off do
6
- LOGGING_LEVEL = Logger::ERROR
7
-
8
- SESSION = Session.new
9
- SESSION.set_values
10
- SESSION.load_solution
11
-
12
- Tasks.new
13
- end
@@ -1,17 +0,0 @@
1
- require 'rubygems'
2
- require 'term/ansicolor'
3
- require 'win32console' unless !(RUBY_PLATFORM =~ /mswin32/)
4
-
5
- class String
6
- include Term::ANSIColor
7
- end
8
-
9
- def print_heading(message)
10
- if(SESSION.is_build_agent)
11
- puts "##teamcity[progressMessage '#{message}']"
12
- else
13
- puts ''
14
- puts message.cyan
15
- puts "####################################".cyan
16
- end
17
- end