albacore 2.8.0 → 3.0.0.pre.alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/albacore/cli.rb +2 -2
- data/lib/albacore/dsl.rb +2 -42
- data/lib/albacore/nuget_model.rb +173 -67
- data/lib/albacore/paket.rb +20 -5
- data/lib/albacore/paths.rb +1 -0
- data/lib/albacore/project.rb +228 -45
- data/lib/albacore/task_types/nugets_pack.rb +73 -425
- data/lib/albacore/task_types/sql_cmd.rb +1 -1
- data/lib/albacore/tasks/release.rb +2 -2
- data/lib/albacore/version.rb +1 -1
- data/spec/dsl_spec.rb +1 -1
- data/spec/nuget_model_spec.rb +208 -79
- data/spec/nugets_pack_spec.rb +1 -353
- data/spec/paket_spec.rb +51 -2
- data/spec/project_spec.rb +118 -43
- data/spec/shared_contexts.rb +28 -14
- data/spec/testdata/Project/Project.fsproj +1 -1
- data/spec/testdata/console-core-argu/.gitignore +4 -0
- data/spec/testdata/console-core-argu/.paket/Paket.Restore.targets +239 -0
- data/spec/testdata/console-core-argu/.paket/paket.exe +0 -0
- data/spec/testdata/console-core-argu/.paket/paket.targets +72 -0
- data/spec/testdata/console-core-argu/ConsoleArgu.fsproj +12 -0
- data/spec/testdata/console-core-argu/Library.fs +31 -0
- data/spec/testdata/console-core-argu/build.sh +4 -0
- data/spec/testdata/console-core-argu/paket.dependencies +3 -0
- data/spec/testdata/console-core-argu/paket.lock +565 -0
- data/spec/testdata/console-core-argu/paket.references +2 -0
- data/spec/testdata/console-core-argu/paket.template +1 -0
- metadata +26 -16
- data/lib/albacore/app_spec.rb +0 -229
- data/lib/albacore/cpack_app_spec.rb +0 -135
- data/lib/albacore/task_types/nugets.rb +0 -8
- data/lib/albacore/task_types/nugets_restore.rb +0 -181
- data/spec/app_spec_spec.rb +0 -147
- data/spec/fpm_app_spec_spec.rb +0 -157
- data/spec/nugets_find_gem_exe_spec.rb +0 -21
- data/spec/nugets_restore_spec.rb +0 -77
data/lib/albacore/paths.rb
CHANGED
data/lib/albacore/project.rb
CHANGED
@@ -4,24 +4,93 @@ require 'albacore/semver'
|
|
4
4
|
require 'albacore/package_repo'
|
5
5
|
require 'albacore/paket'
|
6
6
|
require 'pathname'
|
7
|
-
module Albacore
|
8
7
|
|
8
|
+
module Albacore
|
9
9
|
# error raised from Project#output_path if the given configuration wasn't
|
10
10
|
# found
|
11
11
|
class ConfigurationNotFoundError < ::StandardError
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
class OutputArtifact
|
15
|
+
EXECUTABLE = :executable
|
16
|
+
LIBRARY = :dll
|
17
|
+
XMLDOC = :xmldoc
|
18
|
+
SYMBOLS = :symbols
|
19
|
+
|
20
|
+
# E.g. "bin/Debug/lib.dll"
|
21
|
+
# E.g. "bin/Debug/net461/lib.dll"
|
22
|
+
# E.g. "bin/Debug/net461/lib.xml"
|
23
|
+
# E.g. "bin/Debug/net461/lib.dll.pdb"
|
24
|
+
# E.g. "bin/Debug/net461/prog.exe"
|
25
|
+
attr_reader :path
|
26
|
+
|
27
|
+
# E.g. "lib.dll"
|
28
|
+
# E.g. "prog.exe"
|
29
|
+
attr_reader :filename
|
30
|
+
|
31
|
+
# E.g. :dll
|
32
|
+
attr_reader :sort
|
33
|
+
|
34
|
+
# E.g. ".txt"
|
35
|
+
attr_reader :ext
|
36
|
+
|
37
|
+
# Create a new OutputArtifact
|
38
|
+
def initialize path, sort
|
39
|
+
@path, @sort = path, sort
|
40
|
+
@ext = File.extname path
|
41
|
+
@filename = File.basename path
|
42
|
+
end
|
43
|
+
|
44
|
+
# Is the file a DLL file?
|
45
|
+
def library?
|
46
|
+
sort == ::LIBRARY
|
47
|
+
end
|
48
|
+
|
49
|
+
# Is the file a DLL file?
|
50
|
+
def dll?
|
51
|
+
library?
|
52
|
+
end
|
53
|
+
|
54
|
+
# Is the file an executable?
|
55
|
+
def executable?
|
56
|
+
sort == ::EXECUTABLE
|
57
|
+
end
|
58
|
+
|
59
|
+
# Is the file a documentation file?
|
60
|
+
def xmldoc?
|
61
|
+
sort == ::XMLDOC
|
62
|
+
end
|
63
|
+
|
64
|
+
# Is the file a symbol file?
|
65
|
+
def symbols?
|
66
|
+
sort == ::SYMBOLS
|
67
|
+
end
|
68
|
+
|
69
|
+
def ==(o)
|
70
|
+
@path == o.path && @sort == o.sort
|
71
|
+
end
|
72
|
+
|
73
|
+
alias_method :eql?, :==
|
74
|
+
end
|
75
|
+
|
76
|
+
# A project encapsulates the properties from a xxproj file.
|
15
77
|
class Project
|
16
78
|
include Logging
|
17
79
|
|
18
|
-
attr_reader
|
80
|
+
attr_reader \
|
81
|
+
:proj_path_base,
|
82
|
+
:proj_filename,
|
83
|
+
:ext,
|
84
|
+
:proj_filename_noext,
|
85
|
+
:proj_xml_node
|
19
86
|
|
20
87
|
def initialize proj_path
|
21
88
|
raise ArgumentError, 'project path does not exist' unless File.exists? proj_path.to_s
|
22
89
|
proj_path = proj_path.to_s unless proj_path.is_a? String
|
23
90
|
@proj_xml_node = Nokogiri.XML(open(proj_path))
|
24
91
|
@proj_path_base, @proj_filename = File.split proj_path
|
92
|
+
@ext = File.extname @proj_filename
|
93
|
+
@proj_filename_noext = File.basename @proj_filename, ext
|
25
94
|
sanity_checks
|
26
95
|
end
|
27
96
|
|
@@ -44,15 +113,20 @@ module Albacore
|
|
44
113
|
# the title of the nuspec and, if Id is not specified, also the id of the
|
45
114
|
# nuspec.
|
46
115
|
def name
|
47
|
-
(
|
116
|
+
read_property('Name') || asmname || proj_filename_noext
|
48
117
|
end
|
49
118
|
|
50
119
|
# The same as #name
|
51
120
|
alias_method :title, :name
|
52
121
|
|
122
|
+
# The project is a .Net Core project.
|
123
|
+
def netcore?
|
124
|
+
! @proj_xml_node.css('Project').attr('Sdk').nil?
|
125
|
+
end
|
126
|
+
|
53
127
|
# get the assembly name specified in the project file
|
54
128
|
def asmname
|
55
|
-
read_property
|
129
|
+
read_property('AssemblyName') || proj_filename_noext
|
56
130
|
end
|
57
131
|
|
58
132
|
# Get the root namespace of the project
|
@@ -79,42 +153,131 @@ module Albacore
|
|
79
153
|
read_property 'License'
|
80
154
|
end
|
81
155
|
|
82
|
-
|
83
|
-
|
84
|
-
|
156
|
+
def xmldoc? conf='Debug', platform='AnyCPU'
|
157
|
+
if netcore?
|
158
|
+
gdf = read_property('GenerateDocumentationFile')
|
159
|
+
!gdf.nil? && gdf == 'true'
|
160
|
+
else
|
161
|
+
! read_property('DocumentationFile', conf, platform).nil?
|
162
|
+
end
|
85
163
|
end
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
def output_path conf
|
90
|
-
try_output_path conf || raise(ConfigurationNotFoundError, "could not find configuration '#{conf}'")
|
164
|
+
|
165
|
+
def symbols? conf='Debug', platform='AnyCPU'
|
166
|
+
read_property('DebugSymbols', conf) == 'true'
|
91
167
|
end
|
92
168
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
169
|
+
# OutputArtifact::LIBRARY
|
170
|
+
# OutputArtifact::EXECUTABLE
|
171
|
+
def output_type
|
172
|
+
ot = read_property 'OutputType'
|
173
|
+
case ot
|
174
|
+
when 'Library'
|
175
|
+
OutputArtifact::LIBRARY
|
176
|
+
when 'Exe'
|
177
|
+
OutputArtifact::EXECUTABLE
|
178
|
+
else
|
179
|
+
ot
|
180
|
+
end
|
181
|
+
end
|
97
182
|
|
98
|
-
|
183
|
+
# ".exe"?, ".dll"?
|
184
|
+
def output_file_ext
|
185
|
+
case output_type
|
186
|
+
when OutputArtifact::LIBRARY
|
187
|
+
".dll"
|
188
|
+
when OutputArtifact::EXECUTABLE
|
189
|
+
".exe"
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def default_platform
|
194
|
+
@proj_xml_node.css('Project PropertyGroup Platform').first.inner_text || 'AnyCPU'
|
195
|
+
end
|
196
|
+
|
197
|
+
def debug_type conf
|
198
|
+
dt = read_property "DebugType", conf
|
199
|
+
end
|
200
|
+
|
201
|
+
# the target .NET Framework / .NET version
|
202
|
+
def target_framework
|
203
|
+
read = read_property('TargetFrameworkVersion')
|
204
|
+
case read
|
205
|
+
when 'v3.5'
|
206
|
+
'net35'
|
207
|
+
when 'v3.5.1'
|
208
|
+
'net351'
|
209
|
+
when 'v4.0'
|
210
|
+
'net40'
|
211
|
+
when 'v4.5'
|
212
|
+
'net45'
|
213
|
+
when 'v4.5.1'
|
214
|
+
'net451'
|
215
|
+
when 'v4.6'
|
216
|
+
'net46'
|
217
|
+
when 'v4.6.1'
|
218
|
+
'net461'
|
219
|
+
when 'v4.6.2'
|
220
|
+
'net462'
|
221
|
+
when 'v5.0'
|
222
|
+
'net50'
|
223
|
+
when 'v5.0.1'
|
224
|
+
'net501'
|
225
|
+
else
|
226
|
+
read
|
227
|
+
end
|
228
|
+
end
|
99
229
|
|
100
|
-
|
101
|
-
|
230
|
+
# Gets the target frameworks as specified by .Net Core syntax
|
231
|
+
def target_frameworks
|
232
|
+
if netcore?
|
233
|
+
tfw = @proj_xml_node.css('Project PropertyGroup TargetFramework').inner_text
|
234
|
+
tfws = @proj_xml_node.css('Project PropertyGroup TargetFrameworks').inner_text
|
235
|
+
nfws = if tfw.nil? || tfw == '' then tfws else tfw end
|
236
|
+
fws = nfws.split(';')
|
237
|
+
else
|
238
|
+
[ target_framework ]
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
# Returns OutputArtifact[] or throws an error
|
243
|
+
def outputs conf, fw
|
244
|
+
os = try_outputs(conf, fw)
|
245
|
+
if os.empty?
|
246
|
+
raise(ConfigurationNotFoundError, "could not find configuration '#{conf}'")
|
247
|
+
else
|
248
|
+
os
|
249
|
+
end
|
102
250
|
end
|
103
251
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
252
|
+
def try_outputs conf, fw
|
253
|
+
outputs = []
|
254
|
+
if netcore? then
|
255
|
+
outputs << OutputArtifact.new("bin/#{conf}/#{fw}/#{asmname}#{output_file_ext}", output_type)
|
256
|
+
outputs << OutputArtifact.new("bin/#{conf}/#{fw}/#{asmname}.xml", OutputArtifact::XMLDOC) if xmldoc?
|
257
|
+
else
|
258
|
+
path = read_property 'OutputPath', conf, default_platform
|
259
|
+
if path != ''
|
260
|
+
full_path = Albacore::Paths.join(path, "#{asmname}#{output_file_ext}").to_s
|
261
|
+
outputs << OutputArtifact.new(full_path, output_type)
|
262
|
+
end
|
263
|
+
|
264
|
+
if xmldoc? conf, default_platform
|
265
|
+
xml_full_path = read_property 'DocumentationFile', conf
|
266
|
+
outputs << OutputArtifact.new(xml_full_path, OutputArtifact::XMLDOC)
|
267
|
+
end
|
268
|
+
|
269
|
+
if symbols? conf, default_platform
|
270
|
+
pdb_full_path = Albacore::Paths.join(path, "#{asmname}.pdb").to_s
|
271
|
+
outputs << OutputArtifact.new(pdb_full_path, OutputArtifact::SYMBOLS)
|
272
|
+
end
|
273
|
+
end
|
274
|
+
outputs
|
112
275
|
end
|
113
276
|
|
114
277
|
# Gets the relative location (to the project base path) of the dll
|
115
278
|
# that it will output
|
116
|
-
def output_dll conf
|
117
|
-
|
279
|
+
def output_dll conf, fw
|
280
|
+
output_paths(conf, fw).keep_if { |o| o.library? }.first
|
118
281
|
end
|
119
282
|
|
120
283
|
# find the NodeList reference list
|
@@ -227,8 +390,6 @@ module Albacore
|
|
227
390
|
p
|
228
391
|
end
|
229
392
|
|
230
|
-
|
231
|
-
|
232
393
|
# Reads assembly version information
|
233
394
|
# Returns 1.0.0.0 if AssemblyVersion is not found
|
234
395
|
# @return string
|
@@ -242,11 +403,11 @@ module Albacore
|
|
242
403
|
rescue
|
243
404
|
'1.0.0.0'
|
244
405
|
end
|
245
|
-
|
246
406
|
end
|
247
407
|
|
248
408
|
|
249
|
-
|
409
|
+
private
|
410
|
+
|
250
411
|
def nuget_packages
|
251
412
|
return nil unless has_packages_config?
|
252
413
|
doc = Nokogiri.XML(open(package_config))
|
@@ -262,9 +423,27 @@ module Albacore
|
|
262
423
|
|
263
424
|
def all_paket_deps
|
264
425
|
return @all_paket_deps if @all_paket_deps
|
265
|
-
|
266
|
-
|
426
|
+
|
427
|
+
path = if File.exists?('paket.lock') then
|
428
|
+
'paket.lock'
|
429
|
+
else
|
430
|
+
File.join(@proj_path_base, "paket.lock")
|
431
|
+
end
|
432
|
+
|
433
|
+
arr = File.open(path, 'r') do |io|
|
434
|
+
lines = io.readlines.map(&:chomp)
|
435
|
+
Albacore::Paket.parse_paket_lock(lines)
|
436
|
+
.map { |depid, dep|
|
437
|
+
[ depid,
|
438
|
+
target_frameworks.map { |fw|
|
439
|
+
dep2 = OpenStruct.new dep
|
440
|
+
dep2[:target_framework] = fw
|
441
|
+
dep2
|
442
|
+
}
|
443
|
+
]
|
444
|
+
}
|
267
445
|
end
|
446
|
+
|
268
447
|
@all_paket_deps = Hash[arr]
|
269
448
|
end
|
270
449
|
|
@@ -275,7 +454,8 @@ module Albacore
|
|
275
454
|
|
276
455
|
if has_paket_refs?
|
277
456
|
File.open paket_refs, 'r' do |io|
|
278
|
-
io.readlines.map(&:chomp)
|
457
|
+
lines = io.readlines.map(&:chomp)
|
458
|
+
lines.compact.each do |line|
|
279
459
|
paket_package_by_id! line, all_refs, 'referenced'
|
280
460
|
end
|
281
461
|
end
|
@@ -283,20 +463,21 @@ module Albacore
|
|
283
463
|
|
284
464
|
if has_paket_deps?
|
285
465
|
File.open paket_deps, 'r' do |io|
|
286
|
-
io.readlines.map(&:chomp)
|
466
|
+
lines = io.readlines.map(&:chomp)
|
467
|
+
Albacore::Paket.parse_dependencies_file(lines).each do |line|
|
287
468
|
paket_package_by_id! line, all_refs, 'dependent'
|
288
469
|
end
|
289
470
|
end
|
290
471
|
end
|
291
472
|
|
292
|
-
all_refs
|
473
|
+
all_refs.uniq
|
293
474
|
end
|
294
475
|
|
295
476
|
def paket_package_by_id! id, arr, ref_type
|
296
|
-
|
297
|
-
if
|
477
|
+
pkgs = all_paket_deps[id]
|
478
|
+
if ! pkgs.nil? && pkgs.length > 0
|
298
479
|
debug { "found #{ref_type} package '#{id}' [project: paket_packages]" }
|
299
|
-
arr
|
480
|
+
arr.concat(pkgs)
|
300
481
|
else
|
301
482
|
warn { "found #{ref_type} package '#{id}' not in paket.lock [project: paket_packages]" }
|
302
483
|
end
|
@@ -306,9 +487,11 @@ module Albacore
|
|
306
487
|
warn { "project '#{@proj_filename}' has no name" } unless name
|
307
488
|
end
|
308
489
|
|
309
|
-
def read_property prop_name
|
310
|
-
|
311
|
-
|
490
|
+
def read_property prop_name, conf='Debug', platform='AnyCPU'
|
491
|
+
specific = @proj_xml_node.css("Project PropertyGroup[Condition*='#{conf}|#{platform}'] #{prop_name}")
|
492
|
+
chosen = if specific.empty? then @proj_xml_node.css("Project PropertyGroup #{prop_name}") else specific end
|
493
|
+
first = chosen.first
|
494
|
+
if first.nil? then nil else first.inner_text end
|
312
495
|
end
|
313
496
|
|
314
497
|
# find the node of pkg_id
|
@@ -1,478 +1,126 @@
|
|
1
1
|
require 'rake'
|
2
|
-
require 'nokogiri'
|
3
|
-
require 'fileutils'
|
4
|
-
require 'pathname'
|
5
2
|
require 'albacore'
|
6
|
-
require 'albacore/
|
3
|
+
require 'albacore/package'
|
7
4
|
require 'albacore/cmd_config'
|
8
5
|
require 'albacore/config_dsl'
|
9
6
|
require 'albacore/cross_platform_cmd'
|
10
7
|
require 'albacore/project'
|
11
8
|
require 'albacore/logging'
|
12
9
|
require 'albacore/nuget_model'
|
13
|
-
require 'albacore/task_types/nugets'
|
14
10
|
|
15
11
|
module Albacore
|
16
12
|
module NugetsPack
|
17
|
-
# the nuget command
|
18
|
-
class Cmd
|
19
|
-
include CrossPlatformCmd
|
20
|
-
|
21
|
-
# executable => the nuget executable
|
22
|
-
def initialize executable, *args
|
23
|
-
opts = Map.options args
|
24
|
-
raise ArgumentError, 'out is nil' if opts.getopt(:out).nil?
|
25
|
-
|
26
|
-
@work_dir = opts.getopt :work_dir, default: nil
|
27
|
-
@executable = executable
|
28
|
-
@parameters = [%W{Pack -OutputDirectory #{opts.get(:out)}}].flatten
|
29
|
-
@opts = opts
|
30
|
-
|
31
|
-
mono_command unless opts.get(:mono_opt_out)
|
32
|
-
end
|
33
|
-
|
34
|
-
# run nuget on the nuspec to create a new package
|
35
|
-
# returns: a tuple-array of the package and the symbol package
|
36
|
-
# of which the symbol package is nil if it was not generated
|
37
|
-
def execute nuspec_file, nuspec_symbols_file = nil
|
38
|
-
debug "NugetsPack::Cmd#execute, opts: #{@opts} [nugets pack: cmd]"
|
39
|
-
original_pars = @parameters.dup
|
40
|
-
|
41
|
-
pars = original_pars.dup
|
42
|
-
pars << nuspec_file
|
43
|
-
pars << '-NoPackageAnalysis' unless @opts.get :package_analysis
|
44
|
-
pkg = get_nuget_path_of do
|
45
|
-
system @executable, pars, :work_dir => @work_dir
|
46
|
-
end
|
47
|
-
|
48
|
-
debug "package at '#{pkg}'"
|
49
|
-
|
50
|
-
# if the symbols flag is set and there's a symbols file specified
|
51
|
-
# then run NuGet.exe to generate the .symbols.nupkg file
|
52
|
-
if nuspec_symbols_file
|
53
|
-
pars = original_pars.dup
|
54
|
-
pars << '-Symbols'
|
55
|
-
pars << nuspec_symbols_file
|
56
|
-
spkg = with_subterfuge pkg do
|
57
|
-
get_nuget_path_of do
|
58
|
-
system @executable, pars, :work_dir => @work_dir
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
debug "symbol package at '#{spkg}'"
|
63
|
-
|
64
|
-
[pkg, spkg]
|
65
|
-
else
|
66
|
-
info "symbols not configured for generation, use Config#gen_symbols to do so [nugets pack: cmd]"
|
67
|
-
[pkg, nil]
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
private
|
72
|
-
|
73
|
-
# regexpes the package path from the output
|
74
|
-
def get_nuget_path_of
|
75
|
-
out = yield
|
76
|
-
out.match(/Successfully created package '([:\s\p{Word}\\\/\d\.\-]+\.symbols\.nupkg)'./iu) if out.respond_to? :match
|
77
|
-
trace "Got symbols return value: '#{out}', matched: '#{$1}'" if $1
|
78
|
-
return $1 if $1
|
79
|
-
|
80
|
-
out.match(/Successfully created package '([:\s\p{Word}\\\/\d\.\-]+\.nupkg)'./iu)if out.respond_to? :match
|
81
|
-
trace "Got NOT-symbols return value: '#{out}', matched: '#{$1}'"
|
82
|
-
|
83
|
-
unless $1
|
84
|
-
args = ARGV.inject("") { |state, arg| state + " " + '"' + arg + '"' }
|
85
|
-
warn do
|
86
|
-
%{Couldn't match package, please run
|
87
|
-
bundle exec rake DEBUG=true #{args} --trace
|
88
|
-
and report a bug to albacore with the full output. Here's the nuget process output:
|
89
|
-
--- START OUTPUT ---
|
90
|
-
#{out}
|
91
|
-
--- END OUTPUT ---
|
92
|
-
}
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
$1
|
97
|
-
end
|
98
|
-
|
99
|
-
# hide the original like a ninja while NuGet whimpers in a corner
|
100
|
-
def with_subterfuge pkg
|
101
|
-
FileUtils.mv pkg, "#{pkg}.tmp" if pkg && File.exists?(pkg)
|
102
|
-
res = yield
|
103
|
-
FileUtils.mv "#{pkg}.tmp", pkg if pkg && File.exists?("#{pkg}.tmp")
|
104
|
-
res
|
105
|
-
end
|
106
|
-
end
|
107
13
|
|
108
|
-
# This tasktype allows you to quickly package project files to nuget
|
109
|
-
# packages.
|
110
|
-
#
|
111
|
-
# Point files to the project files, that should be in MsBuild XML.
|
112
|
-
#
|
113
|
-
# Examples
|
114
|
-
#
|
115
|
-
# nugets_pack :pack => ['build/pkg', :versioning] do |p|
|
116
|
-
# p.files = FileList['src/**/*.csproj']
|
117
|
-
# p.out = 'build/pkg'
|
118
|
-
# p.exe = 'buildsupport/NuGet.exe'
|
119
|
-
# p.with_metadata do |m|
|
120
|
-
# m.version = ENV['NUGET_VERSION']
|
121
|
-
# end
|
122
|
-
# p.gen_symbols
|
123
|
-
# p.no_project_dependencies
|
124
|
-
# end
|
125
14
|
class Config
|
126
15
|
include CmdConfig
|
127
|
-
self.extend ConfigDSL
|
128
|
-
|
129
|
-
# the output directory to place the newfangled nugets in
|
130
|
-
attr_path :out
|
131
|
-
|
132
|
-
# the .net target (e.g. net40, mono20, mono3, etc)
|
133
|
-
attr_writer :target
|
134
|
-
|
135
|
-
# sets the files to search
|
136
|
-
attr_writer :files
|
137
|
-
|
138
|
-
# sets the nuspec file
|
139
|
-
attr_writer :nuspec
|
140
|
-
|
141
|
-
|
142
|
-
# sets the MsBuild configuration that is used to produce the output into
|
143
|
-
# <OutputPath>...</OutputPath>
|
144
|
-
attr_writer :configuration
|
145
16
|
|
146
17
|
def initialize
|
147
|
-
@
|
148
|
-
@
|
149
|
-
@
|
150
|
-
@
|
151
|
-
@
|
152
|
-
@
|
153
|
-
@leave_nuspec = false
|
154
|
-
@mono_opt_out = false
|
155
|
-
fill_required
|
156
|
-
end
|
157
|
-
|
158
|
-
def mono_opt_out
|
159
|
-
@mono_opt_out = true
|
18
|
+
@symbols = true
|
19
|
+
@transitive = true
|
20
|
+
@pin = false
|
21
|
+
@exe = '.paket/paket.exe'
|
22
|
+
@files = []
|
23
|
+
@metadata = Albacore::NugetModel::Metadata.new
|
160
24
|
end
|
161
25
|
|
162
|
-
|
163
|
-
|
164
|
-
|
26
|
+
attr_accessor :configuration
|
27
|
+
attr_accessor :exe
|
28
|
+
attr_accessor :output
|
29
|
+
attr_accessor :files
|
30
|
+
attr_accessor :metadata
|
165
31
|
|
166
|
-
|
167
|
-
|
168
|
-
yield @package
|
32
|
+
def not_symbols
|
33
|
+
@symbols = false
|
169
34
|
end
|
170
35
|
|
171
|
-
|
172
|
-
|
173
|
-
def gen_symbols
|
174
|
-
@symbols = true
|
36
|
+
def symbols?
|
37
|
+
@symbols
|
175
38
|
end
|
176
39
|
|
177
|
-
|
178
|
-
|
179
|
-
def leave_nuspec
|
180
|
-
@leave_nuspec = true
|
40
|
+
def not_transitive
|
41
|
+
@transitive = false
|
181
42
|
end
|
182
43
|
|
183
|
-
|
184
|
-
|
185
|
-
def no_project_dependencies
|
186
|
-
@project_dependencies = false
|
44
|
+
def transitive?
|
45
|
+
@transitive
|
187
46
|
end
|
188
47
|
|
189
|
-
|
190
|
-
|
191
|
-
def no_nuget_dependencies
|
192
|
-
@nuget_dependencies = false
|
48
|
+
def pin
|
49
|
+
@pin = true
|
193
50
|
end
|
194
51
|
|
195
|
-
|
196
|
-
|
197
|
-
def no_package_analysis
|
198
|
-
@package_analysis = false
|
52
|
+
def pin?
|
53
|
+
@pin
|
199
54
|
end
|
200
55
|
|
201
|
-
def
|
202
|
-
@
|
56
|
+
def method_missing(m, *args, &block)
|
57
|
+
@metadata.send(m, *args, &block)
|
203
58
|
end
|
204
59
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
unless @nuspec
|
210
|
-
[:authors, :description, :version].each do |required|
|
211
|
-
warn "metadata##{required} is missing from nugets_pack [nugets pack: config]" if @package.metadata.send(required) == 'MISSING'
|
212
|
-
end
|
60
|
+
def validate
|
61
|
+
if configuration.nil?
|
62
|
+
raise '"configuration" is a required property'
|
213
63
|
end
|
214
|
-
|
215
|
-
|
216
|
-
:out => @out,
|
217
|
-
:nuspec => @nuspec,
|
218
|
-
:exe => @exe,
|
219
|
-
:symbols => @symbols,
|
220
|
-
:package => @package,
|
221
|
-
:target => @target,
|
222
|
-
:files => files,
|
223
|
-
:configuration => @configuration,
|
224
|
-
:project_dependencies => @project_dependencies,
|
225
|
-
:nuget_dependencies => @nuget_dependencies,
|
226
|
-
:package_analysis => @package_analysis,
|
227
|
-
:mono_opt_out => @mono_opt_out,
|
228
|
-
:original_path => FileUtils.pwd,
|
229
|
-
:leave_nuspec => @leave_nuspec
|
230
|
-
})
|
231
|
-
end
|
232
|
-
|
233
|
-
private
|
234
|
-
|
235
|
-
def fill_required
|
236
|
-
# see http://docs.nuget.org/docs/reference/nuspec-reference
|
237
|
-
with_metadata do |m|
|
238
|
-
m.authors = m.description = m.version = 'MISSING'
|
64
|
+
if version.nil?
|
65
|
+
raise '"version" is a required property'
|
239
66
|
end
|
240
67
|
end
|
241
68
|
end
|
242
69
|
|
243
|
-
|
244
|
-
|
245
|
-
include Logging
|
246
|
-
|
247
|
-
def initialize opts, &before_execute
|
248
|
-
|
249
|
-
unless opts.get(:nuspec)
|
250
|
-
raise ArgumentError, 'opts is not a map' unless opts.is_a? Map
|
251
|
-
raise ArgumentError, 'no files given' unless opts.get(:files).length > 0
|
252
|
-
end
|
70
|
+
class Cmd
|
71
|
+
include CrossPlatformCmd
|
253
72
|
|
254
|
-
|
255
|
-
@
|
256
|
-
@
|
73
|
+
def initialize config
|
74
|
+
@executable = config.exe
|
75
|
+
@config = config
|
257
76
|
end
|
258
77
|
|
259
78
|
def execute
|
260
|
-
|
261
|
-
|
262
|
-
@
|
263
|
-
proj, n, ns = generate_nuspec p, knowns
|
264
|
-
execute_inner! proj, n, ns
|
265
|
-
end
|
266
|
-
else
|
267
|
-
create_nuget! "#{Dir.pwd}", @opts.get(:nuspec)
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
def path_to path, cwd
|
272
|
-
if (Pathname.new path).absolute?
|
273
|
-
return path
|
274
|
-
else
|
275
|
-
return File.expand_path( File.join(@opts.get(:original_path), path), cwd )
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
# generate all nuspecs
|
280
|
-
def generate_nuspecs
|
281
|
-
nuspecs = {}
|
282
|
-
knowns = compute_knowns
|
283
|
-
@files.each do |p|
|
284
|
-
proj, n, ns = generate_nuspec p, knowns
|
285
|
-
nuspecs[proj.name] = OpenStruct.new({:proj => proj, :nuspec => n, :nuspec_symbols => ns })
|
79
|
+
@config.validate
|
80
|
+
invocations(@config).each do |parameters|
|
81
|
+
system @executable, parameters, clr_command: true
|
286
82
|
end
|
287
|
-
nuspecs
|
288
83
|
end
|
289
84
|
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
rescue => e
|
310
|
-
err (e.inspect)
|
311
|
-
raise $!
|
312
|
-
ensure
|
313
|
-
trace do
|
314
|
-
%{
|
315
|
-
PROJECT #{proj.name} nuspec:
|
316
|
-
#{nuspec.to_xml}
|
317
|
-
PROJECT #{proj.name} symbol nuspec:
|
318
|
-
#{if nuspec_symbols then nuspec_symbols.to_xml else 'NO SYMBOLS' end}}
|
319
|
-
end
|
320
|
-
|
321
|
-
# now remove them all
|
322
|
-
[nuspec_path, nuspec_symbols_path].each{|n| cleanup_nuspec n}
|
323
|
-
end
|
324
|
-
|
325
|
-
## Creating
|
326
|
-
|
327
|
-
def create_nuspec proj, knowns
|
328
|
-
version = @opts.get(:package).metadata.version
|
329
|
-
framework_dependencies = @opts.get(:package).metadata.framework_assemblies
|
330
|
-
project_dependencies = @opts.get(:project_dependencies, true)
|
331
|
-
nuget_dependencies = @opts.get(:nuget_dependencies, true)
|
332
|
-
target = if '' == @opts.get(:target) then proj.target_framework else @opts.get :target end
|
333
|
-
if target.start_with? 'v'
|
334
|
-
target = "net#{target[1..target.size].gsub('.', '')}"
|
335
|
-
end
|
336
|
-
|
337
|
-
trace "creating NON-SYMBOL package for '#{proj.name}', targeting '#{target}' [nugets pack: task]"
|
338
|
-
nuspec = Albacore::NugetModel::Package.from_xxproj proj,
|
339
|
-
symbols: false,
|
340
|
-
verify_files: true,
|
341
|
-
dotnet_version: target,
|
342
|
-
known_projects: knowns,
|
343
|
-
version: version,
|
344
|
-
configuration: (@opts.get(:configuration)),
|
345
|
-
project_dependencies: project_dependencies,
|
346
|
-
nuget_dependencies: nuget_dependencies,
|
347
|
-
framework_dependencies: framework_dependencies
|
348
|
-
|
349
|
-
# take data from package as configured in Rakefile, choosing what is in
|
350
|
-
# Rakefile over what is in projfile.
|
351
|
-
nuspec = nuspec.merge_with @opts.get(:package)
|
352
|
-
trace { "nuspec: #{nuspec.to_s} [nugets pack: task]" }
|
353
|
-
|
354
|
-
if @opts.get(:symbols)
|
355
|
-
trace { "creating SYMBOL package for '#{proj.name}' [nugets pack: task]" }
|
356
|
-
nuspec_symbols = Albacore::NugetModel::Package.from_xxproj proj,
|
357
|
-
symbols: true,
|
358
|
-
verify_files: true,
|
359
|
-
dotnet_version: target,
|
360
|
-
known_projects: knowns,
|
361
|
-
version: version,
|
362
|
-
configuration: (@opts.get(:configuration)),
|
363
|
-
project_dependencies: project_dependencies,
|
364
|
-
nuget_dependencies: nuget_dependencies,
|
365
|
-
framework_dependencies: framework_dependencies
|
366
|
-
|
367
|
-
nuspec_symbols = nuspec_symbols.merge_with @opts.get(:package)
|
368
|
-
trace { "nuspec symbols: #{nuspec_symbols.to_s} [nugets pack: task]" }
|
369
|
-
|
370
|
-
[nuspec, nuspec_symbols]
|
85
|
+
private
|
86
|
+
def defaults config
|
87
|
+
parameters = []
|
88
|
+
parameters = %w|pack|
|
89
|
+
parameters << config.output unless config.output.nil?
|
90
|
+
parameters << '--version' unless config.version.nil?
|
91
|
+
parameters << config.version unless config.version.nil?
|
92
|
+
parameters << '--build-config'
|
93
|
+
parameters << config.configuration
|
94
|
+
parameters << '--include-referenced-projects' if config.transitive?
|
95
|
+
parameters << '--symbols' if config.symbols?
|
96
|
+
parameters << '--project-url' if config.project_url
|
97
|
+
parameters << config.project_url if config.project_url
|
98
|
+
parameters
|
99
|
+
end
|
100
|
+
|
101
|
+
def invocations config
|
102
|
+
if config.files.empty?
|
103
|
+
[ defaults(config) ]
|
371
104
|
else
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
def write_nuspec! proj, nuspec, symbols
|
378
|
-
raise ArgumentError, "no nuspect metadata id, project at path: #{proj.proj_path_base}, nuspec: #{nuspec.inspect}" unless nuspec.metadata.id
|
379
|
-
nuspec_path = File.join(proj.proj_path_base, nuspec.metadata.id + "#{ symbols ? '.symbols' : '' }.nuspec")
|
380
|
-
|
381
|
-
File.write(nuspec_path, nuspec.to_xml)
|
382
|
-
|
383
|
-
nuspec_path
|
384
|
-
end
|
105
|
+
config.files.map do |file|
|
106
|
+
proj = Albacore::Project.new file
|
107
|
+
package = Albacore::NugetModel::Package.from_xxproj proj,
|
108
|
+
configuration: config.configuration,
|
109
|
+
metadata: config.metadata
|
385
110
|
|
386
|
-
|
387
|
-
# create the command
|
388
|
-
exe = path_to(@opts.get(:exe), cwd)
|
389
|
-
out = path_to(@opts.get(:out), cwd)
|
390
|
-
nuspec = path_to nuspec, cwd
|
391
|
-
nuspec_symbols = path_to nuspec_symbols, cwd if nuspec_symbols
|
111
|
+
path = File.join(proj.proj_path_base, "paket.template")
|
392
112
|
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
package_analysis: @opts.get(:package_analysis),
|
397
|
-
mono_opt_out: @opts.get(:mono_opt_out)
|
398
|
-
|
399
|
-
|
400
|
-
# run any concerns that modify the command
|
401
|
-
@before_execute.call cmd if @before_execute
|
402
|
-
|
403
|
-
debug { "generating nuspec at #{nuspec}, and symbols (possibly) at '#{nuspec_symbols}' [nugets pack: task]" }
|
404
|
-
|
405
|
-
# run the command for the file
|
406
|
-
pkg, spkg = cmd.execute nuspec, nuspec_symbols
|
407
|
-
|
408
|
-
publish_artifact nuspec, pkg
|
409
|
-
publish_artifact nuspec_symbols, spkg if spkg && nuspec_symbols
|
410
|
-
end
|
411
|
-
|
412
|
-
## Cleaning up after generation
|
413
|
-
|
414
|
-
def cleanup_nuspec nuspec
|
415
|
-
return if nuspec.nil? or not File.exists? nuspec
|
416
|
-
return if @opts.get :leave_nuspec, false
|
417
|
-
File.delete nuspec
|
418
|
-
end
|
419
|
-
|
420
|
-
def publish_artifact nuspec, nuget
|
421
|
-
Albacore.publish :artifact, OpenStruct.new(
|
422
|
-
:nuspec => nuspec,
|
423
|
-
:nupkg => nuget,
|
424
|
-
:location => nuget
|
425
|
-
)
|
426
|
-
end
|
427
|
-
|
428
|
-
def self.accept? f
|
429
|
-
File.extname(f).downcase != '.nuspec'
|
430
|
-
end
|
431
|
-
end
|
432
|
-
|
433
|
-
# generate a nuget from a nuspec
|
434
|
-
class NuspecTask
|
435
|
-
include Logging
|
436
|
-
|
437
|
-
def initialize command_line, config, nuspec
|
438
|
-
@config = config
|
439
|
-
@nuspec = nuspec
|
440
|
-
# is a NuspecPack::Cmd
|
441
|
-
@command_line = command_line
|
442
|
-
end
|
113
|
+
File.open(path, 'w') do |template|
|
114
|
+
template.write package.to_template
|
115
|
+
end
|
443
116
|
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
nodes = xml.xpath('.//metadata/version')
|
450
|
-
raise "No <version/> found" if nodes.empty?
|
451
|
-
nodes.first.text()
|
452
|
-
rescue => error
|
453
|
-
err "Error reading package version from file: #{error}"
|
454
|
-
raise
|
117
|
+
parameters = defaults config
|
118
|
+
parameters << '--template'
|
119
|
+
parameters << path
|
120
|
+
[ parameters ]
|
121
|
+
end
|
455
122
|
end
|
456
123
|
end
|
457
|
-
|
458
|
-
def execute
|
459
|
-
version = read_version_from_nuspec
|
460
|
-
filename = File.basename(@nuspec, File.extname(@nuspec))
|
461
|
-
|
462
|
-
@command_line.execute @nuspec
|
463
|
-
|
464
|
-
path = File.join(@config.opts.get(:out), "#{filename}.#{version}.nupkg")
|
465
|
-
|
466
|
-
Albacore.publish :artifact, OpenStruct.new(
|
467
|
-
:nuspec => @nuspec,
|
468
|
-
:nupkg => path,
|
469
|
-
:location => path
|
470
|
-
)
|
471
|
-
end
|
472
|
-
|
473
|
-
def self.accept? file
|
474
|
-
File.extname(file).downcase == '.nuspec'
|
475
|
-
end
|
476
124
|
end
|
477
125
|
end
|
478
|
-
end
|
126
|
+
end
|