Skip to content

Instantly share code, notes, and snippets.

@jmeridth
Created December 8, 2010 16:33
Show Gist options
  • Select an option

  • Save jmeridth/733509 to your computer and use it in GitHub Desktop.

Select an option

Save jmeridth/733509 to your computer and use it in GitHub Desktop.
for some reason the assembly generation loop is going one more time than expected
FIXED thanks to quick look by Derick Bailey @derickbailey. generate_assemblyinfo task needed to be a rake task and not assemblyinfo task. easy fix.
### versions.yml
files:
- OneAssemblyInfo: 1.0.0
- TwoAssemblyInfo: 2.0.0
- ThreeAssemblyInfo: 3.0.0
- FourAssemblyInfo: 4.0.0
- FiveAssemblyInfo: 5.0.0
### Rakefile
require 'rubygems'
require 'albacore'
require 'yaml'
desc "Generate the SharedAssemblyInfo file"
task :generate_assemblyinfo, :git_sha do |asm, args|
git_sha = args[:git_sha] || "GIT SHA"
raw_config = File.read('versions.yml')
files = YAML.load(raw_config)['files']
files.each do |file|
file.keys.each do |key|
version_prefix = file[key]
output_file_path = key
Rake::Task[:assemblyinfo].execute({ :git_sha => git_sha , :version_prefix => version_prefix , :output_file_path => output_file_path })
# same output with .invoke
# Rake::Task[:assemblyinfo].reenable
# Rake::Task[:assemblyinfo].invoke(git_sha , version_prefix, output_file_path)
end
end
end
desc "Create the SharedAssemblyInfo file"
assemblyinfo :assemblyinfo, :git_sha, :version_prefix, :output_file_path do |asm, args|
git_sha = args[:git_sha]
version_prefix = args[:version_prefix]
output_file_path = args[:output_file_path]
product_name = output_file_path.gsub('AssemblyInfo','').split(/(?=[A-Z])/).map{|w| w.capitalize}.join(' ')
build_number = ENV['BUILD_NUMBER'] #provided by teamcity
copyright = "Copyright (c) 2001-#{Time.now.year}, Company, Inc. and/or its affiliates. All rights reserved."
asm.version = "#{version_prefix}.#{build_number || 0}"
asm.company_name = 'Company'
asm.product_name = "Company #{product_name} Product"
asm.description = git_sha
asm.copyright = copyright
asm.trademark = copyright
asm.output_file = "#{output_file_path}.cs"
end
### output
$ rake generate_assemblyinfo
(in c:/Users/jmeridth/work/app)
I, [2010-12-08T09:56:47.083899 #468] INFO -- : Generating Assembly Info File At: c:/Users/jmeridth/work/app/OneAssemblyInfo.cs
KEYS COUNT: 1
I, [2010-12-08T09:56:47.138211 #468] INFO -- : Generating Assembly Info File At: c:/Users/jmeridth/work/app/TwoAssemblyInfo.cs
KEYS COUNT: 1
I, [2010-12-08T09:56:47.195918 #468] INFO -- : Generating Assembly Info File At: c:/Users/jmeridth/work/app/ThreeAssemblyInfo.cs
KEYS COUNT: 1
I, [2010-12-08T09:56:47.279649 #468] INFO -- : Generating Assembly Info File At: c:/Users/jmeridth/work/app/FourAssemblyInfo.cs
KEYS COUNT: 1
I, [2010-12-08T09:56:47.364511 #468] INFO -- : Generating Assembly Info File At: c:/Users/jmeridth/work/app/FiveAssemblyInfo.cs
F, [2010-12-08T09:56:47.460689 #468] FATAL -- : output_file cannot be nil
rake aborted!
output_file cannot be nil
c:/Ruby187/lib/ruby/gems/1.8/gems/albacore-0.2.2/lib/albacore/support/failure.rb:12:in `fail_with_message'
c:/Ruby187/lib/ruby/gems/1.8/gems/albacore-0.2.2/lib/albacore/assemblyinfo.rb:41:in `check_output_file'
c:/Ruby187/lib/ruby/gems/1.8/gems/albacore-0.2.2/lib/albacore/assemblyinfo.rb:28:in `write_assemblyinfo'
c:/Ruby187/lib/ruby/gems/1.8/gems/albacore-0.2.2/lib/albacore/assemblyinfo.rb:24:in `execute'
c:/Ruby187/lib/ruby/gems/1.8/gems/albacore-0.2.2/lib/albacore/support/createtask.rb:24:in `assemblyinfo'
c:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
c:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
c:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
c:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
c:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
c:/Ruby187/lib/ruby/1.8/monitor.rb:242:in `synchronize'
c:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
c:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
c:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
c:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
c:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
c:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
c:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
c:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
c:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
c:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
c:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
c:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
c:/Ruby187/bin/rake:19:in `load'
c:/Ruby187/bin/rake:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment