<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dude, where is my Kaizen? &#187; Rake</title>
	<atom:link href="http://www.bjoernrochel.de/tag/rake/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bjoernrochel.de</link>
	<description>Björn Rochel&#039;s weblog</description>
	<lastBuildDate>Mon, 21 Jun 2010 07:26:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ILMerge and Rake go xunit.BDDExtensions</title>
		<link>http://www.bjoernrochel.de/2009/01/27/ilmerge-and-rake-go-xunitbddextensions/</link>
		<comments>http://www.bjoernrochel.de/2009/01/27/ilmerge-and-rake-go-xunitbddextensions/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 12:48:54 +0000</pubDate>
		<dc:creator>BjRo</dc:creator>
				<category><![CDATA[Rake]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[xUnit]]></category>
		<category><![CDATA[xUnit.BDDExtensions]]></category>

		<guid isPermaLink="false">http://www.bjoernrochel.de/?p=253</guid>
		<description><![CDATA[Today I added this little piece of code to the trunk of xUnit.BDDExtensions. It&#8217;s a rake task for merging assemblies via the ILMerge tool.


desc &#34;Merges the assemblies&#34;
task :merge do
  mkdir DEPLOY_DIR unless File.exists?(DEPLOY_DIR)
  cp &#34;xunit.dll&#34;.expand_to(:build_dir), &#34;xunit.dll&#34;.expand_to(:deploy_dir)
  cp &#34;Rhino.Mocks.dll&#34;.expand_to(:build_dir), &#34;Rhino.Mocks.dll&#34;.expand_to(:deploy_dir)
  assemblies_to_merge = [&#34;xUnit.BDDExtensions.dll&#34;, &#34;StructureMap.dll&#34;, &#34;StructureMap.AutoMocking.dll&#34;]
  ilmerge &#34;xunit.bddextensions.dll&#34;, assemblies_to_merge
end


Ruby is a fantastic [...]]]></description>
			<content:encoded><![CDATA[<p>Today I added this little piece of code to the trunk of xUnit.BDDExtensions. It&#8217;s a rake task for merging assemblies via the ILMerge tool.
<p />
<pre class="brush: ruby">
desc &quot;Merges the assemblies&quot;
task :merge do
  mkdir DEPLOY_DIR unless File.exists?(DEPLOY_DIR)
  cp &quot;xunit.dll&quot;.expand_to(:build_dir), &quot;xunit.dll&quot;.expand_to(:deploy_dir)
  cp &quot;Rhino.Mocks.dll&quot;.expand_to(:build_dir), &quot;Rhino.Mocks.dll&quot;.expand_to(:deploy_dir)
  assemblies_to_merge = [&quot;xUnit.BDDExtensions.dll&quot;, &quot;StructureMap.dll&quot;, &quot;StructureMap.AutoMocking.dll&quot;]
  ilmerge &quot;xunit.bddextensions.dll&quot;, assemblies_to_merge
end
</pre>
<p>
Ruby is a fantastic language. The more I learn about it the more I actually like it. Let&#8217;s have a look at how this task is implemented. First of all I opened up Ruby&#8217;s string class and added new methods to it (this is called MonkeyPatching, and worth a blog post on its own <img src='http://www.bjoernrochel.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> )
</p>
<pre class="brush: ruby">
class String
  def escape
    &quot;\&quot;#{self.to_s}\&quot;&quot;
  end

  def expand_to dir_symbol
    case dir_symbol
      when :build_dir
        path = BUILD_DIR
      when :source_dir
        path = SOURCE_DIR
      when :externals_dir
        path = EXTERNALS_DIR
      when :deploy_dir
        path = DEPLOY_DIR
    end    

    File.join(path, self.to_s)
  end
end
</pre>
<p>
And here is the actual <i>ilmerge</i> &#8211; method. It simply gets the complete path to the ILMerge.exe (not shown here), expands the name to all assemblies that have to be merged and escapes them, before the actual call to ILMerge is issued over the console &#8230;</p>
<p />
<pre class="brush: ruby">
def ilmerge(output_name, assemblies)
  ilmerge = get_tool :ILMerge
  expanded_assemblies = assemblies.map do |x|
    x.expand_to(:build_dir).escape
  end

  sh &quot;#{ilmerge.escape} /out:#{output_name.expand_to(:deploy_dir).escape} #{expanded_assemblies.join(&quot; &quot;)}&quot;
end
</pre>
<p>
Currently 3 assemblies pop out of the Rake build. These are xunit.dll, xunit.bddextensions.dll and Rhino.Mocks.dll. While it&#8217;s technically no problem to merge them into a single assembly (and of course I would love to have it that way) there are two problems currently not solved. The R# runner dynamically loads the xunit.dll to run the tests and StructureMap.AutoMocking.dll dynamically loads Rhino.Mocks.dll. That&#8217;s the reason why I&#8217;m currently not able to merge it.
</p>
<p>Any suggestions how to solve that?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bjoernrochel.de/2009/01/27/ilmerge-and-rake-go-xunitbddextensions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
