Albacore / albacore

Albacore is a professional quality suite of Rake tasks for building .NET or Mono based systems.
www.albacorebuild.net
221 stars 64 forks source link

Cannot build from nuspec on Windows #198

Closed munkyjunky closed 7 years ago

munkyjunky commented 8 years ago

I'm trying to get albacore working on my Windows machine and am having issues with nugets_pack. I've based my rakefile off that generated by albacore init.

Rakefile

require 'bundler/setup'
require 'albacore'
require 'albacore/ext/teamcity'

nugets_pack :default do |p|
  p.files   = FileList['**/*.nuspec']
  p.with_metadata do |m|
    m.id          = 'MyProj'
    m.title       = 'TODO'
    m.description = 'TODO'
    m.authors     = 'John Doe, Foretag AB'
    m.project_url = 'http://example.com'
    m.tags        = ''
    m.version     = ENV['NUGET_VERSION']
  end
end

Nuspec (in src/ folder in my project, named build.nuspec)

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
  <metadata>
    <id>albacore-test</id>
    <version>0.0.0</version>
    <description>A test nuspec for albacore</description>
    <authors>test</authors>
  </metadata>
  <files>
    <file src="*.txt"/>
  </files>
</package>

When running bundle exec rake --trace I get the following output

$ bundle exec rake --trace
** Invoke default (first_time)
** Execute default
W 2016-04-09T15:40:13.537428+01:00: project 'build.nuspec' has no name
W 2016-04-09T15:40:13.537428+01:00: project 'build.nuspec' has no name
fatal: ..: '..' is outside repository
rake aborted!
NoMethodError: undefined method `inner_text' for nil:NilClass
C:/Ruby22/lib/ruby/gems/2.2.0/gems/albacore-2.5.6/lib/albacore/project.rb:89:in `try_output_path'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/albacore-2.5.6/lib/albacore/nuget_model.rb:426:in `get_output_path'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/albacore-2.5.6/lib/albacore/nuget_model.rb:383:in `from_xxproj'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/albacore-2.5.6/lib/albacore/task_types/nugets_pack.rb:311:in `create_nuspec'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/albacore-2.5.6/lib/albacore/task_types/nugets_pack.rb:273:in `generate_nuspec'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/albacore-2.5.6/lib/albacore/task_types/nugets_pack.rb:240:in `block in execute'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/file_list.rb:81:in `each'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/file_list.rb:81:in `each'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/albacore-2.5.6/lib/albacore/task_types/nugets_pack.rb:239:in `execute'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/albacore-2.5.6/lib/albacore/dsl.rb:71:in `block in nugets_pack'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:240:in `call'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:240:in `block in execute'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:235:in `each'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:235:in `execute'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
C:/Ruby22/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/task.rb:165:in `invoke'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:150:in `invoke_task'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:106:in `each'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:106:in `block in top_level'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:115:in `run_with_threads'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:100:in `top_level'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:78:in `block in run'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rake-10.5.0/lib/rake/application.rb:75:in `run'
C:/Ruby22/lib/ruby/gems/2.2.0/gems/rake-10.5.0/bin/rake:33:in `<top (required)>'
C:/Ruby22/bin/rake:23:in `load'
C:/Ruby22/bin/rake:23:in `<main>'
Tasks: TOP => default

I'm not sure if the issue is with the fatal: ..: '..' is outside repository log, or the inner_text causing the problems. Checking in the file mentioned in the logs (project.rb:89) it looks like albacore is trying to get Project.PropertyGroup.Platform from my nuspec, however that property is a csproj property - not a nuget property.

Using ruby 2.2.4, albacore 2.5.6

haf commented 8 years ago
  1. you need to give a name to your nuget, that's what it's warning about ("project 'build.nuspec' has no name")
  2. .nuspec files are badly integration tested, it may be well spent time to add another test-case to the existing test suite for nugets_pack (tests/testdata/Project or a new one can be used)
  3. It's trying to find the platform that you're compiling against to find the correct output path, that's why it's looking at a build-oriented property
  4. Because the nuspec functionality was PRed without integration tests, I believe the basic functionality/logic is there and nicely working, but that the task-type nugets_pack has drifted away from being able to use it correctly; hence the suggestion to create a unit/integration test for it, like already exist for ordinary fsproj/csproj files in the unit tests for this repository
munkyjunky commented 8 years ago

I've tried several ways of adding a name field, but can't see anything in the nuspec docs on how to do this. Is there anything I can change in my Rakefile or nuspec to get this working?

I'm not a ruby developer so there's not much I can do in the way of contributing tests to help get this issue sorted.

haf commented 8 years ago

My recommendation then is that you override the keys in your csproj file <Id>...</Id>. Other than that, if you're using a nuspec file you might as well just do:

task :nugets_pack do
  system 'packages/Nuget.CommandLine/lib/NuGet.exe', %W|pack src/MyProject.nuspec|, clr_command: true
end

and be done with it. :)

haf commented 7 years ago

Closing because of lack of reply.