-
Notifications
You must be signed in to change notification settings - Fork 71
AssemblyInfoTask
To simplify the creation of an AssemblyInfo.cs file, for your C# projects, you can use the AssemblyInfoTask. Be sure to require ‘albacore’ at the top of your rakefile, after installing the Albacore gem.
Here is an example of how to use the AssemblyInfoTask
desc "Run a sample assembly info generator"
Rake::AssemblyInfoTask.new(:assemblyinfo) do |asm|
asm.version = "0.1.2.3"
asm.company_name = "a test company"
asm.product_name = "a product name goes here"
asm.title = "my assembly title"
asm.description = "this is the assembly description"
asm.copyright = "copyright some year, by some legal entity"
asm.custom_attributes :SomeAttribute => "some value goes here", :AnotherAttribute => "with some data"
asm.output_file = "lib/spec/support/AssemblyInfo/AssemblyInfo.cs"
end
The output_file is the name and location of the file that will have the assembly information and attributes written to it. The file with either be created, or overwritten.
To simplify the use of certain attributes, the AssemblyInfoTask includes a set of built in attribute settings. Each of these settings are optional. If you do not set them, or if you set them to nil, they will not be written to the output file.
The assembly version information. This is typically an “#.#.#.#” format, but can be any valid .NET version # format.
The name of the company that owns or is creating / maintaining the assembly in question. For example, “My Company, Inc.”
The name of the product that this assembly belongs to. For example, “FooBar Widget Maker”
The specific title of the assembly in question. This is used to differentiate the assembly’s name from the product’s name. For example the “Widget Factory” assembly may be part of the “FooBar Widget Maker” project.
A description of what the assembly in question does. For example, “Builds the Widgets from configuration settings”.
The copyright information for the assembly in question. For example, “Copyright ©2009 MyCompany, Inc. All Rights Reserved.”
Determines whether or not an assembly is visible to the COM system, through COM interop. The only valid options for com_visible are true and false. These values must be specified as actual values, not strings.
asm.com_visible = true
Sets the guid, as a string, for the COM interop system to use when making your assembly COM visible.
This allows you to specify attributes that are not supported through the built-in attributes, listed above. This also allows you to have more creative control over the data that ends up in the parameters for the attribute – if any data is needed, at all.
You can specify multiple custom attributes through a hash literal. The key of the hash will be used as the attribute’s class name. The value of the hash will be used as the parameter that is passed into the attribute constructor.
The example above will generate the following:
[assembly: SomeAttribute("some value goes here")]
[assembly: AnotherAttribute("with some data")]
You can specify a nil value for a custom attribute. This will cause the attribute to be generated with no parameters in the constructor. For example:
asm.custom_attributes :EmptyAttribute => nil
will generate this attribute in the output file
[assembly: EmptyAttribute()]
You can specify literal values for a custom attribute. This will cause the attribute to be generated with no quotes around the parameter in the constructor. For example:
asm.custom_attributes :BooleanAttribute => true
will generate this attribute in the output file
[assembly: BooleanAttribute(true)]
Currently, the AssemblyInfoTask only supports generating assembly info files for C#. I have no need for VB or other .NET languages right now. so I have not built any other language support. If there is sufficient interest in other language support, though, I will work with the interested parties to create a language setting and generator.