albacore 2.0.0.rc.2 → 2.0.0.rc.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +262 -202
- data/albacore.gemspec +1 -0
- data/lib/albacore.rb +3 -0
- data/lib/albacore/albacore_module.rb +6 -0
- data/lib/albacore/nuget_model.rb +7 -1
- data/lib/albacore/task_types/asmver.rb +11 -4
- data/lib/albacore/task_types/asmver/file_generator.rb +17 -10
- data/lib/albacore/task_types/build.rb +196 -192
- data/lib/albacore/task_types/nugets_pack.rb +22 -5
- data/lib/albacore/tasks/README.md +3 -1
- data/lib/albacore/tools.rb +4 -0
- data/lib/albacore/version.rb +1 -1
- data/spec/asmver_spec.rb +17 -13
- data/spec/nuget_model_spec.rb +19 -63
- data/spec/nugets_pack_spec.rb +42 -14
- data/spec/shared_contexts.rb +59 -0
- data/spec/spec_helper.rb +1 -1
- metadata +17 -5
data/albacore.gemspec
CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.email = 'henrik@haf.se'
|
12
12
|
s.homepage = 'http://albacorebuild.net'
|
13
13
|
s.summary = 'Dolphin-safe and awesome Mono and .Net Rake-tasks'
|
14
|
+
s.license = 'MIT'
|
14
15
|
s.description = <<-EOF
|
15
16
|
Easily build your .Net or Mono project using this collection of Rake tasks.
|
16
17
|
Albacore assist you in creating nugets, managing nugets, building your projects,
|
data/lib/albacore.rb
CHANGED
data/lib/albacore/nuget_model.rb
CHANGED
@@ -57,6 +57,9 @@ end})
|
|
57
57
|
# gets or sets the description of this package
|
58
58
|
nuspec_field :description
|
59
59
|
|
60
|
+
# gets or sets the summary of this package
|
61
|
+
nuspec_field :summary
|
62
|
+
|
60
63
|
# gets or sets the language that this package has been built with
|
61
64
|
nuspec_field :language
|
62
65
|
|
@@ -301,9 +304,12 @@ end})
|
|
301
304
|
# Options:
|
302
305
|
# - symbols
|
303
306
|
# - dotnet_version
|
307
|
+
# Specifies the version to use for constructing the nuspec's lib folder
|
304
308
|
# - known_projects
|
305
309
|
# - configuration
|
306
310
|
# - project_dependencies
|
311
|
+
# Specifies whether to follow the project dependencies. See nuget_model_spec.rb
|
312
|
+
# for examples of usage of this property.
|
307
313
|
# - nuget_dependencies
|
308
314
|
def self.from_xxproj proj, *opts
|
309
315
|
opts = Map.options(opts || {}).
|
@@ -373,8 +379,8 @@ end})
|
|
373
379
|
package.files.each do |file|
|
374
380
|
file_path = File.expand_path file.src, proj.proj_path_base
|
375
381
|
unless File.exists? file_path
|
382
|
+
info "while building nuspec for proj: #{proj.name}, file: #{file_path} => #{file.target} not found, removing from nuspec [nuget model: package]"
|
376
383
|
package.remove_file file.src
|
377
|
-
info "while building nuspec for proj: #{proj.name}, file: #{file.src} => #{file.target} not found, removing from nuspec [nuget model: package]"
|
378
384
|
trace { "files: #{package.files.map { |f| f.src }.inspect} [nuget model: package]" }
|
379
385
|
end
|
380
386
|
end
|
@@ -18,6 +18,7 @@ module Albacore
|
|
18
18
|
# the file name to write the assembly info to
|
19
19
|
attr_path_accessor :file_path
|
20
20
|
|
21
|
+
# the namespace to output into the version file
|
21
22
|
attr_writer :namespace
|
22
23
|
|
23
24
|
|
@@ -34,11 +35,12 @@ module Albacore
|
|
34
35
|
|
35
36
|
def opts
|
36
37
|
raise Error, "#file_path is not set" unless (file_path or out)
|
38
|
+
ns = @namespace || '' # defaults to empty namespace if not set.
|
37
39
|
lang = lang_for file_path
|
38
40
|
m = Map.new attributes: @attributes,
|
39
|
-
namespace:
|
41
|
+
namespace: ns,
|
40
42
|
file_path: @file_path,
|
41
|
-
language:
|
43
|
+
language: lang
|
42
44
|
m[:out] = @out if @out
|
43
45
|
m
|
44
46
|
end
|
@@ -55,6 +57,7 @@ module Albacore
|
|
55
57
|
end
|
56
58
|
end
|
57
59
|
class Task
|
60
|
+
include Logging
|
58
61
|
def initialize opts
|
59
62
|
@opts = opts
|
60
63
|
end
|
@@ -62,8 +65,12 @@ module Albacore
|
|
62
65
|
lang = @opts.get :language
|
63
66
|
ns = @opts.get :namespace
|
64
67
|
attrs = @opts.get :attributes
|
65
|
-
out = @opts.get
|
66
|
-
|
68
|
+
out = @opts.get :out do
|
69
|
+
trace { "asmver being written at '#{@opts.get :file_path}' [asmver-task #execute]" }
|
70
|
+
File.open(@opts.get(:file_path), 'w')
|
71
|
+
end
|
72
|
+
::Albacore::Asmver::FileGenerator.new(lang, ns, @opts).generate out, attrs
|
73
|
+
trace { "asmver was written at '#{@opts.get :file_path}' [asmver-task #execute]" }
|
67
74
|
ensure
|
68
75
|
out.close if out
|
69
76
|
end
|
@@ -1,8 +1,11 @@
|
|
1
1
|
require 'albacore/task_types/asmver/engine'
|
2
|
+
require 'albacore/logging'
|
2
3
|
require 'map'
|
3
4
|
|
4
5
|
module Albacore::Asmver
|
5
6
|
class FileGenerator
|
7
|
+
include ::Albacore::Logging
|
8
|
+
|
6
9
|
DEFAULT_USINGS = %w|
|
7
10
|
System.Reflection
|
8
11
|
System.Runtime.CompilerServices
|
@@ -13,33 +16,37 @@ System.Runtime.InteropServices|
|
|
13
16
|
raise ArgumentError, 'ns is nil' unless ns
|
14
17
|
@engine = engine
|
15
18
|
@ns = ns
|
16
|
-
@opts = Map.new
|
19
|
+
@opts = Map.new opts
|
17
20
|
end
|
18
21
|
|
19
|
-
def generate attrs = {}
|
22
|
+
def generate out, attrs = {}
|
23
|
+
trace { "generating file with attributes: #{attrs} [file_generator #generate]" }
|
24
|
+
|
20
25
|
# https://github.com/ahoward/map/blob/master/test/map_test.rb#L374
|
21
26
|
attrs = Map.new attrs
|
22
|
-
s = @opts.get(:out) { StringIO.new }
|
23
27
|
|
24
28
|
# write the attributes in the namespace
|
25
|
-
@engine.build_namespace @ns,
|
29
|
+
@engine.build_namespace @ns, out do
|
26
30
|
# after namespace My.Ns.Here
|
27
|
-
|
31
|
+
out << "\n"
|
28
32
|
|
29
33
|
# open all namespaces to use .Net attributes
|
30
34
|
@opts.get(:usings) { DEFAULT_USINGS }.each do |ns|
|
31
|
-
|
32
|
-
|
35
|
+
out << @engine.build_using_statement(ns)
|
36
|
+
out << "\n"
|
33
37
|
end
|
34
38
|
|
39
|
+
warn { 'no attributes have been given to [file_generator #generate]' } if attrs.empty?
|
40
|
+
|
35
41
|
# write all attributes
|
36
42
|
attrs.each do |name, data|
|
37
|
-
|
38
|
-
|
43
|
+
trace { "building attribute #{name}: '#{data}' [file_generator #generate]" }
|
44
|
+
out << @engine.build_attribute(name, data)
|
45
|
+
out << "\n"
|
39
46
|
end
|
40
47
|
end
|
41
48
|
|
42
|
-
|
49
|
+
nil
|
43
50
|
end
|
44
51
|
end
|
45
52
|
end
|
@@ -1,192 +1,196 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require 'rake'
|
4
|
-
require 'albacore/paths'
|
5
|
-
require 'albacore/cmd_config'
|
6
|
-
require 'albacore/cross_platform_cmd'
|
7
|
-
require 'albacore/logging'
|
8
|
-
require 'albacore/facts'
|
9
|
-
|
10
|
-
module Albacore
|
11
|
-
module Build
|
12
|
-
class Cmd
|
13
|
-
include CrossPlatformCmd
|
14
|
-
def initialize work_dir, executable, parameters
|
15
|
-
@work_dir = work_dir
|
16
|
-
@executable = executable
|
17
|
-
@parameters = (parameters === Array) ? parameters : parameters.to_a
|
18
|
-
end
|
19
|
-
def execute
|
20
|
-
system @executable, @parameters, :work_dir => @work_dir
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# The configuration class for xbuild and msbuild. MSDN docs at: http://msdn.microsoft.com/en-us/library/vstudio/ms164311.aspx
|
25
|
-
class Config
|
26
|
-
include CmdConfig
|
27
|
-
self.extend ConfigDSL
|
28
|
-
include Logging
|
29
|
-
|
30
|
-
# TODO: move towards #opts() for all task types rather than
|
31
|
-
# reading these public properties.
|
32
|
-
|
33
|
-
# this is the target of the compilation with MsBuild/XBuild
|
34
|
-
attr_reader :target
|
35
|
-
|
36
|
-
# any properties you want to set
|
37
|
-
attr_accessor :properties
|
38
|
-
|
39
|
-
def initialize
|
40
|
-
@parameters = Set.new
|
41
|
-
|
42
|
-
w = lambda { |e| CrossPlatformCmd.which(e) ? e : nil }
|
43
|
-
|
44
|
-
@exe = w.call( "msbuild" ) ||
|
45
|
-
w.call( "xbuild" ) ||
|
46
|
-
heuristic_executable
|
47
|
-
|
48
|
-
debug { "build using '#{@exe}'" }
|
49
|
-
set_logging '
|
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
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
instance_variable_get(field)
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
@
|
159
|
-
end
|
160
|
-
|
161
|
-
def
|
162
|
-
@
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
end
|
170
|
-
|
171
|
-
def
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
require 'albacore/paths'
|
5
|
+
require 'albacore/cmd_config'
|
6
|
+
require 'albacore/cross_platform_cmd'
|
7
|
+
require 'albacore/logging'
|
8
|
+
require 'albacore/facts'
|
9
|
+
|
10
|
+
module Albacore
|
11
|
+
module Build
|
12
|
+
class Cmd
|
13
|
+
include CrossPlatformCmd
|
14
|
+
def initialize work_dir, executable, parameters
|
15
|
+
@work_dir = work_dir
|
16
|
+
@executable = executable
|
17
|
+
@parameters = (parameters === Array) ? parameters : parameters.to_a
|
18
|
+
end
|
19
|
+
def execute
|
20
|
+
system @executable, @parameters, :work_dir => @work_dir
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# The configuration class for xbuild and msbuild. MSDN docs at: http://msdn.microsoft.com/en-us/library/vstudio/ms164311.aspx
|
25
|
+
class Config
|
26
|
+
include CmdConfig
|
27
|
+
self.extend ConfigDSL
|
28
|
+
include Logging
|
29
|
+
|
30
|
+
# TODO: move towards #opts() for all task types rather than
|
31
|
+
# reading these public properties.
|
32
|
+
|
33
|
+
# this is the target of the compilation with MsBuild/XBuild
|
34
|
+
attr_reader :target
|
35
|
+
|
36
|
+
# any properties you want to set
|
37
|
+
attr_accessor :properties
|
38
|
+
|
39
|
+
def initialize
|
40
|
+
@parameters = Set.new
|
41
|
+
|
42
|
+
w = lambda { |e| CrossPlatformCmd.which(e) ? e : nil }
|
43
|
+
|
44
|
+
@exe = w.call( "msbuild" ) ||
|
45
|
+
w.call( "xbuild" ) ||
|
46
|
+
heuristic_executable
|
47
|
+
|
48
|
+
debug { "build using '#{@exe}'" }
|
49
|
+
set_logging (ENV['DEBUG'] ?
|
50
|
+
(ENV['VERBOSE'] ?
|
51
|
+
'detailed' :
|
52
|
+
'normal') :
|
53
|
+
'minimal')
|
54
|
+
end
|
55
|
+
|
56
|
+
# this is the solution file to build (or the project files themselves)
|
57
|
+
attr_path_accessor :sln, :file do |val|
|
58
|
+
@parameters.add val
|
59
|
+
end
|
60
|
+
|
61
|
+
# Call for each target that you want to add, or pass an array or
|
62
|
+
# strings. Only unique targets will be passed to MsBuild.
|
63
|
+
#
|
64
|
+
# From MSDN:
|
65
|
+
#
|
66
|
+
# "Build the specified targets in the project. Specify each target separately, or use a semicolon or comma to separate multiple targets, as the following example shows:
|
67
|
+
# /target:Resources;Compile
|
68
|
+
# If you specify any targets by using this switch, they are run instead of any targets in the DefaultTargets attribute in the project file. For more information, see Target Build Order (http://msdn.microsoft.com/en-us/library/vstudio/ee216359.aspx) and How to: Specify Which Target to Build First (http://msdn.microsoft.com/en-us/library/vstudio/ms171463.aspx).
|
69
|
+
# A target is a group of tasks. For more information, see MSBuild Targets (http://msdn.microsoft.com/en-us/library/vstudio/ms171462.aspx)."
|
70
|
+
#
|
71
|
+
# t :: the array or string target to add to the list of tarets to build
|
72
|
+
attr_path_accessor :target do |t|
|
73
|
+
update_array_prop "target", method(:make_target), :targets, t
|
74
|
+
end
|
75
|
+
|
76
|
+
# Allows you to add properties to MsBuild; example:
|
77
|
+
#
|
78
|
+
# b.prop 'WarningLevel', 2
|
79
|
+
# b.prop 'BuildVersion', '3.5.0'
|
80
|
+
#
|
81
|
+
# From MSDN:
|
82
|
+
#
|
83
|
+
# "Set or override the specified project-level properties, where name is the property name and value is the property value. Specify each property separately, or use a semicolon or comma to separate multiple properties, as the following example shows:
|
84
|
+
# /property:WarningLevel=2;OutputDir=bin\Debug"
|
85
|
+
#
|
86
|
+
# The properties will be automatically converted to the correct syntax
|
87
|
+
def prop k, v
|
88
|
+
@properties ||= Hash.new
|
89
|
+
@parameters.delete "/property:#{make_props}" if @properties.any?
|
90
|
+
@properties[k] = v
|
91
|
+
@parameters.add "/property:#{make_props}"
|
92
|
+
end
|
93
|
+
|
94
|
+
# Specifies the amount of information to display in the build log.
|
95
|
+
# Each logger displays events based on the verbosity level that you set for that logger.
|
96
|
+
# You can specify the following verbosity levels: q[uiet], m[inimal],
|
97
|
+
# n[ormal], d[etailed], and diag[nostic].
|
98
|
+
attr_path_accessor :logging do |mode|
|
99
|
+
set_logging mode
|
100
|
+
end
|
101
|
+
|
102
|
+
# Specifies the number of parallel worker processes to build with
|
103
|
+
# Defaults to the number of logical cores
|
104
|
+
attr_path_accessor :cores do |num|
|
105
|
+
@parameters.add "/maxcpucount:#{num}"
|
106
|
+
end
|
107
|
+
|
108
|
+
# Pass the parameters that you specify to the console logger, which displays build information in the console window. You can specify the following parameters:
|
109
|
+
# * PerformanceSummary. Show the time that’s spent in tasks, targets, and projects.
|
110
|
+
# * Summary. Show the error and warning summary at the end.
|
111
|
+
# * NoSummary. Don't show the error and warning summary at the end.
|
112
|
+
# * ErrorsOnly. Show only errors.
|
113
|
+
# * WarningsOnly. Show only warnings.
|
114
|
+
# * NoItemAndPropertyList. Don't show the list of items and properties that would appear at the start of each project build if the verbosity level is set to diagnostic.
|
115
|
+
# * ShowCommandLine. Show TaskCommandLineEvent messages.
|
116
|
+
# * ShowTimestamp. Show the timestamp as a prefix to any message.
|
117
|
+
# * ShowEventId. Show the event ID for each started event, finished event, and message.
|
118
|
+
# * ForceNoAlign. Don't align the text to the size of the console buffer.
|
119
|
+
# * DisableConsoleColor. Use the default console colors for all logging messages.
|
120
|
+
# * DisableMPLogging. Disable the multiprocessor logging style of output when running in non-multiprocessor mode.
|
121
|
+
# * EnableMPLogging. Enable the multiprocessor logging style even when running in non-multiprocessor mode. This logging style is on by default.
|
122
|
+
# * Verbosity. Override the /verbosity setting for this logger.
|
123
|
+
def clp param
|
124
|
+
update_array_prop "consoleloggerparameters", method(:make_clp), :clp, param
|
125
|
+
end
|
126
|
+
|
127
|
+
# Set logging verbosity to quiet
|
128
|
+
def be_quiet
|
129
|
+
logging = "quiet"
|
130
|
+
end
|
131
|
+
|
132
|
+
# Don't display the startup banner or the copyright message.
|
133
|
+
def nologo
|
134
|
+
@parameters.add "/nologo"
|
135
|
+
end
|
136
|
+
|
137
|
+
private
|
138
|
+
def set_logging mode
|
139
|
+
modes = %w{quiet minimal normal detailed diagnostic}.collect{ |m| "/verbosity:#{m}" }
|
140
|
+
@parameters.subtract modes
|
141
|
+
@parameters.add "/verbosity:#{mode}"
|
142
|
+
end
|
143
|
+
|
144
|
+
def update_array_prop prop_name, callable_prop_val, field_sym, value
|
145
|
+
field = :"@#{field_sym}"
|
146
|
+
# @targets ||= []
|
147
|
+
instance_variable_set field, [] unless instance_variable_defined? field
|
148
|
+
# parameters.delete "/target:#{make_target}" if @targets.any?
|
149
|
+
@parameters.delete "/#{prop_name}:#{callable_prop_val.call}" if
|
150
|
+
instance_variable_get(field).any?
|
151
|
+
if value.respond_to? 'each'
|
152
|
+
value.each { |v| instance_variable_get(field) << v }
|
153
|
+
else
|
154
|
+
instance_variable_get(field) << value
|
155
|
+
end
|
156
|
+
instance_variable_get(field).uniq!
|
157
|
+
# @parameters.add "/target:#{make_target}"
|
158
|
+
@parameters.add "/#{prop_name}:#{callable_prop_val.call}"
|
159
|
+
end
|
160
|
+
|
161
|
+
def make_target
|
162
|
+
@targets.join(';')
|
163
|
+
end
|
164
|
+
|
165
|
+
def make_props
|
166
|
+
@properties.collect { |k, v|
|
167
|
+
"#{k}=#{v}"
|
168
|
+
}.join(';')
|
169
|
+
end
|
170
|
+
|
171
|
+
def make_clp
|
172
|
+
@clp.join(';')
|
173
|
+
end
|
174
|
+
|
175
|
+
def heuristic_executable
|
176
|
+
if ::Rake::Win32.windows?
|
177
|
+
trace 'build tasktype finding msbuild.exe'
|
178
|
+
%w{v4.0.30319 v4.0 v3.5 v2.0}.collect { |fw_ver|
|
179
|
+
msb = File.join ENV['WINDIR'], 'Microsoft.NET', 'Framework', fw_ver, 'msbuild.exe'
|
180
|
+
CrossPlatformCmd.which(msb) ? msb : nil
|
181
|
+
}.first
|
182
|
+
else
|
183
|
+
nil
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
class Task
|
188
|
+
def initialize command_line
|
189
|
+
@command_line = command_line
|
190
|
+
end
|
191
|
+
def execute
|
192
|
+
@command_line.execute
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|