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

Too many open files - where "msbuild" 2> nul #240

Open thefernman opened 6 years ago

thefernman commented 6 years ago

After 500 .sln files to build, I get a Too many open files - where "msbuild" 2> nul

Stacktrace:

C:/Projects/project/vendor/bundle/ruby/2.3.0/gems/albacore-3.0.1/lib/albacore/cross_platform_cmd.rb:205:in `popen'
C:/Projects/project/vendor/bundle/ruby/2.3.0/gems/albacore-3.0.1/lib/albacore/cross_platform_cmd.rb:205:in `which'
C:/Projects/project/vendor/bundle/ruby/2.3.0/gems/albacore-3.0.1/lib/albacore/task_types/build.rb:43:in `block in initialize'
C:/Projects/project/vendor/bundle/ruby/2.3.0/gems/albacore-3.0.1/lib/albacore/task_types/build.rb:47:in `initialize'
C:/Projects/project/vendor/bundle/ruby/2.3.0/gems/albacore-3.0.1/lib/albacore/dsl.rb:40:in `new'
C:/Projects/project/vendor/bundle/ruby/2.3.0/gems/albacore-3.0.1/lib/albacore/dsl.rb:40:in `block in build'
C:/Projects/project/vendor/bundle/ruby/2.3.0/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
C:/Projects/project/vendor/bundle/ruby/2.3.0/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
C:/Projects/project/vendor/bundle/ruby/2.3.0/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'

https://github.com/Albacore/albacore/blob/47454a2d51dff3834268b11a7e9b7f0f45c5c0f7/lib/albacore/cross_platform_cmd.rb#L205

Portion of my rakefile

desc 'Build all customers'
task :build_customers do |t|
  logger.info 'Build customer dlls...'
  client_list_paths = Dir.glob(get_relative_path('../customers') + '/**/**/Web')
  client_list_paths.each do |dir|
    clean(dir)
    sln_path = dir + '/../Web.sln'
    out_dir = dir.gsub('/customers/','/build/') + '/Distrib'

    logger.info "Building: #{sln_path} out to #{out_dir}"
    build do |b|
      b.sln  = sln_path                         # alt. name
      b.target = ['Clean', 'Build']             # call with an array of targets or just a single target
      b.prop 'Configuration', 'Release'         # call with 'key, value', to specify a MsBuild property
      b.prop 'OutDir', out_dir                  # call with 'key, value', to specify a MsBuild property
      b.prop 'ToolsVersion' , '4.6'
      b.clp 'ShowEventId'                       # any parameters you want to pass to the console logger of MsBuild
      b.logging = 'm'                           # detailed logging mode. The available verbosity levels are: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]
      b.nologo
    end
  end
end
haf commented 6 years ago

Without understanding your error message; that code won't work because build only declares a task; it doesn't run it. My guess is that you somehow get that declaration running and start umpteen msbuild processes in parallel.

thefernman commented 6 years ago

Do you have a suggestion? That seems to be the problem. build is prepped for all my solutions, and when that's done, those tasks are executed.

thefernman commented 6 years ago

Currently, this is what my code looks like and I'm still getting too many files open error.

EDIT: I fixed it by spawning processes.

`desc 'Build all customers' task :build_customers do |t| logger.info 'Build customer dlls...' (Dir.glob(get_relative_path('../customers') + '///Web')).each do |dir| clean(dir) sln_path = dir + '/../Web.sln' out_dir = dir.gsub('/customers/','/build/') + '/Distrib' Rake::Task['build_client'].execute :sln_path => sln_path, :out_dir => out_dir end end

build :build_client, [:sln_path, :out_dir] do |b, args| sln_path = args[:sln_path] out_dir = args[:out_dir] logger.info "Building: #{sln_path} out to #{out_dir}"

b.sln = sln_path b.target = ['Clean', 'Build'] b.prop 'Configuration', 'Release' b.prop 'OutDir', out_dir b.prop 'ToolsVersion' , '4.6' b.logging = 'm' b.nologo end`

haf commented 6 years ago

Start by formatting your code and I will look at it.