albacore 2.0.10 → 2.0.11
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/task_types/nugets_pack.rb +421 -405
- data/lib/albacore/version.rb +1 -1
- data/spec/nugets_pack_spec.rb +13 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1308f930ad75cb7e143505c49a53db15aaa988f7
|
4
|
+
data.tar.gz: 74473ea92736a01c725e0bbfb5ed36d2421f2a46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 261d88d30963978abcb8595af5838b52f34c698bbc88fa61bcb207958208e8c4ee2ca494a8578ffab77e837864e81f519d65008128c0eedaa6cf8061177fac42
|
7
|
+
data.tar.gz: 6e347fca7aab405e99592826958a9ff6e069a310b627222f373f57f1ac9612ba3b42fa25f08fcd7d80779cc44546c5962688ac367b5f89a012379214543a4aad
|
@@ -1,405 +1,421 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'nokogiri'
|
3
|
-
require 'fileutils'
|
4
|
-
require 'albacore'
|
5
|
-
require 'albacore/paths'
|
6
|
-
require 'albacore/cmd_config'
|
7
|
-
require 'albacore/config_dsl'
|
8
|
-
require 'albacore/cross_platform_cmd'
|
9
|
-
require 'albacore/project'
|
10
|
-
require 'albacore/logging'
|
11
|
-
require 'albacore/nuget_model'
|
12
|
-
|
13
|
-
module Albacore
|
14
|
-
module NugetsPack
|
15
|
-
# the nuget command
|
16
|
-
class Cmd
|
17
|
-
include CrossPlatformCmd
|
18
|
-
|
19
|
-
# executable => the nuget executable
|
20
|
-
def initialize executable, *args
|
21
|
-
opts = Map.options args
|
22
|
-
raise ArgumentError, 'out is nil' if opts.getopt(:out).nil?
|
23
|
-
|
24
|
-
@work_dir = opts.getopt :work_dir, default: nil
|
25
|
-
@executable = executable
|
26
|
-
@parameters = [%W{Pack -OutputDirectory #{opts.get(:out)}}].flatten
|
27
|
-
@opts = opts
|
28
|
-
|
29
|
-
mono_command
|
30
|
-
end
|
31
|
-
|
32
|
-
# run nuget on the nuspec to create a new package
|
33
|
-
# returns: a tuple-array of the package and the symbol package
|
34
|
-
# of which the symbol package is nil if it was not generated
|
35
|
-
def execute nuspec_file, nuspec_symbols_file = nil
|
36
|
-
debug "NugetsPack::Cmd#execute, opts: #{@opts} [nugets pack: cmd]"
|
37
|
-
original_pars = @parameters.dup
|
38
|
-
|
39
|
-
pars = original_pars.dup
|
40
|
-
pars << nuspec_file
|
41
|
-
pkg = get_nuget_path_of do
|
42
|
-
system @executable, pars, :work_dir => @work_dir
|
43
|
-
end
|
44
|
-
|
45
|
-
debug "package at '#{pkg}'"
|
46
|
-
|
47
|
-
# if the symbols flag is set and there's a symbols file specified
|
48
|
-
# then run NuGet.exe to generate the .symbols.nupkg file
|
49
|
-
if nuspec_symbols_file
|
50
|
-
pars = original_pars.dup
|
51
|
-
pars << '-Symbols'
|
52
|
-
pars << nuspec_symbols_file
|
53
|
-
spkg = with_subterfuge pkg do
|
54
|
-
get_nuget_path_of do
|
55
|
-
system @executable, pars, :work_dir => @work_dir
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
debug "symbol package at '#{spkg}'"
|
60
|
-
|
61
|
-
[pkg, spkg]
|
62
|
-
else
|
63
|
-
info "symbols not configured for generation, use Config#gen_symbols to do so [nugets pack: cmd]"
|
64
|
-
[pkg, nil]
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
private
|
69
|
-
|
70
|
-
# regexpes the package path from the output
|
71
|
-
def get_nuget_path_of
|
72
|
-
out = yield
|
73
|
-
out.match /Successfully created package '([:\s\w\\\/\d
|
74
|
-
trace "Got symbols return value: '#{out}', matched: '#{$1}'" if $1
|
75
|
-
return $1 if $1
|
76
|
-
|
77
|
-
out.match /Successfully created package '([:\s\w\\\/\d\.]+\.nupkg)'./i if out.respond_to? :match
|
78
|
-
trace "Got NOT-symbols return value: '#{out}', matched: '#{$1}'"
|
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
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
def
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
def
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
[
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
end
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
end
|
370
|
-
|
371
|
-
def
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
:
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
1
|
+
require 'rake'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'albacore'
|
5
|
+
require 'albacore/paths'
|
6
|
+
require 'albacore/cmd_config'
|
7
|
+
require 'albacore/config_dsl'
|
8
|
+
require 'albacore/cross_platform_cmd'
|
9
|
+
require 'albacore/project'
|
10
|
+
require 'albacore/logging'
|
11
|
+
require 'albacore/nuget_model'
|
12
|
+
|
13
|
+
module Albacore
|
14
|
+
module NugetsPack
|
15
|
+
# the nuget command
|
16
|
+
class Cmd
|
17
|
+
include CrossPlatformCmd
|
18
|
+
|
19
|
+
# executable => the nuget executable
|
20
|
+
def initialize executable, *args
|
21
|
+
opts = Map.options args
|
22
|
+
raise ArgumentError, 'out is nil' if opts.getopt(:out).nil?
|
23
|
+
|
24
|
+
@work_dir = opts.getopt :work_dir, default: nil
|
25
|
+
@executable = executable
|
26
|
+
@parameters = [%W{Pack -OutputDirectory #{opts.get(:out)}}].flatten
|
27
|
+
@opts = opts
|
28
|
+
|
29
|
+
mono_command
|
30
|
+
end
|
31
|
+
|
32
|
+
# run nuget on the nuspec to create a new package
|
33
|
+
# returns: a tuple-array of the package and the symbol package
|
34
|
+
# of which the symbol package is nil if it was not generated
|
35
|
+
def execute nuspec_file, nuspec_symbols_file = nil
|
36
|
+
debug "NugetsPack::Cmd#execute, opts: #{@opts} [nugets pack: cmd]"
|
37
|
+
original_pars = @parameters.dup
|
38
|
+
|
39
|
+
pars = original_pars.dup
|
40
|
+
pars << nuspec_file
|
41
|
+
pkg = get_nuget_path_of do
|
42
|
+
system @executable, pars, :work_dir => @work_dir
|
43
|
+
end
|
44
|
+
|
45
|
+
debug "package at '#{pkg}'"
|
46
|
+
|
47
|
+
# if the symbols flag is set and there's a symbols file specified
|
48
|
+
# then run NuGet.exe to generate the .symbols.nupkg file
|
49
|
+
if nuspec_symbols_file
|
50
|
+
pars = original_pars.dup
|
51
|
+
pars << '-Symbols'
|
52
|
+
pars << nuspec_symbols_file
|
53
|
+
spkg = with_subterfuge pkg do
|
54
|
+
get_nuget_path_of do
|
55
|
+
system @executable, pars, :work_dir => @work_dir
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
debug "symbol package at '#{spkg}'"
|
60
|
+
|
61
|
+
[pkg, spkg]
|
62
|
+
else
|
63
|
+
info "symbols not configured for generation, use Config#gen_symbols to do so [nugets pack: cmd]"
|
64
|
+
[pkg, nil]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
# regexpes the package path from the output
|
71
|
+
def get_nuget_path_of
|
72
|
+
out = yield
|
73
|
+
out.match /Successfully created package '([:\s\w\\\/\d\.\-]+\.symbols\.nupkg)'./i if out.respond_to? :match
|
74
|
+
trace "Got symbols return value: '#{out}', matched: '#{$1}'" if $1
|
75
|
+
return $1 if $1
|
76
|
+
|
77
|
+
out.match /Successfully created package '([:\s\w\\\/\d\.]+\.nupkg)'./i if out.respond_to? :match
|
78
|
+
trace "Got NOT-symbols return value: '#{out}', matched: '#{$1}'"
|
79
|
+
|
80
|
+
unless $1
|
81
|
+
args = ARGV.inject("") { |state, arg| state + " " + '"' + arg + '"' }
|
82
|
+
warn do
|
83
|
+
%{Couldn't match package, please run
|
84
|
+
|
85
|
+
bundle exec rake DEBUG=true #{args} --trace
|
86
|
+
|
87
|
+
and report a bug to albacore with the full output. Here's the nuget process output:
|
88
|
+
--- START OUTPUT ---
|
89
|
+
#{out}
|
90
|
+
--- END OUTPUT ---
|
91
|
+
}
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
$1
|
96
|
+
end
|
97
|
+
|
98
|
+
# hide the original like a ninja while NuGet whimpers in a corner
|
99
|
+
def with_subterfuge pkg
|
100
|
+
FileUtils.mv pkg, "#{pkg}.tmp" if pkg && File.exists?(pkg)
|
101
|
+
res = yield
|
102
|
+
FileUtils.mv "#{pkg}.tmp", pkg if pkg && File.exists?("#{pkg}.tmp")
|
103
|
+
res
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# This tasktype allows you to quickly package project files to nuget
|
108
|
+
# packages.
|
109
|
+
#
|
110
|
+
# Point files to the project files, that should be in MsBuild XML.
|
111
|
+
#
|
112
|
+
# Examples
|
113
|
+
#
|
114
|
+
# nugets_pack :pack => ['build/pkg', :versioning] do |p|
|
115
|
+
# p.files = FileList['src/**/*.csproj']
|
116
|
+
# p.out = 'build/pkg'
|
117
|
+
# p.exe = 'buildsupport/NuGet.exe'
|
118
|
+
# p.with_metadata do |m|
|
119
|
+
# m.version = ENV['NUGET_VERSION']
|
120
|
+
# end
|
121
|
+
# p.gen_symbols
|
122
|
+
# p.no_project_dependencies
|
123
|
+
# end
|
124
|
+
class Config
|
125
|
+
include CmdConfig
|
126
|
+
self.extend ConfigDSL
|
127
|
+
|
128
|
+
# the output directory to place the newfangled nugets in
|
129
|
+
attr_path :out
|
130
|
+
|
131
|
+
# the .net target (e.g. net40, mono20, mono3, etc)
|
132
|
+
attr_writer :target
|
133
|
+
|
134
|
+
# sets the files to search
|
135
|
+
attr_writer :files
|
136
|
+
|
137
|
+
# sets the MsBuild configuration that is used to produce the output into
|
138
|
+
# <OutputPath>...</OutputPath>
|
139
|
+
attr_writer :configuration
|
140
|
+
|
141
|
+
def initialize
|
142
|
+
@package = Albacore::NugetModel::Package.new
|
143
|
+
@target = 'net40'
|
144
|
+
@symbols = false
|
145
|
+
@project_dependencies = true
|
146
|
+
@leave_nuspec = false
|
147
|
+
fill_required
|
148
|
+
end
|
149
|
+
|
150
|
+
def with_metadata &block
|
151
|
+
yield @package.metadata
|
152
|
+
end
|
153
|
+
|
154
|
+
# configure the package with a block
|
155
|
+
def with_package &block
|
156
|
+
yield @package
|
157
|
+
end
|
158
|
+
|
159
|
+
# generate symbols for the nugets: just call this method to
|
160
|
+
# enable generation
|
161
|
+
def gen_symbols
|
162
|
+
@symbols = true
|
163
|
+
end
|
164
|
+
|
165
|
+
# leave the nuspec behind, don't delete it after generating it
|
166
|
+
#
|
167
|
+
def leave_nuspec
|
168
|
+
@leave_nuspec = true
|
169
|
+
end
|
170
|
+
|
171
|
+
# call this if you want to cancel 'smart' scanning of the *proj
|
172
|
+
# file for its dependencies
|
173
|
+
def no_project_dependencies
|
174
|
+
@project_dependencies = false
|
175
|
+
end
|
176
|
+
|
177
|
+
# gets the options specified for the task, used from the task
|
178
|
+
def opts
|
179
|
+
files = @files.respond_to?(:each) ? @files : [@files]
|
180
|
+
|
181
|
+
[:authors, :description, :version].each do |required|
|
182
|
+
warn "metadata##{required} is missing from nugets_pack [nugets pack: config]" if @package.metadata.send(required) == 'MISSING'
|
183
|
+
end
|
184
|
+
|
185
|
+
Map.new({
|
186
|
+
:out => @out,
|
187
|
+
:exe => @exe,
|
188
|
+
:symbols => @symbols,
|
189
|
+
:package => @package,
|
190
|
+
:target => @target,
|
191
|
+
:files => @files,
|
192
|
+
:configuration => @configuration,
|
193
|
+
:project_dependencies => @project_dependencies,
|
194
|
+
:original_path => FileUtils.pwd,
|
195
|
+
:leave_nuspec => @leave_nuspec
|
196
|
+
})
|
197
|
+
end
|
198
|
+
|
199
|
+
private
|
200
|
+
|
201
|
+
def fill_required
|
202
|
+
# see http://docs.nuget.org/docs/reference/nuspec-reference
|
203
|
+
with_metadata do |m|
|
204
|
+
m.authors = m.description = m.version = 'MISSING'
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
# a task that handles the generation of nugets from projects or nuspecs.
|
210
|
+
class ProjectTask
|
211
|
+
include Logging
|
212
|
+
|
213
|
+
def initialize opts, &before_execute
|
214
|
+
raise ArgumentError, 'opts is not a map' unless opts.is_a? Map
|
215
|
+
raise ArgumentError, 'no files given' unless opts.get(:files).length > 0
|
216
|
+
@opts = opts.apply :out => '.'
|
217
|
+
@files = opts.get :files
|
218
|
+
@before_execute = before_execute
|
219
|
+
end
|
220
|
+
|
221
|
+
def execute
|
222
|
+
knowns = compute_knowns
|
223
|
+
@files.each do |p|
|
224
|
+
proj, n, ns = generate_nuspec p, knowns
|
225
|
+
execute_inner! proj, n, ns
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def path_to relative_file_path, cwd
|
230
|
+
File.expand_path( File.join(@opts.get(:original_path), relative_file_path), cwd )
|
231
|
+
end
|
232
|
+
|
233
|
+
# generate all nuspecs
|
234
|
+
def generate_nuspecs
|
235
|
+
nuspecs = {}
|
236
|
+
knowns = compute_knowns
|
237
|
+
@files.each do |p|
|
238
|
+
proj, n, ns = generate_nuspec p, knowns
|
239
|
+
nuspecs[proj.name] = OpenStruct.new({:proj => proj, :nuspec => n, :nuspec_symbols => ns })
|
240
|
+
end
|
241
|
+
nuspecs
|
242
|
+
end
|
243
|
+
|
244
|
+
private
|
245
|
+
|
246
|
+
def compute_knowns
|
247
|
+
Set.new(@files.map { |f| Albacore::Project.new f }.map { |p| p.name })
|
248
|
+
end
|
249
|
+
|
250
|
+
def generate_nuspec p, knowns
|
251
|
+
proj = Albacore::Project.new p
|
252
|
+
nuspec, nuspec_symbols = create_nuspec proj, knowns
|
253
|
+
[proj, nuspec, nuspec_symbols]
|
254
|
+
end
|
255
|
+
|
256
|
+
# execute, for each project file
|
257
|
+
def execute_inner! proj, nuspec, nuspec_symbols
|
258
|
+
nuspec_path = write_nuspec! proj, nuspec, false
|
259
|
+
nuspec_symbols_path = write_nuspec! proj, nuspec_symbols, true if nuspec_symbols
|
260
|
+
|
261
|
+
create_nuget! proj.proj_path_base, nuspec_path, nuspec_symbols_path
|
262
|
+
rescue => e
|
263
|
+
err (e.inspect)
|
264
|
+
raise $!
|
265
|
+
ensure
|
266
|
+
trace do
|
267
|
+
%{
|
268
|
+
PROJECT #{proj.name} nuspec:
|
269
|
+
|
270
|
+
#{nuspec.to_xml}
|
271
|
+
|
272
|
+
PROJECT #{proj.name} symbol nuspec:
|
273
|
+
|
274
|
+
#{if nuspec_symbols then nuspec_symbols.to_xml else 'NO SYMBOLS' end}}
|
275
|
+
end
|
276
|
+
|
277
|
+
# now remove them all
|
278
|
+
[nuspec_path, nuspec_symbols_path].each{|n| cleanup_nuspec n}
|
279
|
+
end
|
280
|
+
|
281
|
+
## Creating
|
282
|
+
|
283
|
+
def create_nuspec proj, knowns
|
284
|
+
version = @opts.get(:package).metadata.version
|
285
|
+
project_dependencies = @opts.get(:project_dependencies, true)
|
286
|
+
target = @opts.get :target
|
287
|
+
|
288
|
+
trace "creating NON-SYMBOL package for '#{proj.name}', targeting '#{target}' [nugets pack: task]"
|
289
|
+
nuspec = Albacore::NugetModel::Package.from_xxproj proj,
|
290
|
+
symbols: false,
|
291
|
+
verify_files: true,
|
292
|
+
dotnet_version: target,
|
293
|
+
known_projects: knowns,
|
294
|
+
version: version,
|
295
|
+
configuration: (@opts.get(:configuration)),
|
296
|
+
project_dependencies: project_dependencies
|
297
|
+
|
298
|
+
# take data from package as configured in Rakefile, choosing what is in
|
299
|
+
# Rakefile over what is in projfile.
|
300
|
+
nuspec = nuspec.merge_with @opts.get(:package)
|
301
|
+
trace { "nuspec: #{nuspec.to_s} [nugets pack: task]" }
|
302
|
+
|
303
|
+
if @opts.get(:symbols)
|
304
|
+
trace { "creating SYMBOL package for '#{proj.name}' [nugets pack: task]" }
|
305
|
+
nuspec_symbols = Albacore::NugetModel::Package.from_xxproj proj,
|
306
|
+
symbols: true,
|
307
|
+
verify_files: true,
|
308
|
+
dotnet_version: target,
|
309
|
+
known_projects: knowns,
|
310
|
+
version: version,
|
311
|
+
configuration: (@opts.get(:configuration)),
|
312
|
+
project_dependencies: project_dependencies
|
313
|
+
|
314
|
+
nuspec_symbols = nuspec_symbols.merge_with @opts.get(:package)
|
315
|
+
trace { "nuspec symbols: #{nuspec_symbols.to_s} [nugets pack: task]" }
|
316
|
+
|
317
|
+
[nuspec, nuspec_symbols]
|
318
|
+
else
|
319
|
+
trace { "skipping SYMBOL package for #{proj.name} [nugets pack: task]" }
|
320
|
+
[nuspec, nil]
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
def write_nuspec! proj, nuspec, symbols
|
325
|
+
raise ArgumentError, "no nuspect metadata id, project at path: #{proj.proj_path_base}, nuspec: #{nuspec.inspect}" unless nuspec.metadata.id
|
326
|
+
nuspec_path = File.join(proj.proj_path_base, nuspec.metadata.id + "#{ symbols ? '.symbols' : '' }.nuspec")
|
327
|
+
|
328
|
+
File.write(nuspec_path, nuspec.to_xml)
|
329
|
+
|
330
|
+
nuspec_path
|
331
|
+
end
|
332
|
+
|
333
|
+
def create_nuget! cwd, nuspec, nuspec_symbols = nil
|
334
|
+
# create the command
|
335
|
+
exe = path_to(@opts.get(:exe), cwd)
|
336
|
+
out = path_to(@opts.get(:out), cwd)
|
337
|
+
nuspec = path_to nuspec, cwd
|
338
|
+
nuspec_symbols = path_to nuspec_symbols, cwd if nuspec_symbols
|
339
|
+
cmd = Albacore::NugetsPack::Cmd.new exe,
|
340
|
+
work_dir: cwd,
|
341
|
+
out: out
|
342
|
+
|
343
|
+
# run any concerns that modify the command
|
344
|
+
@before_execute.call cmd if @before_execute
|
345
|
+
|
346
|
+
debug { "generating nuspec at #{nuspec}, and symbols (possibly) at '#{nuspec_symbols}' [nugets pack: task]" }
|
347
|
+
|
348
|
+
# run the command for the file
|
349
|
+
pkg, spkg = cmd.execute nuspec, nuspec_symbols
|
350
|
+
|
351
|
+
publish_artifact nuspec, pkg
|
352
|
+
publish_artifact nuspec_symbols, spkg if spkg && nuspec_symbols
|
353
|
+
end
|
354
|
+
|
355
|
+
## Cleaning up after generation
|
356
|
+
|
357
|
+
def cleanup_nuspec nuspec
|
358
|
+
return if nuspec.nil? or not File.exists? nuspec
|
359
|
+
return if @opts.get :leave_nuspec, false
|
360
|
+
File.delete nuspec
|
361
|
+
end
|
362
|
+
|
363
|
+
def publish_artifact nuspec, nuget
|
364
|
+
Albacore.publish :artifact, OpenStruct.new(
|
365
|
+
:nuspec => nuspec,
|
366
|
+
:nupkg => nuget,
|
367
|
+
:location => nuget
|
368
|
+
)
|
369
|
+
end
|
370
|
+
|
371
|
+
def self.accept? f
|
372
|
+
File.extname(f).downcase != '.nuspec'
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
# generate a nuget from a nuspec
|
377
|
+
class NuspecTask
|
378
|
+
include Logging
|
379
|
+
|
380
|
+
def initialize command_line, config, nuspec
|
381
|
+
@config = config
|
382
|
+
@nuspec = nuspec
|
383
|
+
# is a NuspecPack::Cmd
|
384
|
+
@command_line = command_line
|
385
|
+
end
|
386
|
+
|
387
|
+
def read_version_from_nuspec
|
388
|
+
begin
|
389
|
+
nuspec_file = File.open(@nuspec)
|
390
|
+
xml = Nokogiri::XML(nuspec_file)
|
391
|
+
nuspec_file.close
|
392
|
+
nodes = xml.xpath('.//metadata/version')
|
393
|
+
raise "No <version/> found" if nodes.empty?
|
394
|
+
nodes.first.text()
|
395
|
+
rescue => error
|
396
|
+
err "Error reading package version from file: #{error}"
|
397
|
+
raise
|
398
|
+
end
|
399
|
+
end
|
400
|
+
|
401
|
+
def execute
|
402
|
+
version = read_version_from_nuspec
|
403
|
+
filename = File.basename(@nuspec, File.extname(@nuspec))
|
404
|
+
|
405
|
+
@command_line.execute @nuspec
|
406
|
+
|
407
|
+
path = File.join(@config.opts.get(:out), "#{filename}.#{version}.nupkg")
|
408
|
+
|
409
|
+
Albacore.publish :artifact, OpenStruct.new(
|
410
|
+
:nuspec => @nuspec,
|
411
|
+
:nupkg => path,
|
412
|
+
:location => path
|
413
|
+
)
|
414
|
+
end
|
415
|
+
|
416
|
+
def self.accept? file
|
417
|
+
File.extname(file).downcase == '.nuspec'
|
418
|
+
end
|
419
|
+
end
|
420
|
+
end
|
421
|
+
end
|
data/lib/albacore/version.rb
CHANGED
data/spec/nugets_pack_spec.rb
CHANGED
@@ -138,6 +138,14 @@ Successfully created package '/home/xyz/Shared/build/pkg/MyNuget.Package.1.0.0.s
|
|
138
138
|
EXAMPLE_OUTPUT
|
139
139
|
end
|
140
140
|
|
141
|
+
let :sample3 do
|
142
|
+
<<EXAMPLE_OUTPUT
|
143
|
+
Attempting to build package from 'MyNuget.Package.nuspec'.
|
144
|
+
Successfully created package '/home/xyz/Shared/build/pkg/MyNuget.Package.1.0.0-alpha3.nupkg'.
|
145
|
+
Successfully created package '/home/xyz/Shared/build/pkg/MyNuget.Package.1.0.0-alpha3.symbols.nupkg'.
|
146
|
+
EXAMPLE_OUTPUT
|
147
|
+
end
|
148
|
+
|
141
149
|
it "should match sample1 with last nupkg mentioned" do
|
142
150
|
match = subject.send(:get_nuget_path_of) { sample1 }
|
143
151
|
match.should eq('Y:\\Shared\\build\\pkg\\MyNuget.Package.1.0.0.symbols.nupkg')
|
@@ -147,6 +155,11 @@ EXAMPLE_OUTPUT
|
|
147
155
|
match = subject.send(:get_nuget_path_of) { sample2 }
|
148
156
|
match.should eq('/home/xyz/Shared/build/pkg/MyNuget.Package.1.0.0.symbols.nupkg')
|
149
157
|
end
|
158
|
+
|
159
|
+
it 'should match sample3 with last nupkg mentioned' do
|
160
|
+
match = subject.send(:get_nuget_path_of) { sample3 }
|
161
|
+
match.should eq('/home/xyz/Shared/build/pkg/MyNuget.Package.1.0.0-alpha3.symbols.nupkg')
|
162
|
+
end
|
150
163
|
end
|
151
164
|
|
152
165
|
# testing nuspec task
|