Skip to content

Commit

Permalink
[paket] started added configuration
Browse files Browse the repository at this point in the history
Ref #174
  • Loading branch information
haf committed Feb 13, 2016
1 parent 149f3ad commit 7640643
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 72 deletions.
29 changes: 18 additions & 11 deletions lib/albacore/task_types/nugets_pack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ def execute nuspec_file, nuspec_symbols_file = nil
# if the symbols flag is set and there's a symbols file specified
# then run NuGet.exe to generate the .symbols.nupkg file
if nuspec_symbols_file
pars = original_pars.dup
pars << '-Symbols'
pars << nuspec_symbols_file
pars = original_pars.dup
pars << '-Symbols'
pars << nuspec_symbols_file
spkg = with_subterfuge pkg do
get_nuget_path_of do
system @executable, pars, :work_dir => @work_dir
Expand All @@ -74,11 +74,11 @@ def execute nuspec_file, nuspec_symbols_file = nil
# regexpes the package path from the output
def get_nuget_path_of
out = yield
out.match /Successfully created package '([:\s\p{Word}\\\/\d\.\-]+\.symbols\.nupkg)'./iu if out.respond_to? :match
out.match(/Successfully created package '([:\s\p{Word}\\\/\d\.\-]+\.symbols\.nupkg)'./iu) if out.respond_to? :match
trace "Got symbols return value: '#{out}', matched: '#{$1}'" if $1
return $1 if $1

out.match /Successfully created package '([:\s\p{Word}\\\/\d\.\-]+\.nupkg)'./iu if out.respond_to? :match
out.match(/Successfully created package '([:\s\p{Word}\\\/\d\.\-]+\.nupkg)'./iu) if out.respond_to? :match
trace "Got NOT-symbols return value: '#{out}', matched: '#{$1}'"

unless $1
Expand Down Expand Up @@ -107,7 +107,7 @@ def with_subterfuge pkg
res
end
end

# This tasktype allows you to quickly package project files to nuget
# packages.
#
Expand Down Expand Up @@ -149,6 +149,7 @@ def initialize
@project_dependencies = true
@nuget_dependencies = true
@leave_nuspec = false
@use_paket = true
fill_required
end

Expand Down Expand Up @@ -185,6 +186,12 @@ def no_nuget_dependencies
@nuget_dependencies = false
end

# Call this if you want to use the legacy NuGet.exe infrastructure instead
# of the more modern Paket infrastructure
def use_legacy_exe
@use_paket = false
end

def nuget_gem_exe
@exe = Albacore::Nugets::find_nuget_gem_exe
end
Expand All @@ -194,7 +201,7 @@ def opts
files = @files.respond_to?(:each) ? @files : [@files]

[:authors, :description, :version].each do |required|
warn "metadata##{required} is missing from nugets_pack [nugets pack: config]" if @package.metadata.send(required) == 'MISSING'
warn "metadata##{required} is missing from nugets_pack [nugets pack: config]" if @package.metadata.send(required) == 'MISSING'
end

Map.new({
Expand All @@ -203,7 +210,7 @@ def opts
:symbols => @symbols,
:package => @package,
:target => @target,
:files => @files,
:files => files,
:configuration => @configuration,
:project_dependencies => @project_dependencies,
:nuget_dependencies => @nuget_dependencies,
Expand Down Expand Up @@ -308,7 +315,7 @@ def create_nuspec proj, knowns
target = @opts.get :target

trace "creating NON-SYMBOL package for '#{proj.name}', targeting '#{target}' [nugets pack: task]"
nuspec = Albacore::NugetModel::Package.from_xxproj proj,
nuspec = Albacore::NugetModel::Package.from_xxproj proj,
symbols: false,
verify_files: true,
dotnet_version: target,
Expand Down Expand Up @@ -389,14 +396,14 @@ def publish_artifact nuspec, nuget
:nuspec => nuspec,
:nupkg => nuget,
:location => nuget
)
)
end

def self.accept? f
File.extname(f).downcase != '.nuspec'
end
end

# generate a nuget from a nuspec
class NuspecTask
include Logging
Expand Down
56 changes: 0 additions & 56 deletions spec/nugets_pack_shared.rb

This file was deleted.

9 changes: 7 additions & 2 deletions spec/nugets_pack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require 'spec_helper'
require 'shared_contexts'
require 'support/sh_interceptor'
require 'nugets_pack_shared'
require 'albacore'
require 'albacore/task_types/nugets_pack'
require 'albacore/nuget_model'
Expand All @@ -14,7 +13,13 @@
it 'should be set to path that exists' do
subject.nuget_gem_exe
expect(subject.exe).to be_a String
expect(File.exists?( subject.exe)).to be true
expect(File.exists?(subject.exe)).to be true
end

# this denotes that the user wishes to use the buggy NuGet.exe instead of
# paket
it 'should respond to #use_legacy_exe' do
expect(subject).to respond_to :use_legacy_exe
end
end

Expand Down
1 change: 0 additions & 1 deletion spec/project_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

require 'spec_helper'
require 'shared_contexts'
require 'nugets_pack_shared'
require 'support/sh_interceptor'
require 'albacore'
require 'albacore/task_types/nugets_pack'
Expand Down
61 changes: 59 additions & 2 deletions spec/shared_contexts.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,62 @@
# encoding: utf-8

require 'albacore/paths'

class ConfigFac
def self.create id, curr, gen_symbols = true
cfg = Albacore::NugetsPack::Config.new
cfg.target = 'mono32'
cfg.configuration = 'Debug'
cfg.files = Dir.glob(File.join(curr, 'testdata', 'Project', '*.fsproj'))
cfg.out = 'spec/testdata/pkg'
cfg.exe = 'NuGet.exe'
cfg.with_metadata do |m|
m.id = id
m.authors = 'haf'
m.owners = 'haf owner'
m.description = 'a nice lib'
m.language = 'Danish'
m.project_url = 'https://github.com/haf/Reasonable'
m.license_url = 'https://github.com/haf/README.md'
m.version = '0.2.3'
m.release_notes = %{
v10.0.0:
- Some notes
}
m.require_license_acceptance = false

m.add_dependency 'Abc.Package', '>= 1.0.2'
m.add_framework_dependency 'System.Transactions', '4.0.0'
end
cfg.gen_symbols if gen_symbols # files: *.{pdb,dll,all compiled files}
cfg
end
end

shared_context 'pack_config' do
let :id do
'Sample.Nuget'
end
let :curr do
File.dirname(__FILE__)
end
let :config do
ConfigFac.create id, curr, true
end
end

shared_context 'pack_config no symbols' do
let :id do
'Sample.Nuget'
end
let :curr do
File.dirname(__FILE__)
end
let :config do
ConfigFac.create id, curr, false
end
end

shared_context 'package_metadata_dsl' do
let :m do
subject.metadata
Expand Down Expand Up @@ -41,7 +98,7 @@ def self.has_file src, target, exclude = nil
it "has file[#{src}].target == '#{target}'" do
file = subject.files.find { |f| f.src == src }
expect(file.target).to eq target
end
end
end

def self.has_not_file src
Expand All @@ -54,6 +111,6 @@ def self.has_not_file src

def self.norm str
Albacore::Paths.normalise_slashes str
end
end
end

0 comments on commit 7640643

Please sign in to comment.