<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Alkampfer's Place</title>
	
	<link>http://www.nablasoft.com/alkampfer</link>
	<description>Blog about programming and .NET</description>
	<pubDate>Sat, 04 Jul 2009 17:26:00 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<geo:lat>43.44754459758882</geo:lat><geo:long>12.84752368927002</geo:long><image><url>http://www.feedburner.com/fb/images/pub/fb_pwrd.gif</url></image><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/AlkampferEng" type="application/rss+xml" /><feedburner:emailServiceId>AlkampferEng</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Test posting in the future</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/U2lalZB6r98/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/07/04/test-posting-in-the-future/#comments</comments>
		<pubDate>Sat, 04 Jul 2009 17:26:00 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[Blogging]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/07/04/test-posting-in-the-future/</guid>
		<description><![CDATA[Probably one of the most missed feature of wordpress is the possibility to post in the future. There are days when you have tons of ideas, but you simply avoid to blog just because you’ve already blogged a lot in the last days. One of the most interesting feature of wordpress, as well as other [...]]]></description>
			<content:encoded><![CDATA[<p>Probably one of the most missed feature of wordpress is the possibility to post in the future. There are days when you have tons of ideas, but you simply avoid to blog just because you’ve already blogged a lot in the last days. One of the most interesting feature of wordpress, as well as other blog engine is the ability to post in the future.</p>
<p>The good stuff is that windows live writer is able to decide date of the post directly on the post page, I’m writing this post 03 July 2009, but it will be published only the next day. Moreover in the net there are some suggestions on how to <a href="http://webdemar.com/wordpress/display-future-posts-in-your-wordpress-theme/">show a list of future post in the sidebar</a>.</p>
<p>I’m not sure if I’ll use this feature, I’m a fan of Blogging at the moment, but for technical question, especially for series of posts dedicated to the same argument, the ability to schedule post in advance can be really interesting.</p>
<p>Alk.</p>
<p>Tags: <a href="http://technorati.com/tag/Blogging" rel="tag">Blogging</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=U2lalZB6r98:7qa6AZPd5u8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=U2lalZB6r98:7qa6AZPd5u8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=U2lalZB6r98:7qa6AZPd5u8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=U2lalZB6r98:7qa6AZPd5u8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=U2lalZB6r98:7qa6AZPd5u8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=U2lalZB6r98:7qa6AZPd5u8:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/U2lalZB6r98" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/07/04/test-posting-in-the-future/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/07/04/test-posting-in-the-future/</feedburner:origLink></item>
		<item>
		<title>Execute custom code during Tfs build</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/Jn4BtRpWKqw/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/07/03/execute-custom-code-during-tfs-build/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 14:31:51 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[Team Foundation Server]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/07/03/execute-custom-code-during-tfs-build/</guid>
		<description><![CDATA[At this point I explained how to setup a build, and how to fully customize it editing the msbuild file to execute some tasks, like open an issue when one or more test fail.
Another interesting stuff to explain is how to execute custom code during the build, to demonstrate this concept I’ll show how to [...]]]></description>
			<content:encoded><![CDATA[<p>At this point I explained how to setup a build, and how to fully customize it editing the msbuild file to execute some tasks, like open an issue when one or more test fail.</p>
<p>Another interesting stuff to explain is how to execute custom code during the build, to demonstrate this concept I’ll show how to tweet a warning message when test phase fails. To execute custom code you simply need to create a custom msbuild task that does everything you want, then you simply need to call this custom task in the build script. The first step is creating the task.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:43b65518-3803-4663-9a27-147be2edc6f1" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">class</span><span style="color: #000000;"> TweetTask : Task
{
    [Required]
    </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> String Username { </span><span style="color: #0000FF;">get</span><span style="color: #000000;">; </span><span style="color: #0000FF;">set</span><span style="color: #000000;">; }
    [Required]
    </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> String Password { </span><span style="color: #0000FF;">get</span><span style="color: #000000;">; </span><span style="color: #0000FF;">set</span><span style="color: #000000;">; }
    [Required]
    </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> String Tweet { </span><span style="color: #0000FF;">get</span><span style="color: #000000;">; </span><span style="color: #0000FF;">set</span><span style="color: #000000;">; }

    </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">override</span><span style="color: #000000;"> </span><span style="color: #0000FF;">bool</span><span style="color: #000000;"> Execute()
    {
        TwitterService service </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> TwitterService();
        String tweet </span><span style="color: #000000;">=</span><span style="color: #000000;"> Tweet.Substring(</span><span style="color: #800080;">0</span><span style="color: #000000;">, Math.Min(Tweet.Length, </span><span style="color: #800080;">140</span><span style="color: #000000;">));
        </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> service.SendMessage(Username, Password, tweet);
    }
}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>As you can see, creating a custom task is really simple, you should inherit from the Task base class and override the Execute() method. In this example everything is done in the TwitterService class that I <a href="http://www.dreamincode.net/code/snippet2556.htm">took from this post</a>. To pass parameters to this task you can simply create public properties in the task class, and use the [Required] attribute to specify that the caller absolutely needs to specify these properties to use the task.</p>
<p>Now you only need to compile this class into a dll, and <em>make it avaliable to the build process</em>. This is probably the most interesting part, because <strong>the build engine must be able to locate this dll in order to execute your custom action</strong>. Another requirement I want, is that you must be able to use your custom task without the need to physically go to tfs server and copy the dll into some directory. This because you must be able to fully configure the build with the same set of permission you have in tfs. I do not want to ask someone “Hey copy this dll into the tfs server”, I simply want to configure everything in visual studio.</p>
<p>This is a well known problem for everyone that works with Continuous integration machines, and the solution I like is <strong>inserting everything is needed for the build in a specific folder into the source control system of the project</strong>.</p>
<p>&#160;<a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/07/image6.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="172" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/07/image-thumb6.png" width="467" border="0" /></a> </p>
<p>As you can see I created a folder called BuildTools, inside it another folder called MsBuildCustomTasks and inside the compiled dll with my actino. Now I’m sure that the dll with my custom task is included into the source control system, and I can refer to it inside the TFSBuild.proj build file.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:79c4e306-37df-4b14-97ea-5e598b19b8f3" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">UsingTask
        </span><span style="color: #FF0000;">TaskName</span><span style="color: #0000FF;">="DotNetMarche.MsBuildExtensions.Twitter.TweetTask"</span><span style="color: #FF0000;">
         AssemblyFile</span><span style="color: #0000FF;">="..\sources\BuildTools\MsBuildCustomTasks\DotNetMarche.MsBuildExtensions.dll"</span><span style="color: #0000FF;">/&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>to import the custom task you simply need to specify the task name and the assemblyFile in a <strong>&lt;UsingTask&gt;</strong> directive, as you can see the path of the dll is ..\sources\xxx where xxx is the path of the dll relative to the root of the source control system. Now if you do a check-in the next build will comprehend your custom task. This technique is useful, because you can be sure that each build always do a “Get Latest” to build the latest version of the source, thus getting also every tool it need to do the build.</p>
<p>Now you can use this task wherever you want:</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:a229d5f0-61da-4529-8849-a6332d657522" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">TweetTask
    </span><span style="color: #FF0000;">Condition</span><span style="color: #0000FF;">="'$(IsDesktopBuild)' != 'true' and '$(TestSuccess)' != 'true'"</span><span style="color: #FF0000;">
    Username</span><span style="color: #0000FF;">="alkampfer"</span><span style="color: #FF0000;">
    Password</span><span style="color: #0000FF;">="xxxxxxxxxxx"</span><span style="color: #FF0000;">
    Tweet</span><span style="color: #0000FF;">="Unit Test Failure in build number: $(BuildNumber)"</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
<p>As for the previous post, I’m asking to tweet a message to my twitter account when test phase fails during the build, I made a test fails, commit everything and after integration machine finished to build I can see this in my twitterDesk</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/07/image7.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="134" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/07/image-thumb7.png" width="305" border="0" /></a> </p>
<p>WOW <img src='http://www.nablasoft.com/alkampfer/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> you can have your CI machine tweet whenever you want with less than 20 lines of code. You can now create a dedicated twitter account for every project you have, and you can follow status of the build in every device that supports twitter :D.</p>
<p>Alk.</p>
<p>Tags: <a href="http://technorati.com/tag/Team Foundation Server" rel="tag">Team Foundation Server</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=Jn4BtRpWKqw:nhH1JhuKFao:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=Jn4BtRpWKqw:nhH1JhuKFao:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=Jn4BtRpWKqw:nhH1JhuKFao:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=Jn4BtRpWKqw:nhH1JhuKFao:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=Jn4BtRpWKqw:nhH1JhuKFao:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=Jn4BtRpWKqw:nhH1JhuKFao:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/Jn4BtRpWKqw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/07/03/execute-custom-code-during-tfs-build/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/07/03/execute-custom-code-during-tfs-build/</feedburner:origLink></item>
		<item>
		<title>Open an issue when a test fails during a TFS build</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/AdRkKyD5hiM/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/07/02/open-an-issue-when-a-test-fails-during-a-tfs-build/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 15:29:55 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[Team Foundation Server]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/07/02/open-an-issue-when-a-test-fails-during-a-tfs-build/</guid>
		<description><![CDATA[In last post I show how to configure test run in a team foundation build, simply editing the msbuild file. The aim of the post was showing how to make the entire build fail when a single test fails. To achieve this result I simply override a target and set some properties values. 
In this [...]]]></description>
			<content:encoded><![CDATA[<p>In last post I show how to configure test run in a team foundation build, simply editing the msbuild file. The aim of the post was showing how to make the entire build fail when a single test fails. To achieve this result I simply override a target and set some properties values. </p>
<p>In this post I’ll show how to automatically open an issue in TFS when a test fails. This is a standard requirement, because in such a way you are immediately aware when some test are failing.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:14fcc739-bc11-46f0-8264-e51c3e80ce97" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">Target </span><span style="color: #FF0000;">Name</span><span style="color: #0000FF;">="AfterTest"</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">

    </span><span style="color: #008000;">&lt;!--</span><span style="color: #008000;"> Refresh the build properties. </span><span style="color: #008000;">--&gt;</span><span style="color: #000000;">
    </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">GetBuildProperties </span><span style="color: #FF0000;">TeamFoundationServerUrl</span><span style="color: #0000FF;">="$(TeamFoundationServerUrl)"</span><span style="color: #FF0000;">
                                 BuildUri</span><span style="color: #0000FF;">="$(BuildUri)"</span><span style="color: #FF0000;">
                                 Condition</span><span style="color: #0000FF;">=" '$(IsDesktopBuild)' != 'true' "</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
        </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">Output </span><span style="color: #FF0000;">TaskParameter</span><span style="color: #0000FF;">="TestSuccess"</span><span style="color: #FF0000;"> PropertyName</span><span style="color: #0000FF;">="TestSuccess"</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span><span style="color: #000000;">
    </span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">GetBuildProperties</span><span style="color: #0000FF;">&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>To execute some task after tests are run, you can simply override the target <strong>AfterTest </strong>then insert inside it all the tasks you like. To know result of tests we need to refresh some properties of the build, this is simply done with the <strong>GetBuildProperties task</strong>, you need to insert the serverUri, the BuildUri and ask to know the value of the TestSuccess parameter. Now you can know if some tests failed during test run, and you can create an issue if TestSuccess property is false.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:ffc05363-023f-4c53-9c9e-49ee8b6132b1" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">CreateNewWorkItem
    </span><span style="color: #FF0000;">Condition</span><span style="color: #0000FF;">="'$(IsDesktopBuild)' != 'true' and '$(TestSuccess)' != 'true'"</span><span style="color: #FF0000;">
     TeamFoundationServerUrl</span><span style="color: #0000FF;">="$(TeamFoundationServerUrl)"</span><span style="color: #FF0000;">
     BuildUri</span><span style="color: #0000FF;">="$(BuildUri)"</span><span style="color: #FF0000;">
     BuildNumber</span><span style="color: #0000FF;">="$(BuildNumber)"</span><span style="color: #FF0000;">
     Description</span><span style="color: #0000FF;">="Test run failure in build"</span><span style="color: #FF0000;">
     TeamProject</span><span style="color: #0000FF;">="$(TeamProject)"</span><span style="color: #FF0000;">
     Title</span><span style="color: #0000FF;">="Unit Test Failure in build number: $(BuildNumber)"</span><span style="color: #FF0000;">
     WorkItemFieldValues</span><span style="color: #0000FF;">="$(WorkItemFieldValues)"</span><span style="color: #FF0000;">
     WorkItemType</span><span style="color: #0000FF;">="$(WorkItemType)"</span><span style="color: #FF0000;">
     ContinueOnError</span><span style="color: #0000FF;">="true"</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span><span style="color: #000000;">
</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">Target</span><span style="color: #0000FF;">&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>The condition property is used to create the item only if the DesktopBuild is false and TestSuccess is also false, this means that issue are created only when the build is executed by the server and at least one test failed. You can configure every parameters but the most important one is the WorkItemFieldValues that can be specified in this way.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:4897ec07-cbcc-4261-90d1-0f20b88db4ac" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">PropertyGroup</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
    </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">WorkItemFieldValues</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
        priority =2; severity=3; rank =4; triage =Investigate
    </span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">WorkItemFieldValues</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">PropertyGroup</span><span style="color: #0000FF;">&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
<p>It must contains a list of issue properties that you want to set when you create the new work item. Now I reset back the TreatTestFailureAsBuildFailure to false, so the build will partially succeed even when some tests fails, but for each build that fails unit testing task an issue is automatically generated, with the desidered properties.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/07/image4.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="110" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/07/image-thumb4.png" width="308" border="0" /></a> </p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/07/image5.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="61" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/07/image-thumb5.png" width="706" border="0" /></a> </p>
<p>Configuring the build adding msbuild tasks is quite simple and permits you to fully configure your build.</p>
<p>alk.</p>
<p>Tags: <a href="http://technorati.com/tag/Team Foundation Server" rel="tag">Team Foundation Server</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=AdRkKyD5hiM:gcBzK57dsjc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=AdRkKyD5hiM:gcBzK57dsjc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=AdRkKyD5hiM:gcBzK57dsjc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=AdRkKyD5hiM:gcBzK57dsjc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=AdRkKyD5hiM:gcBzK57dsjc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=AdRkKyD5hiM:gcBzK57dsjc:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/AdRkKyD5hiM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/07/02/open-an-issue-when-a-test-fails-during-a-tfs-build/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/07/02/open-an-issue-when-a-test-fails-during-a-tfs-build/</feedburner:origLink></item>
		<item>
		<title>Installation of Tfs Beta 1</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/lawEzH5fBcw/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/07/01/installation-of-tfs-beta-1/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 16:55:05 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[Team Foundation Server]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/07/01/installation-of-tfs-beta-1/</guid>
		<description><![CDATA[Today I installed Tfs 2010 beta to look at new features; installation process of Tfs can be a complex operation but I must admit that in the 2010 version, the installer is more friendly. I installed sharepoint and sql server 2008 then I fired the installation of tfs. The main difference from the 2008 version [...]]]></description>
			<content:encoded><![CDATA[<p>Today I installed Tfs 2010 beta to look at new features; installation process of Tfs can be a complex operation but I must admit that in the 2010 version, the installer is more friendly. I installed sharepoint and sql server 2008 then I fired the installation of tfs. The main difference from the 2008 version is that it does not ask you anything, it just install, postponing the configuration after the installation is ok. When you access the Team Foundation Administration console, it presents you a configuration wizard.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/07/image.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="253" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/07/image-thumb.png" width="756" border="0" /></a>&#160;</p>
<p>If you select “custom Configuration” you can fine tuning the configuration, you can choose as example the database you want to use.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/07/image1.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="329" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/07/image-thumb1.png" width="424" border="0" /></a> </p>
<p>Since I already configured sharepoint services and created sites I can specify them in the next configuration step.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/07/image2.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="380" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/07/image-thumb2.png" width="406" border="0" /></a> </p>
<p>You can configure almost anything with simple wizards, the overall process can be complicated if you are not familiar with the tecnologies involved, since you have to configure reporting services, integration with sharepoint etc. etc. When you finished configuring everything the wizard runs a check that tells you what is wrong and what is good.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/07/image3.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="359" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/07/image-thumb3.png" width="572" border="0" /></a> </p>
<p>From this simple list of errors and warning you can easily address every problem you can have, in this example I forgot to set the Database Agent in automatic execution, so I started it and do again a check. </p>
<p>During the whole installation I had only a little problem with error TF255275 that states </p>
<blockquote><p>The following Web service for SQL Server Reporting Services could not be accessed: <a href="http://tfsd2010/ReportServer/ReportService2005.asmx">http://tfsd2010/ReportServer/ReportService2005.asmx</a></p>
</blockquote>
<p>This is caused by a wrong configuration of reporting services, actually I completely forgot to create databases for Reporting services :), but the error is somewhat misleading me to wrong cause. you can find a detailed discussion of this error h<a href="http://social.msdn.microsoft.com/Forums/en-US/tfsprerelease/thread/750302b5-12fb-4a92-8249-bcb64aadc23a">ere</a>. </p>
<p>I must admit that the installation process is more friendly and improved respect Tfs 2008.</p>
<p>Alk.</p>
<p>Tags: <a href="http://technorati.com/tag/Team Foundation Server" rel="tag">Team Foundation Server</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=lawEzH5fBcw:1fXMgjvk27E:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=lawEzH5fBcw:1fXMgjvk27E:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=lawEzH5fBcw:1fXMgjvk27E:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=lawEzH5fBcw:1fXMgjvk27E:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=lawEzH5fBcw:1fXMgjvk27E:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=lawEzH5fBcw:1fXMgjvk27E:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/lawEzH5fBcw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/07/01/installation-of-tfs-beta-1/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/07/01/installation-of-tfs-beta-1/</feedburner:origLink></item>
		<item>
		<title>error MSB3321: Importing key file xxx was canceled</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/HGdim6URU5E/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/07/01/error-msb3321-importing-key-file-xxx-was-canceled/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 08:46:43 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/07/01/error-msb3321-importing-key-file-xxx-was-canceled/</guid>
		<description><![CDATA[I start to got this error from my Continuous integration machine, after I setup a project for deploy with clickonce the build begins to fail. I’m using CC.net with msbuild scripts and in detailed error I see a message like
The &#34;ResolveKeySource&#34; task failed unexpectedly.
System.InvalidOperationException: Showing a modal dialog box or form when the application is [...]]]></description>
			<content:encoded><![CDATA[<p>I start to got this error from my Continuous integration machine, after I setup a project for deploy with clickonce the build begins to fail. I’m using CC.net with msbuild scripts and in detailed error I see a message like</p>
<blockquote><p>The &quot;ResolveKeySource&quot; task failed unexpectedly.</p>
<p>System.InvalidOperationException: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.</p>
</blockquote>
<p>This error happens because when the project has a certificate used by click once, you need to import that certificate in order to compile, and since my certificate is password protected the system need to show a form that ask for password to import certificate. Since cc.net runs as service it tries to shows the dialog, but it cannot gain access to a user interface and fail miserably.</p>
<p>The solution is to create a specific user to use for cc.net service (a good practice that you should always do), open a command prompt with credentials of that user, run your build script and wait for the form that ask you the password of the certificate. Once you give the password to msbuild script it installs into appropriate location and subsequent builds will run just ok.</p>
<p>Alk.</p>
<p>Tags: <a href="http://technorati.com/tag/CC.Net" rel="tag">CC.Net</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=HGdim6URU5E:6UUWltHKeaQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=HGdim6URU5E:6UUWltHKeaQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=HGdim6URU5E:6UUWltHKeaQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=HGdim6URU5E:6UUWltHKeaQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=HGdim6URU5E:6UUWltHKeaQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=HGdim6URU5E:6UUWltHKeaQ:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/HGdim6URU5E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/07/01/error-msb3321-importing-key-file-xxx-was-canceled/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/07/01/error-msb3321-importing-key-file-xxx-was-canceled/</feedburner:origLink></item>
		<item>
		<title>Customize test running in a Tfs Team Build</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/zVNnV9WkJt0/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/29/customize-test-running-in-a-tfs-team-build/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 17:41:54 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[.NET framework]]></category>

		<category><![CDATA[Team Foundation Server]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/29/customize-test-running-in-a-tfs-team-build/</guid>
		<description><![CDATA[In previous post I showed how to setup a build in tfs that not only builds the solution, but also runs all the tests. The next step is to configure how tests are run and reacting to test result. The first thing I want is the ability to make the entire build fail if one [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.nablasoft.com/alkampfer/index.php/2009/06/26/running-tests-during-a-build-in-tfs/">previous post</a> I showed how to setup a build in tfs that not only builds the solution, but also runs all the tests. The next step is to configure how tests are run and reacting to test result. The first thing I want is the ability to make the entire build fail if one of the test fails. As you see in the previous post, the default behavior of the build, is to partially fail if one or more tests fail.</p>
<p>This kind of option is not present in the wizard, and it is time to make your hands dirty. To unleash the full power of team builds, you need to know <a href="http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx">msbuild</a>, in order to configure the build editing the msbuild file of the team build. First of all go to the team explorer, open the source control node (step 1), here you will find a folder named &quot;<strong>TeamBuildTypes</strong> (step2) that contains a subfolder for each build definition, in the BuildWithTests folder there are a couple of file, the one named TFSBuild.proj (Step 3) is the one that contains all operations of the build.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image46.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="270" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb46.png" width="624" border="0" /></a> </p>
<p>In order to edit that file, you first need to grab a copy from the source control to your local folder, simply right click in the teamBuildTypes folder to “Get the latest version”</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image47.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="127" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb47.png" width="233" border="0" /></a> </p>
<p>Ok now you can double click the tfsbuild.proj file to edit it. This is a simple msbuild file, and in the first lines you find this instruction</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:af5a2b39-73a1-4df1-83cc-513d6015e8be" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">Import </span><span style="color: #FF0000;">Project</span><span style="color: #0000FF;">="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets"</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>it imports a file called <strong>Microsoft.TeamFoundation.Build.targets</strong> that contains base targets for a build definition. This file permits you to override some specific target to execute custom code in specific moments of the build process. You can find a list of overridable targets <a href="http://msdn.microsoft.com/en-us/library/aa337604.aspx">here</a>. From that list you can verify that there is a target called <strong>BeforeTestConfiguration</strong> that can be used to specify some custom configuration for test execution.</p>
<p>To fully understand how overriding works, you can open the Microsoft.TeamFoundation.Build.Targets file and look at the BeforeTestConfiguration target.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:9edfef6a-b813-4c69-bef9-8e41e521ed42" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">  </span><span style="color: #008000;">&lt;!--</span><span style="color: #008000;"> Override this target to execute custom tasks before the testing of an individual configuration </span><span style="color: #008000;">--&gt;</span><span style="color: #000000;">
  </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">Target </span><span style="color: #FF0000;">Name</span><span style="color: #0000FF;">="BeforeTestConfiguration"</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
<p>Since its only purpose is running your own code, it contains no task. Then you can verify on how it is used by the basic test runner task.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:77c7df30-e7c9-4b30-a6b0-f81215ba11ec" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">  </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">PropertyGroup</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
    </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">TestConfigurationDependsOn</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
      BeforeTestConfiguration;
      CoreTestConfiguration;
      AfterTestConfiguration;
    </span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">TestConfigurationDependsOn</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
  </span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">PropertyGroup</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
  </span><span style="color: #008000;">&lt;!--</span><span style="color: #008000;"> Batch target for individual configuration testing </span><span style="color: #008000;">--&gt;</span><span style="color: #000000;">
  </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">Target </span><span style="color: #FF0000;">Name</span><span style="color: #0000FF;">="TestConfiguration"</span><span style="color: #FF0000;">
          DependsOnTargets</span><span style="color: #0000FF;">="$(TestConfigurationDependsOn)"</span><span style="color: #FF0000;">
          Outputs</span><span style="color: #0000FF;">="@(TestOutputs)"</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span><span style="color: #000000;">

...
</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>From that code you can verify that test configuration depends on <strong>BeforeTestconfiguration, CoreTestConfiguration, AfterTEstConfiguration</strong>.Of these three targets, only CoreTestConfiguration contains real actions, the other two are there only to insert own task into the build process. If you look at the CoreTestConfiguration you can find this code.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:373b3191-e02e-478e-8c1a-e2b3922ea301" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">    </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">PropertyGroup</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
      </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">ContinueOnTestError </span><span style="color: #FF0000;">Condition</span><span style="color: #0000FF;">=" '$(StopOnTestFailure)' != 'true' "</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">true</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">ContinueOnTestError</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
      </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">ContinueOnTestError </span><span style="color: #FF0000;">Condition</span><span style="color: #0000FF;">=" '$(StopOnTestFailure)' == 'true' "</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">false</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">ContinueOnTestError</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
    </span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">PropertyGroup</span><span style="color: #0000FF;">&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Ok this is exactly what we need, the Continue on test property is set to true or false depending on the StopOnTestFailure variable. Another interesting piece of code is this one</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:0719d2e6-0398-471e-9d07-61dae3a45c69" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">  </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">Target </span><span style="color: #FF0000;">Name</span><span style="color: #0000FF;">="RunTest"</span><span style="color: #FF0000;">
          DependsOnTargets</span><span style="color: #0000FF;">="$(RunTestDependsOn)"</span><span style="color: #FF0000;">
          Outputs</span><span style="color: #0000FF;">="@(TestOutputs)"</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">

    </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">MakeDir
          </span><span style="color: #FF0000;">Directories</span><span style="color: #0000FF;">="$(TestResultsRoot)"</span><span style="color: #FF0000;">
          Condition</span><span style="color: #0000FF;">="!Exists('$(TestResultsRoot)')"</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span><span style="color: #000000;">

    </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">MSBuild </span><span style="color: #FF0000;">Projects</span><span style="color: #0000FF;">="@(ConfigurationList)"</span><span style="color: #FF0000;">
             Properties</span><span style="color: #0000FF;">="TreatTestFailureAsBuildFailure=$(TreatTestFailureAsBuildFailure)"</span><span style="color: #FF0000;">
             Targets</span><span style="color: #0000FF;">="TestConfiguration"</span><span style="color: #FF0000;">
             StopOnFirstFailure</span><span style="color: #0000FF;">="$(StopOnFirstFailure)"</span><span style="color: #0000FF;">&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>That shows you an interesting property called <strong>TreatTestFailureAsBuildFailure</strong>, that is initially set to false. Now you have every information needed to solve the original problem, you can simply edit TFSBuild.proj file inside the definition of your build, and add this code, after the import statement of the file Microsoft.TeamFoundation.Build.Targets.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:4a6e9c2f-2a7d-4754-a732-acd36f212191" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">Target </span><span style="color: #FF0000;">Name</span><span style="color: #0000FF;">="BeforeTestConfiguration"</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
    </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">Message </span><span style="color: #FF0000;">Text</span><span style="color: #0000FF;">="Configure test runner to make the entire build fails if a single test fails"</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span><span style="color: #000000;">
    </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">PropertyGroup</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
        </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">StopOnTestFailure</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">True</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">StopOnTestFailure</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
        </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">TreatTestFailureAsBuildFailure</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">True</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">TreatTestFailureAsBuildFailure</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
    </span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">PropertyGroup</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">Target</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;"> </span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>As you can see, overriding a target is done simply redefining it in the build file. With this simple addition, the msbuild engine will call your BeforeTestConfiguration task that sets the StopOnTestFailure property to True and the <strong>TreatTestFailureAsBuildFailure </strong>also to true, thus asking to msbuild to make the entire build fails when the test task fails. Now if I fire a build with a failing test I see.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image48.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="411" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb48.png" width="575" border="0" /></a> </p>
<p>As you can see the entire build is considered to be failed, because we override the BeforeTestConfiguration. If you click on the Log file you can find the Message that confirms that your override task was really called.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:21e7c3a9-6023-4f12-907a-8cd611521a63" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">Building with tools version </span><span style="color: #000000;">"</span><span style="color: #000000;">3.5</span><span style="color: #000000;">"</span><span style="color: #000000;">.</span><span style="color: #000000;">
Target </span><span style="color: #000000;">"</span><span style="color: #000000;">CanonicalizePaths</span><span style="color: #000000;">"</span><span style="color: #000000;"> skipped</span><span style="color: #000000;">.</span><span style="color: #000000;"> Previously built successfully</span><span style="color: #000000;">.</span><span style="color: #000000;">
Target </span><span style="color: #000000;">"</span><span style="color: #000000;">BeforeTestConfiguration</span><span style="color: #000000;">"</span><span style="color: #000000;"> in file </span><span style="color: #000000;">"</span><span style="color: #000000;">C:\Users\tfsservice\AppData\Local\Temp\FluentMsTest\BuildWithTests\BuildType\TFSBuild.proj</span><span style="color: #000000;">"</span><span style="color: #000000;"> from project </span><span style="color: #000000;">"</span><span style="color: #000000;">C:\Users\tfsservice\AppData\Local\Temp\FluentMsTest\BuildWithTests\BuildType\TFSBuild.proj</span><span style="color: #000000;">"</span><span style="color: #000000;">:
Task </span><span style="color: #000000;">"</span><span style="color: #000000;">Message</span><span style="color: #000000;">"</span><span style="color: #000000;">
  Configure test runner to make the entire build fails </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> a single test fails
Done executing task </span><span style="color: #000000;">"</span><span style="color: #000000;">Message</span><span style="color: #000000;">"</span><span style="color: #000000;">.</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
<p>Configuring Tfs build is quite simple, it is only a matter of overriding certain specific targets to insert custom msbuild code in the main build process. </p>
<p>Alk.</p>
<p>Tags: <a href="http://technorati.com/tag/Team Foundation Server" rel="tag">Team Foundation Server</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=zVNnV9WkJt0:wGrJ2eIkErs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=zVNnV9WkJt0:wGrJ2eIkErs:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=zVNnV9WkJt0:wGrJ2eIkErs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=zVNnV9WkJt0:wGrJ2eIkErs:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=zVNnV9WkJt0:wGrJ2eIkErs:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=zVNnV9WkJt0:wGrJ2eIkErs:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/zVNnV9WkJt0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/29/customize-test-running-in-a-tfs-team-build/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/29/customize-test-running-in-a-tfs-team-build/</feedburner:origLink></item>
		<item>
		<title>Running tests during a build in TFS.</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/CUPsEkU0bgE/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/26/running-tests-during-a-build-in-tfs/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 17:14:04 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[Team Foundation Server]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/26/running-tests-during-a-build-in-tfs/</guid>
		<description><![CDATA[The term “Build” is a complex one that does not only means “compile source files into final assemblies”, but it comprehends many other operations that are vital for the project. One of these operation is running unit tests during Tfs build. The reason to have unit tests run at each build is to continuously keep [...]]]></description>
			<content:encoded><![CDATA[<p>The term “Build” is a complex one that does not only means “compile source files into final assemblies”, but it comprehends many other operations that are vital for the project. One of these operation is running unit tests during Tfs build. The reason to have unit tests run at each build is to continuously keep track of the quality of the project. </p>
<p>Specifying test to run in a Tfs build is really simple, since you have a specific step of the wizard dedicated to this operation.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image42.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="312" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb42.png" width="413" border="0" /></a> </p>
<p>During the definition of the build, I can simply ask to automatically detect tests in all assembly that matches the pattern *.Test.dll. Now if you schedule a build you should see results of test run.&#160; Here the first result of my test build.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image43.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="221" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb43.png" width="531" border="0" /></a> </p>
<p>Now we have a problem, because the task “running tests” is failed, but we also check that we have a “No test result”, something went wrong and weare in trouble :). The most important thing to avoid when you work with Tfs is having panic <img src='http://www.nablasoft.com/alkampfer/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> you will always get detailed error of a failing build. To look at these details, you need to look in the file <em>BuildLog.txt </em>located in the shared folder used by the build (in my situation is <a href="file://\\10.0.0.200\Builds\FluentMsTest\BuildWithTests_20090625.3">\\10.0.0.200\Builds\FluentMsTest\BuildWithTests_20090625.3</a>). Since the failure is due to a Test failure, I need to look for string <strong>testtoolstask</strong> (the task related to running test) to find problem related to unit testing.</p>
<p>Here is what I found</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:b78a59db-0b81-454f-b9ed-eeceb51ffc73" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">SBUILD : warning : Visual Studio Team System </span><span style="color: #0000FF;">for</span><span style="color: #000000;"> Software Testers or Visual Studio Team System </span><span style="color: #0000FF;">for</span><span style="color: #000000;"> Software Developers is required to </span><span style="color: #0000FF;">run</span><span style="color: #000000;"> tests as part of a Team Build</span><span style="color: #000000;">.</span><span style="color: #000000;">
  The previous error was converted to a warning because the task was called with ContinueOnError</span><span style="color: #000000;">=</span><span style="color: #000000;">true</span><span style="color: #000000;">.</span><span style="color: #000000;">
  Build continuing because </span><span style="color: #000000;">"</span><span style="color: #000000;">ContinueOnError</span><span style="color: #000000;">"</span><span style="color: #000000;"> </span><span style="color: #0000FF;">on</span><span style="color: #000000;"> the task </span><span style="color: #000000;">"</span><span style="color: #000000;">TestToolsTask</span><span style="color: #000000;">"</span><span style="color: #000000;"> is </span><span style="color: #0000FF;">set</span><span style="color: #000000;"> to </span><span style="color: #000000;">"</span><span style="color: #000000;">true</span><span style="color: #000000;">"</span><span style="color: #000000;">.</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
</p>
<p>Ok, it seems that I forgot to install Visual Studio Team System for Software Tester in the Tfs test machine (I’m doing posts using a test virtual machine installed ex novo). Visual studio is needed, because the build is done with msbuild tool, and if visual studio is not present the build machine does not have the correct tasks to use with msbuild. Another interesting stuff is that this error states that build can continue, because the ContinueOnError of “TestToolsTask” is set to true. This is the default setting, when something goes wrong with running tests, the build does not fail, and we have a&#160; <strong>“partially succeeded” </strong>build.</p>
<p>Now when you install Visual Studio Team System for Software Testers on the build machine, you will finally see test result.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image44.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="192" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb44.png" width="610" border="0" /></a> </p>
<p>The interesting stuff here is that if you click on the hilighted link, you can download test results on your machine. The file you download can be opened directly from visual studio, and you can examine results as if you executed them locally.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image45.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="455" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb45.png" width="564" border="0" /></a></p>
<p>Once again we can see that setting Tfs to run unit tests during the build is a simple process, and can be simply done with the wizard. In the next post of the series I’ll deal on more advanced configuration for test run during a build.</p>
<p>alk.</p>
<p>Tags: <a href="http://technorati.com/tag/Team foundation Server Build" rel="tag">Team foundation Server Build</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=CUPsEkU0bgE:9PI4rSJGE8s:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=CUPsEkU0bgE:9PI4rSJGE8s:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=CUPsEkU0bgE:9PI4rSJGE8s:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=CUPsEkU0bgE:9PI4rSJGE8s:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=CUPsEkU0bgE:9PI4rSJGE8s:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=CUPsEkU0bgE:9PI4rSJGE8s:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/CUPsEkU0bgE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/26/running-tests-during-a-build-in-tfs/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/26/running-tests-during-a-build-in-tfs/</feedburner:origLink></item>
		<item>
		<title>Import log and filegroup file sizes option for Vs Db edition</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/um_ZHCSOrbI/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/26/import-log-and-filegroup-file-sizes-option-for-vs-db-edition/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 12:03:15 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[.NET framework]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/26/import-log-and-filegroup-file-sizes-option-for-vs-db-edition/</guid>
		<description><![CDATA[In previous post I deal with file size in VS DB edition. To avoid this problem, (as my friend Lorenzo pointed me out), when you import the database structure, with the Database Project wizard, you must not select the “Import log and filegroup file size”.
 
If you deselect this option the import wizard does not [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.nablasoft.com/alkampfer/index.php/2009/06/26/vs-database-edition-pay-attention-to-file-size-when-you-import-db/">previous post</a> I deal with file size in VS DB edition. To avoid this problem, (as my friend <a href="http://www.geniodelmale.info/">Lorenzo</a> pointed me out), when you import the database structure, with the Database Project wizard, you must not select the “Import log and filegroup file size”.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image41.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="223" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb41.png" width="495" border="0" /></a> </p>
<p>If you deselect this option the import wizard does not check the actual file size of the database that is being imported.</p>
<p>alk.</p>
<p>Tags: <a href="http://technorati.com/tag/Visual Studio Database Edition" rel="tag">Visual Studio Database Edition</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=um_ZHCSOrbI:wAJfGpiiuZ8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=um_ZHCSOrbI:wAJfGpiiuZ8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=um_ZHCSOrbI:wAJfGpiiuZ8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=um_ZHCSOrbI:wAJfGpiiuZ8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=um_ZHCSOrbI:wAJfGpiiuZ8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=um_ZHCSOrbI:wAJfGpiiuZ8:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/um_ZHCSOrbI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/26/import-log-and-filegroup-file-sizes-option-for-vs-db-edition/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/26/import-log-and-filegroup-file-sizes-option-for-vs-db-edition/</feedburner:origLink></item>
		<item>
		<title>VS Database Edition, pay attention to file size when you import db</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/H9QJLSLbPmI/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/26/vs-database-edition-pay-attention-to-file-size-when-you-import-db/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 08:43:06 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[.NET framework]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/26/vs-database-edition-pay-attention-to-file-size-when-you-import-db/</guid>
		<description><![CDATA[I use Database Edition on a legacy database that is very big, when I created the database project I simply ask to VS database edition to import the structure and everything is ok. Then I noticed that deploy operation when database does not exists on the server is really slow. I use in the past [...]]]></description>
			<content:encoded><![CDATA[<p>I use Database Edition on a legacy database that is very big, when I created the database project I simply ask to VS database edition to import the structure and everything is ok. Then I noticed that deploy operation when database does not exists on the server is really slow. I use in the past some custom test infrastructure to preload the db, I have a lot of test that works in this way and I do not want to delete them. These test will simply delete the entire database and recreate it empty to start preloading.</p>
<p>Now with VS DB edition I write test more easily using the data generation plan, but usually I run both the old tests and the new ones, and I noticed that the deploy of my DB project is incredibly slow when the db does not exists.</p>
<p>when I look at the database folder I saw that my test database is 40 GB big, I was astonished by this fact, since it is deleted at each test run and have small preload set. This problem was caused by the fact that VS DB edition imported the whole structure of the DB as well as file dimension. If you go to “Schema Objects”, then “Storage” then “Files” you can find several .sql files that contain definitions of the physical files of the database. Examining the files I found entries like this.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:3e41092d-9101-4d75-afde-08335b4c19a2" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">ALTER</span><span style="color: #000000;"> </span><span style="color: #0000FF;">DATABASE</span><span style="color: #000000;"> </span><span style="color: #FF0000;">[</span><span style="color: #FF0000;">$(DatabaseName)</span><span style="color: #FF0000;">]</span><span style="color: #000000;">
    </span><span style="color: #0000FF;">ADD</span><span style="color: #000000;"> </span><span style="color: #0000FF;">FILE</span><span style="color: #000000;"> (NAME </span><span style="color: #808080;">=</span><span style="color: #000000;"> </span><span style="color: #FF0000;">[</span><span style="color: #FF0000;">MyFileName</span><span style="color: #FF0000;">]</span><span style="color: #000000;">, FILENAME </span><span style="color: #808080;">=</span><span style="color: #000000;"> </span><span style="color: #FF0000;">'</span><span style="color: #FF0000;">$(DefaultDataPath)$(DatabaseName).mdf</span><span style="color: #FF0000;">'</span><span style="color: #000000;">, SIZE </span><span style="color: #808080;">=</span><span style="color: #000000;"> </span><span style="color: #800000; font-weight: bold;">16000000</span><span style="color: #000000;"> KB, MAXSIZE </span><span style="color: #808080;">=</span><span style="color: #000000;"> UNLIMITED, FILEGROWTH </span><span style="color: #808080;">=</span><span style="color: #000000;"> </span><span style="color: #800000; font-weight: bold;">64000</span><span style="color: #000000;"> KB) </span><span style="color: #0000FF;">TO</span><span style="color: #000000;"> FILEGROUP </span><span style="color: #FF0000;">[</span><span style="color: #FF0000;">PRIMARY</span><span style="color: #FF0000;">]</span><span style="color: #000000;">;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>This means that each time VS DB edition does a deploy this file is 16 gigabytes big, and the operating system take times to find space on disks. The solution was changing this value to a reasonable value (10 megabytes for each file). Now deploy operation is considerably faster.</p>
<p>alk.</p>
<p>Tags: <a href="http://technorati.com/tag/Visual Studio Database Edition" rel="tag">Visual Studio Database Edition</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=H9QJLSLbPmI:DEkwsDPUn8Y:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=H9QJLSLbPmI:DEkwsDPUn8Y:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=H9QJLSLbPmI:DEkwsDPUn8Y:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=H9QJLSLbPmI:DEkwsDPUn8Y:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=H9QJLSLbPmI:DEkwsDPUn8Y:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=H9QJLSLbPmI:DEkwsDPUn8Y:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/H9QJLSLbPmI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/26/vs-database-edition-pay-attention-to-file-size-when-you-import-db/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/26/vs-database-edition-pay-attention-to-file-size-when-you-import-db/</feedburner:origLink></item>
		<item>
		<title>I do not have time to write tests excuse</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/z0pdkPKfVF0/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/26/i-do-not-have-time-to-write-tests-excuse/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 07:27:27 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/26/i-do-not-have-time-to-write-tests/</guid>
		<description><![CDATA[I’m not a tests fanatic, but I use a lot of unit tests in during my development days. I do not aim to 100% coverage, and I do not believe that TDD can be used in every moment, and I use unit testing when it is necessary for me.
Sometimes it happens that someone calls me [...]]]></description>
			<content:encoded><![CDATA[<p>I’m not a tests fanatic, but I use a lot of unit tests in during my development days. I do not aim to 100% coverage, and I do not believe that TDD can be used in every moment, and I use unit testing when it is necessary for me.</p>
<p>Sometimes it happens that someone calls me to solve a problem in code, and quite often i say “Write a unit test that reproduce the problem, then begin to investigate”. Quite often one I got a reply of </p>
<blockquote><p>I’m in a hurry, I do not have time to write test, I must correct that bug as soon as possible</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image39.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="160" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb39.png" width="202" border="0" /></a> </p>
</blockquote>
<p>I’m aware that writing a test consume time, but quite often in the end a test save you time. After that people told me that he do not have time, he shows me the problem, then fire a big web site from a .NET solution with 60 projects, we have to wait about 40 seconds for the app to start, then browse to a web page, enter data, and verify if the answer is correct.</p>
<p>The problem is that we are testing a function that use some stored procedures and some .net code, so if the problem is still there, we need to return to Management Studio, change the procedure or change the code. If we must change the code, we need to recompile, fire the app again (and wait for the app to reinitialize) bla bla bla.</p>
<p>For big application the startup time of the whole application is just too big to think that F5 approach is a feasible solution to verify if a bug is corrected. One day, for a very difficult bug, after a couple of hours I realized that more than half of the time was spent waiting the app to start and insert data to exercise the function……. too bad. This means that we are developing slowly, and moreover it is frustrating to: “do a modification and wait for one minute to see if it corrects the problem”</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image40.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="149" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb40.png" width="244" border="0" /></a> </p>
<p>Working this way lead to this pattern</p>
<ol>
<li>Write a modification</li>
<li>Fire the program with F5</li>
<li>Goes to facebook, twitter, waiting for the app to start</li>
<li>The app started but you are reading some blog </li>
</ol>
<p>This is incredible inefficient way to develop software. </p>
<p>My suggestion is, whenever you need to correct bug, or verify some feature of a low level layer of your application, do not exercise it from the User Interface but write a test. It will save you time in the long run. Most of the problem is that writing test is not so simple, expecially in complex product, but when you are experienced in unit testing, writing a test is really a breeze. Most of the time you will end with a test infrastructure specific for your project, where creating a new test is a matter of seconds. </p>
<p>Alk.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=z0pdkPKfVF0:xs_qppcubNI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=z0pdkPKfVF0:xs_qppcubNI:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=z0pdkPKfVF0:xs_qppcubNI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=z0pdkPKfVF0:xs_qppcubNI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=z0pdkPKfVF0:xs_qppcubNI:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=z0pdkPKfVF0:xs_qppcubNI:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/z0pdkPKfVF0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/26/i-do-not-have-time-to-write-tests-excuse/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/26/i-do-not-have-time-to-write-tests-excuse/</feedburner:origLink></item>
		<item>
		<title>Team foundation Build – Share Builds among multiple servers</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/piIidXQuxlU/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/25/team-foundation-build-share-builds-among-multiple-servers/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 19:17:22 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[Software Architecture]]></category>

		<category><![CDATA[Team Foundation Server]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/25/team-foundation-build-share-builds-among-multiple-servers/</guid>
		<description><![CDATA[When you begin to use Team Foundation Server, you will create different builds for all of your company’s projects. Since building complex products can be resource intensive, it is likely that your Team Foundation Server machine starts to perform slowly. This is a typical issue of Continuous integration servers, since they compile projects at each [...]]]></description>
			<content:encoded><![CDATA[<p>When you begin to use Team Foundation Server, you will create different builds for all of your company’s projects. Since building complex products can be resource intensive, it is likely that your Team Foundation Server machine starts to perform slowly. This is a typical issue of Continuous integration servers, since they compile projects at each check-in you will end with a lot of builds and a lot of work to do. </p>
<p>Team Foundation Server addresses this issue separating <em><a href="http://msdn.microsoft.com/en-us/library/ms181710.aspx">build machines</a></em> from <em>Team Foundation Server</em>. If you find that the build machine is becoming slow, you can simply use another machine in the network to execute some of the builds. In real environment you can even avoid to install build engine in the Tfs machine, delegating builds to other servers. First of all go into another machine, fire the installer of Team Foundation Server, and choose to install a “Team Foundation Build”. </p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image35.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="203" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb35.png" width="510" border="0" /></a></p>
<p><strong><em>Note:</em></strong> if you do not have Active Directory<em> you Must create in this machine an account with the same name/password of an account of the machine where Team Foundation Server is running and that account must have right to access tfs</em>. This is a standar requirement, the Build Server needs to access Team Foundation Server to get sources to build and store build result, etc, etc. so it is of vital importance that it runs with sufficient privilege to access TFS server. If you have active directory you do not need to create a specific account, but you must select one AD user that have credential to access TFS during the installation.</p>
<p>When the installer finished, you can go to Visual Studio, Right Click on the Builds in the Team Foundation Server Explorer Tree, then choose “Manage Build Agents”</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image36.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="141" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb36.png" width="249" border="0" /></a> </p>
<p>Now you can add additional Build Agent, and you can choose the new machine name, where you had previously installed the Team Foundation Build.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image37.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="408" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb37.png" width="444" border="0" /></a> </p>
<p>Now you can use this new machine to run Builds simply specifying this agent when you create a Build Definition, or you can use it when you manually queue new build. It is really important that the user credentials used to run the Build Service in the new Build machine has the right to access the Team Foundation Server Machine as stated before.</p>
<p>If you had already installed the team Build engine with a wrong user don’t panic, you can still manually change build machine settings to correctly access TFS. Go to Service control panel and change the credential used by the “Visual Studio Team Foundation Build” service to use an user that has sufficient credential for TFS. Now restart the service.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image38.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="242" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb38.png" width="617" border="0" /></a> </p>
<p>It is highly possible that when you restart the service you get “<strong>access is Denied</strong>” error, it means that the new account does not have sufficient rights to run, first of all the user needs rights to access the folder where you install the Build Agent, but this is usually not enough. <em>The only way to understand exactly what is wrong <strong>is going into the Event Viewer</strong></em> where you can find detailed errors like this one.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:e797dcdf-51f5-4dc5-8039-ba55a7f64343" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">Detailed Message: TF224004: The Visual Studio Team Foundation Build service failed to </span><span style="color: #0000FF;">start</span><span style="color: #000000;"> because WS2008V1</span><span style="color: #000000;">\</span><span style="color: #000000;">alkampfer does </span><span style="color: #0000FF;">not</span><span style="color: #000000;"> have the required access permissions </span><span style="color: #0000FF;">for</span><span style="color: #000000;"> address http:</span><span style="color: #000000;">//</span><span style="color: #000000;">ws2008v1:</span><span style="color: #000000;">9191</span><span style="color: #000000;">/</span><span style="color: #000000;">Build</span><span style="color: #000000;">/</span><span style="color: #000000;">v2</span><span style="color: #000000;">.</span><span style="color: #000000;">0</span><span style="color: #000000;">/</span><span style="color: #000000;">AgentService</span><span style="color: #000000;">.</span><span style="color: #000000;">asmx</span><span style="color: #000000;">.</span><span style="color: #000000;">
Exception Message: HTTP could </span><span style="color: #0000FF;">not</span><span style="color: #000000;"> register URL http:</span><span style="color: #000000;">//+</span><span style="color: #000000;">:</span><span style="color: #000000;">9191</span><span style="color: #000000;">/</span><span style="color: #000000;">Build</span><span style="color: #000000;">/</span><span style="color: #000000;">v2</span><span style="color: #000000;">.</span><span style="color: #000000;">0</span><span style="color: #000000;">/</span><span style="color: #000000;">AgentService</span><span style="color: #000000;">.</span><span style="color: #000000;">asmx</span><span style="color: #000000;">/.</span><span style="color: #000000;"> Your process does </span><span style="color: #0000FF;">not</span><span style="color: #000000;"> have access rights to this namespace </span><span style="color: #000000;">(</span><span style="color: #000000;">see http:</span><span style="color: #000000;">//</span><span style="color: #000000;">go</span><span style="color: #000000;">.</span><span style="color: #000000;">microsoft</span><span style="color: #000000;">.</span><span style="color: #000000;">com</span><span style="color: #000000;">/</span><span style="color: #000000;">fwlink</span><span style="color: #000000;">/</span><span style="color: #000000;">?LinkId</span><span style="color: #000000;">=</span><span style="color: #000000;">70353</span><span style="color: #000000;"> </span><span style="color: #0000FF;">for</span><span style="color: #000000;"> details</span><span style="color: #000000;">).</span><span style="color: #000000;"> </span><span style="color: #000000;">(</span><span style="color: #0000FF;">type</span><span style="color: #000000;"> AddressAccessDeniedException</span><span style="color: #000000;">)</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
</p>
</p>
<p>This message is one of the most dreadful, it means that the user has no <a href="http://msdn.microsoft.com/en-us/library/ms733768.aspx">rights to use that url to host&#160; a web service</a>. The solution is to run this couple of commands.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:e58a65f3-aa13-47e3-b866-7fdca531b246" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">netsh http delete urlacl url</span><span style="color: #000000;">=</span><span style="color: #000000;">http:</span><span style="color: #000000;">//+</span><span style="color: #000000;">:</span><span style="color: #000000;">9191</span><span style="color: #000000;">/</span><span style="color: #000000;">Build</span><span style="color: #000000;">/</span><span style="color: #000000;">v2</span><span style="color: #000000;">.</span><span style="color: #000000;">0</span><span style="color: #000000;">/</span><span style="color: #000000;">AgentService</span><span style="color: #000000;">.</span><span style="color: #000000;">asmx
netsh http add urlacl url</span><span style="color: #000000;">=</span><span style="color: #000000;">http:</span><span style="color: #000000;">//+</span><span style="color: #000000;">:</span><span style="color: #000000;">9191</span><span style="color: #000000;">/</span><span style="color: #000000;">Build</span><span style="color: #000000;">/</span><span style="color: #000000;">v2</span><span style="color: #000000;">.</span><span style="color: #000000;">0</span><span style="color: #000000;">/</span><span style="color: #000000;">AgentService</span><span style="color: #000000;">.</span><span style="color: #000000;">asmx user</span><span style="color: #000000;">=</span><span style="color: #000000;">alkampfer</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>With these two lines of code you are giving to user <em>Alkampfer </em>(the one that has right to access Tfs and the one used to run build service) enough rights to create a web service in that url. Now you should be able to start the service. Verify if the Build Agent is running browsing the WebService page (something like <a title="http://10.0.0.11:9191/Build/v2.0/AgentService.asmx" href="http://10.0.0.11:9191/Build/v2.0/AgentService.asmx">http://10.0.0.11:9191/Build/v2.0/AgentService.asmx</a>). Now if everything is ok, you should go to “Manage Build Agents” menu and reenable agent if necessary. This step is needed because Tfs disables all Agents that are unable to run. If you fire a build with an agent that has no right to access TFS the TFS disables that agent because it is useless. When you correct the problem, you can simply edit the Build Agent definition, and change its status back to active, now you can schedule again builds on it.</p>
<p>With such a configuration you can divide build tasks across multiple machines, and the whole build process is more scalable. The advantage is that you have a single point of access (the Tfs machine), and from that point you can subdivide works between machines. Since you can install how many build server you want, the whole system is highly scalable.</p>
<p>Alk.</p>
<p>Tags: <a href="http://technorati.com/tag/Team Foundation Server" rel="tag">Team Foundation Server</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=piIidXQuxlU:85ZwQ30XAtc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=piIidXQuxlU:85ZwQ30XAtc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=piIidXQuxlU:85ZwQ30XAtc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=piIidXQuxlU:85ZwQ30XAtc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=piIidXQuxlU:85ZwQ30XAtc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=piIidXQuxlU:85ZwQ30XAtc:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/piIidXQuxlU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/25/team-foundation-build-share-builds-among-multiple-servers/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/25/team-foundation-build-share-builds-among-multiple-servers/</feedburner:origLink></item>
		<item>
		<title>A dto factory code generator with visual studio T4</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/jG5I0-CwgcM/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/24/a-dto-factory-code-generator-with-visual-studio-t4/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 17:29:00 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[Entity Framework]]></category>

		<category><![CDATA[Software Architecture]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/24/a-dto-factory-code-generator-with-visual-studio-t4/</guid>
		<description><![CDATA[Data Transfer Objects, best known as Dto, are an essential part of projects that uses services or Domain Model. Dto are great, but the disadvantage is that maintaining Dto objects is a pain, because they are composed by repetitive code, and you have no fun in writing them.
Since building a Dto is a mechanical process [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Data_Transfer_Object">Data Transfer Objects</a>, best known as Dto, are an essential part of projects that uses services or Domain Model. Dto are great, but the disadvantage is that maintaining Dto objects is a pain, because they are composed by repetitive code, and you have no fun in writing them.</p>
<p>Since building a Dto is a mechanical process it is better to use a code generation tool to generate them with little effort. If you work with visual studio 2008 the best choice in Code Generator is T4, because it is included in Visual Studio and is really good. I do not want to cover T4 syntax, because you can find tons of information following <a href="http://www.hanselman.com/blog/T4TextTemplateTransformationToolkitCodeGenerationBestKeptVisualStudioSecret.aspx">this post links</a>.</p>
<p>You can <a href="http://www.nablasoft.com/alkampfer/Storage/DtoFactory.zip">download here</a> a little project that contains a simple DtoFActory.tt file used to generate basic Dto out from a domain object. It is written with little effort, and it can contain errors, but I’m quite satisfied by the general result. To use it simply add the DtoFactory.tt file to your solution, then you can use in other tt file. In the <a href="http://www.nablasoft.com/alkampfer/Storage/DtoFactory.zip">example</a> I simply generate a EntityFramework edmx against northwind database, then I create a CustomerDto.tt file with this content.</p>
<p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:89222878-18f0-44bf-a12e-fe226e942258" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">&lt;</span><span style="color: #000000;">#@ template language</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">C#</span><span style="color: #800000;">"</span><span style="color: #000000;"> hostspecific</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">True</span><span style="color: #800000;">"</span><span style="color: #000000;"> debug</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">True</span><span style="color: #800000;">"</span><span style="color: #000000;"> #</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">
</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">#@ output extension</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">cs</span><span style="color: #800000;">"</span><span style="color: #000000;"> #</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">
</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">#@ include file</span><span style="color: #000000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">DtoFactory.tt</span><span style="color: #800000;">"</span><span style="color: #000000;"> #</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">
</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">#
</span><span style="color: #008000;">//</span><span style="color: #008000;"> &lt;copyright file="CustomerDto.tt" company="Gian Maria Ricci"&gt;
</span><span style="color: #008000;">//</span><span style="color: #008000;">  Copyright Â© Gian Maria Ricci. All Rights Reserved.
</span><span style="color: #008000;">//</span><span style="color: #008000;"> &lt;/copyright&gt;</span><span style="color: #008000;">
</span><span style="color: #000000;">    GenerateDto(
        </span><span style="color: #800000;">@"</span><span style="color: #800000;">bin\Debug\DtoFactory.Exe</span><span style="color: #800000;">"</span><span style="color: #000000;">,
        </span><span style="color: #800000;">"</span><span style="color: #800000;">DtoFactory.Customers</span><span style="color: #800000;">"</span><span style="color: #000000;">,
        </span><span style="color: #800000;">"</span><span style="color: #800000;">CustomersDto</span><span style="color: #800000;">"</span><span style="color: #000000;">,
        </span><span style="color: #800000;">"</span><span style="color: #800000;">DtoFactory</span><span style="color: #800000;">"</span><span style="color: #000000;">,
        </span><span style="color: #800000;">"</span><span style="color: #800000;">http://www.nablasoft.com/dotnet/</span><span style="color: #800000;">"</span><span style="color: #000000;">,
        </span><span style="color: #800080;">1</span><span style="color: #000000;">,
        </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> PropertyData[] {</span><span style="color: #800000;">"</span><span style="color: #800000;">CustomerId</span><span style="color: #800000;">"</span><span style="color: #000000;">, </span><span style="color: #800000;">"</span><span style="color: #800000;">CompanyName</span><span style="color: #800000;">"</span><span style="color: #000000;">, </span><span style="color: #800000;">"</span><span style="color: #800000;">ContactName</span><span style="color: #800000;">"</span><span style="color: #000000;">},
        </span><span style="color: #0000FF;">true</span><span style="color: #000000;">, </span><span style="color: #0000FF;">true</span><span style="color: #000000;">, </span><span style="color: #0000FF;">true</span><span style="color: #000000;">); 

#</span><span style="color: #000000;">&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
<p>As you can see I import the DtoFactory.tt file, then call the GenerateDto function. The first parameter is the relative path of the assembly that contains the original object. Relative means respect to the tt file itself, this is one of the part I do not like very much because you need to find out relative path and refers to the debug directory, but it can be acceptable. </p>
<p>Then I specify the fullname of the class, the name of the Dto object, the name of the namespace were to put generated class. Then I need to specify the namespace used in the DataContract attribute (I want my Dto to be transferrable by WCF), then the number of base classes to examine to find properties, a list of PropertyData object with names of the property of the original object I want in my dto, finally three boolean values to specify if I need my dto to implement INotifyPropertyChanged, INotifyPropertyChanged, and IEditableObject.</p>
<p>You can see that this simple template will generate a CustomerDto.cs file that contains a CustomersDto class that contains that three properties. The interesting part is how I generate the assembler of the Dto. To build a Dto the standard way to proceed is to take the original object and copy all needed properties into corresponding properties of the dto object. This is a suboptimal approach, because using such a technique, you are forced to load the entire object from the database. In My situation CustomersDto has only three properties, <em>why I need to load an entire Customers object into memory to build a CustomersDto object that contains only three properties</em>? The solution is in how my dtoFactory generates the assembler. </p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:606dedbe-b9b2-4f18-9482-fee451426055" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">
</span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> Expression</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">Func</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">Customers, CustomersDto</span><span style="color: #000000;">&gt;&gt;</span><span style="color: #000000;"> ExpressionSelector;
</span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> Func</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">Customers, CustomersDto</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> Selector;

</span><span style="color: #0000FF;">static</span><span style="color: #000000;"> CustomersDtoAssembler()
{

    ExpressionSelector </span><span style="color: #000000;">=</span><span style="color: #000000;"> obj </span><span style="color: #000000;">=&gt;</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> CustomersDto()
    {
        CompanyName </span><span style="color: #000000;">=</span><span style="color: #000000;"> obj.CompanyName,
        ContactName </span><span style="color: #000000;">=</span><span style="color: #000000;"> obj.ContactName,
        CustomerID </span><span style="color: #000000;">=</span><span style="color: #000000;"> obj.CustomerID,
    };
    Selector </span><span style="color: #000000;">=</span><span style="color: #000000;"> obj </span><span style="color: #000000;">=&gt;</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> CustomersDto()
    {
        CompanyName </span><span style="color: #000000;">=</span><span style="color: #000000;"> obj.CompanyName,
        ContactName </span><span style="color: #000000;">=</span><span style="color: #000000;"> obj.ContactName,
        CustomerID </span><span style="color: #000000;">=</span><span style="color: #000000;"> obj.CustomerID,
    };
}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
<p>As you can see my generator generates an <strong><em>Expression&lt;Func&lt;Customers, CustomersDto&gt;&gt;,</em></strong> and simply initialize it in static constructor with a simple lambda expression. If you are wondering why I need such a strange object let’s see how I use it</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:b51f2fb9-c390-483c-9bd8-b55119b63661" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">using</span><span style="color: #000000;"> (NorthwindEntities context </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> NorthwindEntities())
{
    var Query </span><span style="color: #000000;">=</span><span style="color: #000000;"> context.Customers.
       Where(c </span><span style="color: #000000;">=&gt;</span><span style="color: #000000;"> c.CustomerID.StartsWith(</span><span style="color: #800000;">"</span><span style="color: #800000;">A</span><span style="color: #800000;">"</span><span style="color: #000000;">))
       .Select(CustomersDtoAssembler.ExpressionSelector);

    </span><span style="color: #0000FF;">foreach</span><span style="color: #000000;"> (CustomersDto customerDto </span><span style="color: #0000FF;">in</span><span style="color: #000000;"> Query)
    {
        Console.WriteLine(</span><span style="color: #800000;">"</span><span style="color: #800000;">ID: {0}, ContactName: {1}, CompanyName {2}</span><span style="color: #800000;">"</span><span style="color: #000000;">,
            customerDto.CustomerID, customerDto.ContactName, customerDto.CompanyName);
    }
}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Thanks to LINQ to Entities, I can simply build a query to the NorthwindEntites data context, selecting Customers, applying a filter and specify the assembler <strong>ExpressionSelector </strong>seen before. This produces this query against my database.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:6e5a60af-327d-4c4e-91db-f9f220786901" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">SELECT</span><span style="color: #000000;">
</span><span style="color: #800000; font-weight: bold;">1</span><span style="color: #000000;"> </span><span style="color: #0000FF;">AS</span><span style="color: #000000;"> </span><span style="color: #FF0000;">[</span><span style="color: #FF0000;">C1</span><span style="color: #FF0000;">]</span><span style="color: #000000;">,
</span><span style="color: #FF0000;">[</span><span style="color: #FF0000;">Extent1</span><span style="color: #FF0000;">]</span><span style="color: #000000;">.</span><span style="color: #FF0000;">[</span><span style="color: #FF0000;">CompanyName</span><span style="color: #FF0000;">]</span><span style="color: #000000;"> </span><span style="color: #0000FF;">AS</span><span style="color: #000000;"> </span><span style="color: #FF0000;">[</span><span style="color: #FF0000;">CompanyName</span><span style="color: #FF0000;">]</span><span style="color: #000000;">,
</span><span style="color: #FF0000;">[</span><span style="color: #FF0000;">Extent1</span><span style="color: #FF0000;">]</span><span style="color: #000000;">.</span><span style="color: #FF0000;">[</span><span style="color: #FF0000;">ContactName</span><span style="color: #FF0000;">]</span><span style="color: #000000;"> </span><span style="color: #0000FF;">AS</span><span style="color: #000000;"> </span><span style="color: #FF0000;">[</span><span style="color: #FF0000;">ContactName</span><span style="color: #FF0000;">]</span><span style="color: #000000;">,
</span><span style="color: #FF0000;">[</span><span style="color: #FF0000;">Extent1</span><span style="color: #FF0000;">]</span><span style="color: #000000;">.</span><span style="color: #FF0000;">[</span><span style="color: #FF0000;">CustomerID</span><span style="color: #FF0000;">]</span><span style="color: #000000;"> </span><span style="color: #0000FF;">AS</span><span style="color: #000000;"> </span><span style="color: #FF0000;">[</span><span style="color: #FF0000;">CustomerID</span><span style="color: #FF0000;">]</span><span style="color: #000000;">
</span><span style="color: #0000FF;">FROM</span><span style="color: #000000;"> </span><span style="color: #FF0000;">[</span><span style="color: #FF0000;">dbo</span><span style="color: #FF0000;">]</span><span style="color: #000000;">.</span><span style="color: #FF0000;">[</span><span style="color: #FF0000;">Customers</span><span style="color: #FF0000;">]</span><span style="color: #000000;"> </span><span style="color: #0000FF;">AS</span><span style="color: #000000;"> </span><span style="color: #FF0000;">[</span><span style="color: #FF0000;">Extent1</span><span style="color: #FF0000;">]</span><span style="color: #000000;">
</span><span style="color: #0000FF;">WHERE</span><span style="color: #000000;"> (</span><span style="color: #FF00FF;">CAST</span><span style="color: #000000;">(</span><span style="color: #FF00FF;">CHARINDEX</span><span style="color: #000000;">(N</span><span style="color: #FF0000;">'</span><span style="color: #FF0000;">A</span><span style="color: #FF0000;">'</span><span style="color: #000000;">, </span><span style="color: #FF0000;">[</span><span style="color: #FF0000;">Extent1</span><span style="color: #FF0000;">]</span><span style="color: #000000;">.</span><span style="color: #FF0000;">[</span><span style="color: #FF0000;">CustomerID</span><span style="color: #FF0000;">]</span><span style="color: #000000;">) </span><span style="color: #0000FF;">AS</span><span style="color: #000000;"> </span><span style="color: #0000FF;">int</span><span style="color: #000000;">)) </span><span style="color: #808080;">=</span><span style="color: #000000;"> </span><span style="color: #800000; font-weight: bold;">1</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Thanks to the <strong>Expression&lt;Func&lt;Customers, CustomerDto&gt;&gt;,</strong> Entity Framework knows how to retrieve only the data he need to create the Dto, wonderful :D. With such a powerful generator I can create Dto objects with few lines of code.</p>
<p>Since this generator is not still fully tested feel free to send me suggestions, bugs, feature you wish to have, etc, etc.</p>
<p>Alk.</p>
<p><a href="http://www.nablasoft.com/alkampfer/Storage/DtoFactory.zip">Code Download.</a></p>
<p>Tags: <a href="http://technorati.com/tag/Dto" rel="tag">Dto</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=jG5I0-CwgcM:RhV5eZs-Icg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=jG5I0-CwgcM:RhV5eZs-Icg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=jG5I0-CwgcM:RhV5eZs-Icg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=jG5I0-CwgcM:RhV5eZs-Icg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=jG5I0-CwgcM:RhV5eZs-Icg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=jG5I0-CwgcM:RhV5eZs-Icg:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/jG5I0-CwgcM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/24/a-dto-factory-code-generator-with-visual-studio-t4/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/24/a-dto-factory-code-generator-with-visual-studio-t4/</feedburner:origLink></item>
		<item>
		<title>Introspection vs reflection</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/Zra2S2NjJ3Y/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/24/introspection-vs-reflection/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 09:33:19 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[.NET framework]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/24/introspection-vs-reflection/</guid>
		<description><![CDATA[As every .Net programmer know, reflection is the standard way to analyze an assembly finding types, interfaces etc. This approach cannot be used in all situations, as an example when you generate code with T4 engine in visual studio 2008.
As Oleg states here, if you need to analyze assemblies during code generation, you should use [...]]]></description>
			<content:encoded><![CDATA[<p>As every .Net programmer know, reflection is the standard way to analyze an assembly finding types, interfaces etc. This approach cannot be used in all situations, as an example when you generate code with T4 engine in visual studio 2008.</p>
<p>As <a href="http://www.olegsych.com/2008/09/t4-tutorial-debugging-code-generation-files/">Oleg</a> states here, if you need to analyze assemblies during code generation, you should use fxcop introspection vs standard reflection. Using introspection is really simple, first of all you need to locate a couple of dll in the fxcop installation folder, and references them in the solution.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image34.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="89" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb34.png" width="165" border="0" /></a> </p>
<p>Microsoft.Cci.dll contains a lot of classes to use Introspection. The main problem is that there is not great help on how to use these classes, but it can be quite intuitive.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:2027c838-4138-4b0c-bf7d-526a95755098" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">AssemblyNode modelAssembly </span><span style="color: #000000;">=</span><span style="color: #000000;"> AssemblyNode.GetAssembly(</span><span style="color: #800000;">@"</span><span style="color: #800000;">KilogWms.Model.dll</span><span style="color: #800000;">"</span><span style="color: #000000;">);
Identifier namespaceIdentifier </span><span style="color: #000000;">=</span><span style="color: #000000;"> Identifier.For(</span><span style="color: #800000;">"</span><span style="color: #800000;">KilogWms.Model</span><span style="color: #800000;">"</span><span style="color: #000000;">);
Identifier typeIdentifier </span><span style="color: #000000;">=</span><span style="color: #000000;"> Identifier.For(</span><span style="color: #800000;">"</span><span style="color: #800000;">Location</span><span style="color: #800000;">"</span><span style="color: #000000;">);
TypeNode locationNode </span><span style="color: #000000;">=</span><span style="color: #000000;"> modelAssembly.GetType(namespaceIdentifier, typeIdentifier);
Assert.That(locationNode.BaseType.Name.Name, Is.EqualTo(</span><span style="color: #800000;">"</span><span style="color: #800000;">LocationBase</span><span style="color: #800000;">"</span><span style="color: #000000;">));</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>With this code I load an assembly specifying dll name, then create a couple of identifier, the namespace and the name of a class, finally with the GetType() method of the AssemblyNode I get a TypeNode that contains all information on the Type. The good part of introspection engine is that the assembly is not really loaded into the appdomain of the caller. You can verify with with a little test, start code and load an AssemblyNode, then try to delete the assembly from disk, you cannot do this because the file is in use, now call Dispose() on AssemblyNode object, and try to delete the assembly again, now you can delete it with no problem. This happens because Introspection does not really load the assembly file into the process, it simply inspect it, so when you dispose the AssemblyNode the file is free again.</p>
<p>Looking at the above code you can see that using Introspection is really intuitive, with intellisense is really simple to figure out how to find information about classes.</p>
<p>Alk.</p>
<p>Tags: <a href="http://technorati.com/tag/FxCop Introspection" rel="tag">FxCop Introspection</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=Zra2S2NjJ3Y:6OxFA7jId1k:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=Zra2S2NjJ3Y:6OxFA7jId1k:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=Zra2S2NjJ3Y:6OxFA7jId1k:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=Zra2S2NjJ3Y:6OxFA7jId1k:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=Zra2S2NjJ3Y:6OxFA7jId1k:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=Zra2S2NjJ3Y:6OxFA7jId1k:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/Zra2S2NjJ3Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/24/introspection-vs-reflection/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/24/introspection-vs-reflection/</feedburner:origLink></item>
		<item>
		<title>Visual Studio Database edition How to find objects that reference other objects</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/tVwEN4--gmM/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/23/visual-studio-database-edition-how-to-find-objects-that-reference-other-objects/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 13:31:19 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[.NET framework]]></category>

		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/23/visual-studio-database-edition-find-object-that-references-table/</guid>
		<description><![CDATA[Another feature of Visual Studio Database Edition I cannot live without, is the possibility to find all objects that references a specific table or stored procedure etc. To see a dependency for an object simply click on the SchemaView and then you can right click on a table, and choose “View Dependencies”
 
This command will [...]]]></description>
			<content:encoded><![CDATA[<p>Another feature of Visual Studio Database Edition I cannot live without, is the possibility to find all objects that references a specific table or stored procedure etc. To see a dependency for an object simply click on the SchemaView and then you can right click on a table, and choose “View Dependencies”</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image30.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="319" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb30.png" width="329" border="0" /></a> </p>
<p>This command will open a menu that shows all objects that references this specific object, as well as all database objects that are referenced by this object. This function is of invaluable use when you need to change or modify something, and gives you an invaluable sight on dependency between database structure. </p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image31.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="380" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb31.png" width="349" border="0" /></a> </p>
<p>In this specific situation I removed some old features from the code, and I want also to remove all objects in database that are related to those features. Since I know that these feature are related to three tables, I can simply check all dependencies of those tables, that and verify that I’m not breaking anything. When I’m sure I can remove tables files from the solution.</p>
<p>After table files are deleted, I return in the Schema view. Now I can open the “Orphaned Objects” to view all object that are orphan.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image32.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="230" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb32.png" width="286" border="0" /></a> </p>
<p>This is an invaluable help because you immediately view all objects that are now orphan because I deleted some tables. As you can see in “orphaned Objects” you can view only keys, constraints, etc, and you do not see stored or view. If you watch in schema view to stored procedure section you can find that each stored that references one of those removed table is marked as “warning”</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image33.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="78" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb33.png" width="265" border="0" /></a> </p>
<p>If I build the project I obtain a lot of errors, because I have stored and views that reference missing tables.</p>
<p>I simply check again each stored and view, some of them are to be deleted, and some other needs only modifications. Thanks to database edition I know when I have finished work because until I have a single object that references missing object the project will not compile. Finally I fire my database tests to verify that everything is still working.</p>
<p>If something went wrong (because at a certain point you find that you should not removed those tabled because they are still used somewhere), you can simply undo everything and starts again the process. The great advantage working with Database Edition is that you works only with&#160; local files, and you can commit changes to databases only when you are really sure that everything is ok. Now database can be managed like other code, you modify it, you test it, and until you does not check in, nothing gets really changed.</p>
<p>alk.</p>
<p>Tags: <a href="http://technorati.com/tag/Visual Studio Database Edition" rel="tag">Visual Studio Database Edition</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=tVwEN4--gmM:I670NISYWXE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=tVwEN4--gmM:I670NISYWXE:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=tVwEN4--gmM:I670NISYWXE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=tVwEN4--gmM:I670NISYWXE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=tVwEN4--gmM:I670NISYWXE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=tVwEN4--gmM:I670NISYWXE:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/tVwEN4--gmM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/23/visual-studio-database-edition-how-to-find-objects-that-reference-other-objects/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/23/visual-studio-database-edition-how-to-find-objects-that-reference-other-objects/</feedburner:origLink></item>
		<item>
		<title>Creating a build with Tfs</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/TII34vJPKhI/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/22/creating-a-build-with-tfs/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 15:32:23 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[.NET framework]]></category>

		<category><![CDATA[Team Foundation Server]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/22/creating-a-build-with-tfs/</guid>
		<description><![CDATA[I worked for long time with NANT + CC.net as continuous integration tools. I used subversion as Source Control System and use Mantis or Redmine for issue tracking. 
The main disadvantage of using such a configuration is the need to make each tool communicate with others, the good part is that these tools are open [...]]]></description>
			<content:encoded><![CDATA[<p>I worked for long time with NANT + CC.net as continuous integration tools. I used subversion as Source Control System and use Mantis or Redmine for issue tracking. </p>
<p>The main disadvantage of using such a configuration is the need to make each tool communicate with others, the good part is that these tools are open source. Team Foundation Server on the other side is a Commercial tool, so you have to pay it, but it gives you a lot of features in a single unified tool, and this is Great. Let’s see as an example how to set up a continuous integration server for a simple project.</p>
<p>Leveraging the power of a Continuos Integration machine with open source tool is not difficult, but you need to do some work, in CC.net you have to create a NANT or MSbuild script, configure cc.net with ccnet.config and so on. The good part of Team Foundation Server is that creating a build is a matter of a right click on the builds node</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image20.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="159" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb20.png" width="244" border="0" /></a> </p>
<p>The “New Build Definition” shows you a wizard that helps you in creating the build, the first time you run it tells you that it does not find any build file in the source code, so it suggest you to use a wizard to create one.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image21.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="207" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb21.png" width="605" border="0" /></a> </p>
</p>
<p>The wizard is really simple, first of all it asks you the list of solutions to build.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image22.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="144" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb22.png" width="491" border="0" /></a> </p>
<p>In this test project I have only one solution so I select it. Then you select the configuration (Debug/Release/Etc). You can forget any option for now. When you click finish you will return to the original wizard, now you can decide how many result you want to mantain</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image23.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="211" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb23.png" width="406" border="0" /></a> </p>
<p>This is a great option, because it permits you to avoid keeping too many data, as example for failing builds. The next step asks you the build agent to use, since it is my first build, I create an agent for the first time</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image24.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="417" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb24.png" width="438" border="0" /></a> </p>
<p>I’ve installed the Build Engine on the same machine where the Tfs runs, so I create an agent named <em>StandardBuildAgent,</em> then specify the name of the computer <em>TFSALKAMPFER</em> , when you press OK you can use that agent to run the build, now you must specify network share where to put the result</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image25.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="165" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb25.png" width="353" border="0" /></a> </p>
<p>In the last step you simply decide when to trigger a build, and since I want really continuos integration I specify a build at each check-in-</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image26.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="204" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb26.png" width="456" border="0" /></a> </p>
<p>Now the build is created, you can right click and schedule a new build (this is the equivalent to Force a build in CC.net). The result gives you a lot of informations on what is happened.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image27.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="448" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb27.png" width="598" border="0" /></a> </p>
<p>This build have some errors, if you scroll down the result of the build you can find detailed error, stored in file Debug.txt. This file contains the error output of the msBuild engine so you can understand what goes wrong. The good news is that, if the build goes ok, you can find a lot of information in the shared folder you specified during build definition.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image28.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="141" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb28.png" width="445" border="0" /></a> </p>
<p>And if you click into the Debug folder you can find all the artifacts produced by the build.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image29.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="178" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb29.png" width="425" border="0" /></a> </p>
<p>Respect to CC.Ner, Team Foundation Server is really simpler, with few clicks you can create a Build Definition that is triggered at each check-in, gives you a lot of detailed information, and copies all artifacts in a network share. I really care about Continuous Integration Machine, and the ability to directly manage it inside Visual Studio with few clicks is really a great feature respect CC.net. </p>
<p>Alk.</p>
<p>Tags: <a href="http://technorati.com/tag/Team Foundation Server" rel="tag">Team Foundation Server</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=TII34vJPKhI:TRt5K6xiWDc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=TII34vJPKhI:TRt5K6xiWDc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=TII34vJPKhI:TRt5K6xiWDc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=TII34vJPKhI:TRt5K6xiWDc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=TII34vJPKhI:TRt5K6xiWDc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=TII34vJPKhI:TRt5K6xiWDc:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/TII34vJPKhI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/22/creating-a-build-with-tfs/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/22/creating-a-build-with-tfs/</feedburner:origLink></item>
		<item>
		<title>Database Test With DataBase Edition</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/gsmfXY9d4Xg/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/19/database-test-with-database-edition/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 10:14:09 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/19/database-test-with-database-edition/</guid>
		<description><![CDATA[I really like the ability to use the Visual Studio Team System Database Edition to create Database Test where I can specify the Database Project with the structure and a DataGeneration Plan to preload data for testing.
While this is really good to create a set of unit test that are repeatable, it can slow up [...]]]></description>
			<content:encoded><![CDATA[<p>I really like the ability to use the Visual Studio Team System Database Edition to create Database Test where I can specify the Database Project with the structure and a DataGeneration Plan to preload data for testing.</p>
<p>While this is really good to create a set of unit test that are repeatable, it can slow up testing process during development. Let’s make an example, I need to made a change in a stored procedure, so I write some tests to verify the new features, verify that they fail, and then start to work.</p>
<p>The process usually is</p>
<ol>
<li>Modify the stored in the Database Project</li>
<li>Run the new tests</li>
<li>If new tests are all green rerun the whole test suite to verify that you have not broke something else.</li>
</ol>
<p>If the modification is really complex you need to modify/run test more than one time, but since you are always running the same little test suite, you really does not need to redeploy database structure and run data generation plan at each iteration. Deploying database and running data generation plan at each test run can be time consuming. </p>
<p>I’m used to setup database test with transaction management to automatically rollback a transaction after each test, you can use <a href="http://www.codeplex.com/MSTestExtensions">extensions project</a> or you can code it by yourself, because is a simple matter of using a TransactionScope object. In the end you will end with tests that do not alter the database. In such a situation I prefer to proceed this way: first of all I configure my database project to deploy to the test database, simply open property of the database project and goes into Deploy tab</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image18.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="307" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb18.png" width="626" border="0" /></a> </p>
<p>Then I go into the test project, goes into Database Folder, locate the DatabaseSetup.cs and comment out the two lines that actually does structure deploy and data generation</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:9e7f0bfe-173b-4577-9c22-c63d4aaf76b9" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">[AssemblyInitialize()]
</span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> IntializeAssembly(TestContext ctx)
{
    </span><span style="color: #008000;">//</span><span style="color: #008000;">Setup the test database based on setting in the
    </span><span style="color: #008000;">//</span><span style="color: #008000;">configuration file
    </span><span style="color: #008000;">//</span><span style="color: #008000;">DatabaseTestClass.TestService.DeployDatabaseProject();
    </span><span style="color: #008000;">//</span><span style="color: #008000;">DatabaseTestClass.TestService.GenerateData();</span><span style="color: #008000;">
</span><span style="color: #000000;">}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Then I open the DataGenerationPlan I want to use and with the menu Data-&gt;DataGeneration Plan-&gt;Execute plan, I execute my plan against the test database.</p>
</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image19.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="154" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb19.png" width="316" border="0" /></a> </p>
<p>Now I’m sure that </p>
<ol>
<li>the database is prepared to be tested</li>
<li>No test will alter the content of the database (thanks to transaction maangement)</li>
</ol>
<p>At this point I setup the build configuration to make a deploy of the DAtabase Project at each build, everything is now prepared for work.</p>
<p>I open the .sql file that contains the stored I want to modify, write some modifications, and then Build+Run Tests. With such a configuration I’m sure that at each build, my modification are propagated to test database, data are already there because I preloaded previously, and each test now run very fast. With this configuration I can really speed up development time avoiding unnecessary preload and structure syncronization.</p>
<p>When all new test passes I run the whole test suite, then remove the comment from the InitializeAssembly and do a check-in.</p>
<p>alk.</p>
<p>Tags: <a href="http://technorati.com/tag/msTest" rel="tag">msTest</a> </p>
<div class="wlWriterEditableSmartContent" id="scid:C16BAC14-9A3D-4c50-9394-FBFEF7A93539:b1ab78d7-6301-4de7-9186-84e149545dd0" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"><a href="http://www.dotnetkicks.com/kick/?url=http://www.nablasoft.com/alkampfer/index.php/2009/06/19/database-test-with-database-edition/"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://www.nablasoft.com/alkampfer/index.php/2009/06/19/database-test-with-database-edition/" border="0" alt="kick it on DotNetKicks.com" /></a></div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=gsmfXY9d4Xg:svWLbnVu5cc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=gsmfXY9d4Xg:svWLbnVu5cc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=gsmfXY9d4Xg:svWLbnVu5cc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=gsmfXY9d4Xg:svWLbnVu5cc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=gsmfXY9d4Xg:svWLbnVu5cc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=gsmfXY9d4Xg:svWLbnVu5cc:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/gsmfXY9d4Xg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/19/database-test-with-database-edition/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/19/database-test-with-database-edition/</feedburner:origLink></item>
		<item>
		<title>Publish a project with ClickOnce via NANT and CC.Net</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/O8nTcBiN2Fc/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/18/publish-a-project-with-clickonce-via-nant-and-ccnet/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 12:47:18 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[.NET framework]]></category>

		<category><![CDATA[Experiences]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/18/publish-a-project-with-clickonce-via-nant-and-ccnet/</guid>
		<description><![CDATA[I have a project that needs to be published automatically through IIS directory, clickonce and CC.net machine. The easiest way to make this happens is to follow these simple instructions.
First of all goes into the machine where the CC.Net runs, prepare the IIS directory where the clickonce generated setup will be copied, open the solution [...]]]></description>
			<content:encoded><![CDATA[<p>I have a project that needs to be published automatically through IIS directory, clickonce and CC.net machine. The easiest way to make this happens is to follow these simple instructions.</p>
<p>First of all goes into the machine where the CC.Net runs, prepare the IIS directory where the clickonce generated setup will be copied, open the solution into visual studio, goes to the project you want to publish and set everything needed for clickonce, set version to 1.0.0.0 and publish through visual studio IDE. This will create the folder structure in IIS and the application is published for the first time with the version number 1.0.0.0. Now take the publish.htm file and copy into the trunk of your project into a specific directory (I used Configuration\ClickOnce), rename it in OriginalPublish.htm, edit it and find the place where visual studio ide wrote the string 1.0.0.0, replace it with the string VERSIONNUMBERTOKEN. </p>
<p>This part is needed because msbuild is able to publish a clickonce enabled application, but it will not create the publish.htm file. Now create a target in nant, and inside it execute MsBuild against your project</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:eb8ed7b0-b365-4573-9124-1cdf39258764" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">exec </span><span style="color: #FF0000;">program</span><span style="color: #0000FF;">="${MSBuild}"</span><span style="color: #FF0000;">
        commandline</span><span style="color: #0000FF;">="${ProjectDir}\Src\MyApp\MyApp.csproj"</span><span style="color: #FF0000;">
      basedir</span><span style="color: #0000FF;">="."</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">

    </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">arg </span><span style="color: #FF0000;">value</span><span style="color: #0000FF;">="/target:publish"</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span><span style="color: #000000;">
    </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">arg </span><span style="color: #FF0000;">value</span><span style="color: #0000FF;">="/p:Configuration=${BuildConfiguration}"</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span><span style="color: #000000;">
    </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">arg </span><span style="color: #FF0000;">value</span><span style="color: #0000FF;">="/property:ApplicationVersion=${assembly.file.version}"</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span><span style="color: #000000;">
    </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">arg </span><span style="color: #FF0000;">value</span><span style="color: #0000FF;">="/property:PublishUrl=http://10.8.0.5:10444/MyApp/"</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span><span style="color: #000000;">
    </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">arg </span><span style="color: #FF0000;">value</span><span style="color: #0000FF;">="/Property:InstallUrl=http://10.8.0.5:10444/MyApp/"</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span><span style="color: #000000;">
</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">exec</span><span style="color: #0000FF;">&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>As you can see I simply delegate to msbuild the task of publishing the application, specifiying the url used to distribute it. This task will create all needed click once files in the bin\debug\app.publish subdirectory of the project. Now you need to create the publis.htm file</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:e9d742eb-f6f9-443d-8ec7-e0508862536a" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">property </span><span style="color: #FF0000;">name</span><span style="color: #0000FF;">="clickOnePublishDir"</span><span style="color: #FF0000;"> value</span><span style="color: #0000FF;">="${ProjectDir}\Src\MyApp\bin\${BuildConfiguration}\app.publish"</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span><span style="color: #000000;">
</span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">ReplaceTokenInFile
    </span><span style="color: #FF0000;">sourcefile</span><span style="color: #0000FF;">="${ConfigurationDir}\ClickOnce\OriginalPublish.htm"</span><span style="color: #FF0000;">
    destfile</span><span style="color: #0000FF;">="${clickOnePublishDir}\publish.htm"</span><span style="color: #FF0000;">
    token</span><span style="color: #0000FF;">="VERSIONNUMBERTOKEN"</span><span style="color: #FF0000;">
    replacetoken</span><span style="color: #0000FF;">="${assembly.file.version}"</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>This task takes the original publish.htm file and replace the token VERSIONNUMBERTOKEN, with the actual version number. The ReplaceTokenInFile task is c# code in nant script</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:0af55f0a-ab49-4b9b-be04-563b9d7d9ac5" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">    </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">script </span><span style="color: #FF0000;">language</span><span style="color: #0000FF;">="C#"</span><span style="color: #FF0000;"> prefix</span><span style="color: #0000FF;">="FileOp"</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">

        </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">references</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
            </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">include </span><span style="color: #FF0000;">name</span><span style="color: #0000FF;">="System.Dll"</span><span style="color: #0000FF;">/&gt;</span><span style="color: #000000;">
        </span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">references</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
        </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">imports</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
            </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">import </span><span style="color: #FF0000;">namespace</span><span style="color: #0000FF;">="NAnt.Core.Types"</span><span style="color: #0000FF;">/&gt;</span><span style="color: #000000;">
        </span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">imports</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">

        </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">code</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
            </span><span style="color: #0000FF;">&lt;![CDATA[</span><span style="color: #808080;">

          [TaskName("ReplaceTokenInFile")]
                public class ReplaceTokenInFile : Task {
                  #region Private Instance Fields

                  private string _sourceFile;
                        private string _destFile;
                        private string _token;
                        private string _replaceToken;
                  #endregion Private Instance Fields

                  #region Public Instance Properties

                  [TaskAttribute("sourcefile", Required=true)]
                  public string SourceFile {
                      get { return _sourceFile; }
                      set { _sourceFile = value; }
                  }

                  [TaskAttribute("destfile", Required=true)]
                  public string DestFile {
                      get { return _destFile; }
                      set { _destFile = value; }
                  }

                        [TaskAttribute("token", Required=true)]
                  public string Token {
                      get { return _token; }
                      set { _token = value; }
                  }

                        [TaskAttribute("replacetoken", Required=true)]
                  public string ReplaceToken {
                      get { return _replaceToken; }
                      set { _replaceToken = value; }
                  }

                  #endregion Public Instance Properties

                  #region Override implementation of Task

                  protected override void ExecuteTask() {
                      String source = System.IO.File.ReadAllText(SourceFile);
                            source = source.Replace(Token, ReplaceToken);
                            System.IO.File.WriteAllText(DestFile, source);
                            String message = "Replace token" + Token + " in file " + SourceFile + " with token " + ReplaceToken + " and saved into " + DestFile;
                             Log(Level.Info, message);
                  }
                  #endregion Override implementation of Task
                }

       </span><span style="color: #0000FF;">]]&gt;</span><span style="color: #000000;">
        </span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">code</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
    </span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">script</span><span style="color: #0000FF;">&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Now you can simply copy all the files into the folder where IIS maps the publishUrl and the game is done.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:245c2c85-c780-4fad-8dd7-565c84566c51" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">copy </span><span style="color: #FF0000;">todir</span><span style="color: #0000FF;">="${ClickOnceDir}"</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
    </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">fileset </span><span style="color: #FF0000;">basedir</span><span style="color: #0000FF;">="${ProjectDir}\Src\MyApp\bin\${BuildConfiguration}\app.publish"</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
        </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">include </span><span style="color: #FF0000;">name</span><span style="color: #0000FF;">="**"</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span><span style="color: #000000;">
    </span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">fileset</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">copy</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">  </span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>The advantage of this approach, is that I can reuse the automatic version numbering I use in my CC.Net machine,&#160; and at each checkin I have an automatically publish of new version of the application that my testers can use. Clearly for a software in production this action must be run manually only with stable and tested builds.</p>
<p>If you do not like deploying at each checkin you can simply schedule this action to run periodically, but the important stuff is that now everything is automatic and you can update clickonce application with a single click.</p>
<p>alk.</p>
<p>Tags: <a href="http://technorati.com/tag/Continuos Integration" rel="tag">Continuos Integration</a> <a href="http://technorati.com/tag/Click Once" rel="tag">Click Once</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=O8nTcBiN2Fc:mRuXfyiTvys:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=O8nTcBiN2Fc:mRuXfyiTvys:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=O8nTcBiN2Fc:mRuXfyiTvys:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=O8nTcBiN2Fc:mRuXfyiTvys:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=O8nTcBiN2Fc:mRuXfyiTvys:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=O8nTcBiN2Fc:mRuXfyiTvys:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/O8nTcBiN2Fc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/18/publish-a-project-with-clickonce-via-nant-and-ccnet/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/18/publish-a-project-with-clickonce-via-nant-and-ccnet/</feedburner:origLink></item>
		<item>
		<title>OpenXml excel and formulas</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/9xjfB277o4Q/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/16/openxml-excel-and-formulas/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 16:10:13 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[Office]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/16/openxml-excel-and-formulas/</guid>
		<description><![CDATA[In an old post, I deal with a simple way to create excel report using openXml format. The trick is a simple manipulation of the document with Linq to Xml. 
Now I need to add another feature, I need to open an excel document with formulas, fill some cells, leaving formulas intact. My first version [...]]]></description>
			<content:encoded><![CDATA[<p>In an <a href="http://www.nablasoft.com/alkampfer/index.php/2008/11/28/create-a-report-in-excel-2007-with-open-xml-sdk-10/">old post</a>, I deal with a simple way to create excel report using openXml format. The trick is a simple manipulation of the document with Linq to Xml. </p>
<p>Now I need to add another feature, I need to open an excel document with formulas, fill some cells, leaving formulas intact. My first version does not work as expected, I simply created an excel with simple formulas, then fire my function and when I open the resulting excel I see all zero on formula column, but the formula is there, and if I change some cell referenced by the formula I’ll obtain the right value.</p>
<p>This problem arise because formula are stored in original sheet with such a xml</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:2d6f34d9-f8cf-46a7-be76-ef6319962782" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">c </span><span style="color: #FF0000;">r</span><span style="color: #0000FF;">="C2"</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
  </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">f </span><span style="color: #FF0000;">t</span><span style="color: #0000FF;">="shared"</span><span style="color: #FF0000;"> ref</span><span style="color: #0000FF;">="C2:C10"</span><span style="color: #FF0000;"> si</span><span style="color: #0000FF;">="0"</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">A2+B2</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">f</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
  </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">v</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">0</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">v</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">c</span><span style="color: #0000FF;">&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>This means that the cell C2 contains the formula A2+B2, but the node &lt;v&gt;0&lt;/v&gt; tells Excel that actual value is Zero. So when you open the resulting excel file, excel found that content of the cell is 0 and shows this value until some related cell changes content. To solve this problem I simply added a bit of code that removes the &lt;v&gt; element.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:ba7855ba-516b-4dbc-aa8f-fd88ee1efdc7" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">originalElement.Descendants(ExcelFiller.ns_s </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">v</span><span style="color: #800000;">"</span><span style="color: #000000;">).Remove();
row.Add(originalElement);</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Now when excel opens elaborated document, it found no &lt;v&gt; (value) element, so it recalculate it based on formula.</p>
<p>alk.</p>
<p>Tags: <a href="http://technorati.com/tag/OpenXml" rel="tag">OpenXml</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=9xjfB277o4Q:12YM6fPRlT4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=9xjfB277o4Q:12YM6fPRlT4:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=9xjfB277o4Q:12YM6fPRlT4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=9xjfB277o4Q:12YM6fPRlT4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=9xjfB277o4Q:12YM6fPRlT4:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=9xjfB277o4Q:12YM6fPRlT4:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/9xjfB277o4Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/16/openxml-excel-and-formulas/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/16/openxml-excel-and-formulas/</feedburner:origLink></item>
		<item>
		<title>Pex to the rescue</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/H1NLJidzCE0/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/16/pex-to-the-rescue/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 13:20:11 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/16/pex-to-the-rescue/</guid>
		<description><![CDATA[Pex is a product from microsoft research that is really useful for those Test Addicted developers. Pex is a White Box Testing tool for .Net, that is able to analyze your code to find every possible point of failure of a method or a class. This morning I had a couple of log from a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://research.microsoft.com/en-us/projects/Pex/">Pex</a> is a product from microsoft research that is really useful for those Test Addicted developers. Pex is a White Box Testing tool for .Net, that is able to analyze your code to find every possible point of failure of a method or a class. This morning I had a couple of log from a server that runs a windows service that makes analysis on some text strings. These analysis where originally composed by some regular expressions, but since the amount of data is really big, I substitute some regexes with specialized routine that speeds up the time needed to finish the work.</p>
<p>Those exceptions I received this morning told me that my unit tests for that class are not so good, even if they cover the 100% of the class code. Before actually trying to review the code to find why it can give an IndexOutOfBoundException I fired Pex on that class.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image13.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="298" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb13.png" width="954" border="0" /></a> </p>
<p>It seems that there are really a lot of paths that makes my routine to fail. If you look at the Text column you see that some of the input strings that makes my routine fails are composed by string termination (\0) inside the string, or are null etc etc. Pex can find those specific input values because it analyzes the code of the Class under test, for this reason it is a tool of “White Box” testing. Another great feature of Pex is the “Suggestions Windows”, since Pex found errors because he really analyze written code he can also give you suggestion on how to avoid a specific error.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image14.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="384" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb14.png" width="596" border="0" /></a> </p>
<p>SElecting the specific error, you can find a suggestion on how to avoid it, in this situation it seems that I completely forgot to test the length of the text to be analyzed. My next step is to add validation of text lenght to avoid those errors. </p>
<p>A real cool feature is the possibility to save one or more failing Pex test as a standard unit test.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image15.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="392" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb15.png" width="695" border="0" /></a> </p>
<p>This will create one test for each one of the selected tests, and you can run those test as standard ones.</p>
<p>After you have modified your class you can run pex again to check if some other error remains. Running Pex analysis took time, Pex have a time limit to avoid running forever, but you can click on appropriate icon to change default values (this needs the creation of a test project that pex will use to store information)</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image16.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="175" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb16.png" width="393" border="0" /></a> </p>
<p>Once the test project is created you can find a test file named in the same way of the class under test with the suffix Test, it is composed of some test methods decorated with Pex specific attributes. </p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:2c279538-403c-4010-a36e-206f74bbbb8e" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">[PexMethod(MaxConstraintSolverTime </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">2</span><span style="color: #000000;">)]
        </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> MultiRange FindHit(
             [PexAssumeUnderTest]WildCardBeginEndKeywordFinder target,
             </span><span style="color: #0000FF;">string</span><span style="color: #000000;"> keyword,
             </span><span style="color: #0000FF;">string</span><span style="color: #000000;"> text
        )
        {
            </span><span style="color: #008000;">//</span><span style="color: #008000;"> TODO: add assertions to method WildCardBeginEndKeywordFinderTest.FindHit(WildCardBeginEndKeywordFinder, String, String)</span><span style="color: #008000;">
</span><span style="color: #000000;">            MultiRange result </span><span style="color: #000000;">=</span><span style="color: #000000;"> target.FindHit(keyword, text);
            </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> result;
        }</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>As you can see I changed the MaxConstraintSolverTime to 2 so Pex can spend more time to analyze my function, now I can simply right click Pex generated class, and select “Run Pex exploration” to explore again the method with this new setting. Now Pex can do a more deep analysis (this does not means that will always find more errors).</p>
<p>Pex is really good to find input pattern that makes your code fail:</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image17.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="108" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb17.png" width="583" border="0" /></a> </p>
<p>I’m sure I never think to pass 1****\0 to my routine :D. After some correction you usually find that inputs that makes your code fail are really strange, and you can tell “Ok, it is enough”, if someone passes “1*****\0” he should really got an exception as result, but in the end Pex is exceptional in finding obvious failing path in your code.</p>
<p>alk.</p>
<p>Tags: <a href="http://technorati.com/tag/Pex" rel="tag">Pex</a> <a href="http://technorati.com/tag/Testing" rel="tag">Testing</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=H1NLJidzCE0:Yc1KOzgm6gE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=H1NLJidzCE0:Yc1KOzgm6gE:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=H1NLJidzCE0:Yc1KOzgm6gE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=H1NLJidzCE0:Yc1KOzgm6gE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=H1NLJidzCE0:Yc1KOzgm6gE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=H1NLJidzCE0:Yc1KOzgm6gE:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/H1NLJidzCE0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/16/pex-to-the-rescue/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/16/pex-to-the-rescue/</feedburner:origLink></item>
		<item>
		<title>Cannot create project in a newly installed TFS</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/qK-EmuTM6lk/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/15/cannot-create-project-in-a-newly-installed-tfs/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 16:27:20 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[.NET framework]]></category>

		<category><![CDATA[Experiences]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/15/cannot-create-project-in-a-newly-installed-tfs/</guid>
		<description><![CDATA[I’ve just installed Tfs For Workgroup in a small virtual machine to make some experiments. After setting up the machine (Windows 2008) I installed TFS SErvice pack 1 then tfs power toys and finally I opened up visual studio in my desktop machine. I simply connect to the team foundation server and tried to create [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve just installed Tfs For Workgroup in a small virtual machine to make some experiments. After setting up the machine (Windows 2008) I installed TFS SErvice pack 1 then tfs power toys and finally I opened up visual studio in my desktop machine. I simply connect to the team foundation server and tried to create a new “Team Project”, inserted some values for my test project and then tried to create the project, but here is the result</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image9.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="487" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb9.png" width="559" border="0" /></a> </p>
<p>Following the link “For More information .. “ you can read detailed log, in the end of the file there is an exception</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image10.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="390" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb10.png" width="1067" border="0" /></a> </p>
</p>
</p>
<p>To avoid being lost in error simply look at the last operation that it tried to do, in this case it was “Creating reports on the Sql Server reporting&quot; Services” and the cause of the exception is “The permission granted to user “TFSALKAMPFER\Alkampfer are insufficient”. To solve this problem install on the server the <a href="http://tfsadmin.codeplex.com/">Team Foundation Server Administration Tool</a></p>
<p>Then you can launch that tool with administrative privileges, connect to the server and verify permissions. Here are permissions on my newly installed server.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image11.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="97" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb11.png" width="865" border="0" /></a> </p>
<p>Uh Oh, it seems that my account does not have any rights on reporting services, and limited access to share point, now you can simply click on Reporting Services area.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image12.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="181" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb12.png" width="395" border="0" /></a> </p>
<p>Since this is a test server and I do not care a lot about security I give to myself full rights, then save changes. Now I’m able to create team projects.</p>
<p>When you work with a complex system like TFS do not forget to analyze detailed log files in case of errors, it can save you a lot of time.</p>
<p>alk.</p>
<p>Tags: <a href="http://technorati.com/tag/Team Foundation Server" rel="tag">Team Foundation Server</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=qK-EmuTM6lk:NhCKZF8Z7D4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=qK-EmuTM6lk:NhCKZF8Z7D4:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=qK-EmuTM6lk:NhCKZF8Z7D4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=qK-EmuTM6lk:NhCKZF8Z7D4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=qK-EmuTM6lk:NhCKZF8Z7D4:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=qK-EmuTM6lk:NhCKZF8Z7D4:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/qK-EmuTM6lk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/15/cannot-create-project-in-a-newly-installed-tfs/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/15/cannot-create-project-in-a-newly-installed-tfs/</feedburner:origLink></item>
		<item>
		<title>Plan for change</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/evyt0CV4E0k/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/15/plan-for-change/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 14:40:11 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[Software Architecture]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/15/plan-for-change/</guid>
		<description><![CDATA[Here is a possible dialog between Customer/PM/Analyst and a programmer
 
Developers usually end with one or more of those thought

Analyst is a moron, he did a bad job not finding the real requirement of the customer
Customer are stupid because they does not know what they want, they are constantly changing requirements.
We lack requirement gathering phase, [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a possible dialog between Customer/PM/Analyst and a programmer</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image7.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="277" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb7.png" width="644" border="0" /></a> </p>
<p>Developers usually end with one or more of those thought</p>
<ol>
<li>Analyst is a moron, he did a bad job not finding the real requirement of the customer</li>
<li>Customer are stupid because they does not know what they want, they are constantly changing requirements.</li>
<li>We lack requirement gathering phase, now we must loose time following desires of Analyst/Customer</li>
</ol>
<p>Finally the programmer complains a lot about too much code to change, and how is painful working in an environment where noone is able to catch the real requirement of the customer.</p>
<p>Situation is much more different if you understand that the needs of the customer quite often change with time, we are in a fast world where moving slowly quite often leads to death, so it is absolutely normal that requirements changes with time. The only solution is <em>Plan in advance for change</em>, if you are ready for changes, you will having really less problem when some requirement changes over time. </p>
<p>Technically speaking, to have a software that can react quickly to change the key concept is <em>loose coupling</em>, through heavy use of Inversion of Control, you can minimize dependencies between the various part of the software. The more the software is loosely copuled, the more you can modify a part without affecting other parts. </p>
<p>Then you need a lot of tests, that can spot immediately when a change in some part of the software has introduced some bug. Then You need to setup a Continuous Integration machine, and make your tests run at each check-in, this assures you that tests are run frequently and automatically. Then you must setup a real good logging infrastructure, to trace immediately what is going wrong with the system. Finally you should work in asynchronous mode when possible, minimizing the coupling between different tiers in the software.</p>
<p>But probably the most difficult step is <em>changing the way we manage software developement. </em>We must change the way we approach the software, not fearing changes and reacting differently to change in requirements.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image8.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="273" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb8.png" width="644" border="0" /></a> </p>
<p>alk.</p>
<p>Tags: <a href="http://technorati.com/tag/Software Architecture" rel="tag">Software Architecture</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=evyt0CV4E0k:fbh81yUW8v4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=evyt0CV4E0k:fbh81yUW8v4:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=evyt0CV4E0k:fbh81yUW8v4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=evyt0CV4E0k:fbh81yUW8v4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=evyt0CV4E0k:fbh81yUW8v4:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=evyt0CV4E0k:fbh81yUW8v4:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/evyt0CV4E0k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/15/plan-for-change/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/15/plan-for-change/</feedburner:origLink></item>
		<item>
		<title>Error: the specified windows sharepoint services site url is not the default site collection site</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/ZAryUlygRHc/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/12/error-the-specified-windows-sharepoint-services-site-url-is-not-the-default-site-collection-site/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 21:50:30 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[Experiences]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/12/error-the-specified-windows-sharepoint-services-site-url-is-not-the-default-site-collection-site/</guid>
		<description><![CDATA[I’m installing Tfs 2008 on a Virtual machine. Following the guide I saw that I need first to install Share Point Services 3.0 SP2 before installing team foundation server. You can find those part in the guide with the title “How to: Install SharePoint Products and Technologies on Windows Server”.
I followed all the instruction, but [...]]]></description>
			<content:encoded><![CDATA[<p>I’m installing Tfs 2008 on a Virtual machine. Following the guide I saw that I need first to install Share Point Services 3.0 SP2 before installing team foundation server. You can find those part in the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=FF12844F-398C-4FE9-8B0D-9E84181D9923&amp;displaylang=en">guide</a> with the title “How to: Install SharePoint Products and Technologies on Windows Server”.</p>
<p>I followed all the instruction, but when team foundation server installer asked me the address of sharepoint site I tried some url but I got the infamous error</p>
<blockquote><p>the specified windows sharepoint services site url is not the default site collection site</p>
</blockquote>
<p>The missing part in the guide is that after step 19 you need to create a site collection. First of all verify that you are able to browse the root site you have created in step 18</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image4.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="356" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb4.png" width="778" border="0" /></a> </p>
<p>Ok now verify that you can browse the site collection at site <a title="http://tfsalkampfer/sites/base/default.aspx" href="http://tfsalkampfer/sites/base/default.aspx">http://tfsalkampfer/sites/base/default.aspx</a> where tfsalkampfer is the name of the machine, probably you get a 404 error, so goes to the administration pane of sharepoint services</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image5.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="333" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb5.png" width="999" border="0" /></a> </p>
</p>
<p>You need to click “application management” and then “Create site collection”. Now you should see the page to create another site collection</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image6.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="396" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb6.png" width="758" border="0" /></a> </p>
<p>Please be sure that you are working on the Web application you have created for Tfs, then simply use the /sites/ option in the combo and specify whathever name you want for the web site address, i’ve chosen “Base”. Now press ok and verify that the site collection is ok browsing <a title="http://tfsalkampfer/sites/base/default.aspx" href="http://tfsalkampfer/sites/base/default.aspx">http://tfsalkampfer/sites/base/default.aspx</a>, now you can set the value <a href="http://tfsalkampfer/sites/">http://tfsalkampfer/sites/</a> as share point site during Tfs installation, and now everything went ok.</p>
<p>alk.</p>
<p>Tags: <a href="http://technorati.com/tag/Team Foundation Server" rel="tag">Team Foundation Server</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=ZAryUlygRHc:mas81JTboIo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=ZAryUlygRHc:mas81JTboIo:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=ZAryUlygRHc:mas81JTboIo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=ZAryUlygRHc:mas81JTboIo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=ZAryUlygRHc:mas81JTboIo:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=ZAryUlygRHc:mas81JTboIo:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/ZAryUlygRHc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/12/error-the-specified-windows-sharepoint-services-site-url-is-not-the-default-site-collection-site/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/12/error-the-specified-windows-sharepoint-services-site-url-is-not-the-default-site-collection-site/</feedburner:origLink></item>
		<item>
		<title>Do not forget Array</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/H3SrqaRiuzc/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/11/do-not-forget-array/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 13:01:15 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[.NET framework]]></category>

		<category><![CDATA[Experiences]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/11/do-not-forget-array/</guid>
		<description><![CDATA[I wrote a stupid util that does this operation: it scans a folder with 500.000 + files (in various subfolder), all files have name that contains an integer that is an id of a row in a database. I need to find orphan files, so I simply take file name, es: myfile_1002.txt, extracts the number [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote a stupid util that does this operation: it scans a folder with 500.000 + files (in various subfolder), all files have name that contains an integer that is an id of a row in a database. I need to find orphan files, so I simply take file name, es: myfile_1002.txt, extracts the number 1002 and then verify if in a specific table of the database there is a row with index 1002.</p>
<p>To avoid poor performance I eager load all valid ids in memory (each id is an In32 (4 bytes) and I have 100k of them, so I’m keeping in memory 100k * 4 bytes 400kbytes of RAM). Now I load all these id in a List&lt;Int32&gt;, then iterate into all files of a directory, for each file parse the name and verify that the List contains the id. To analyze 200k files the whole routine took 10.200 milliseconds. It is quite speedy, but if you profile it you can verify that most of the time was spent into checking that an id is contained in the list.</p>
<p>This is because search operations in List&lt;T&gt; are slow, a search is basically a scan of the whole list until you find the element or you find the end of the list. We are so used with List&lt;T&gt; that I saw a lot of developers completely forget the old Array class. Let’s see how we can speed up the lookup with the old Array class.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:bc8ad18b-b83b-4f14-ab83-fc1093920e1a" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #008000;">//</span><span style="color: #008000;">Load all id in ascending order into ValidLink List&lt;Int32&gt;</span><span style="color: #008000;">
</span><span style="color: #000000;">Int32[] links;
links </span><span style="color: #000000;">=</span><span style="color: #000000;"> ValidLink.ToArray();</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>I’ve simply change the query to the database, asking for id in ascending order, then I populate the list as usual, and finally creates a simple Array of Int32 with the function ToArray(). now you can use <a href="http://en.wikipedia.org/wiki/Binary_search">BinarySearch</a></p>
<p><div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:8644e947-e995-4eec-aca7-1dba77fc41de" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">if</span><span style="color: #000000;"> (Array.BinarySearch</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">Int32</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">(links, id) </span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">)</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
<p>A lot of people forget that the <a href="http://msdn.microsoft.com/en-us/library/system.array.binarysearch.aspx">Array class natively supports Binary search</a> for ordered array, when I ran the sample again execution time was dropped to 2.392 seconds, and now most of the time is spent reading Disk structure.</p>
<p>Pay attention to the data structure you use <img src='http://www.nablasoft.com/alkampfer/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Alk.</p>
<div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:103b1229-41ee-45eb-9bd6-3395bbfb9761" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/.Net+Framework" rel="tag">.Net Framework</a>,<a href="http://technorati.com/tags/Performance" rel="tag">Performance</a></div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=H3SrqaRiuzc:-7RvBmuvY2M:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=H3SrqaRiuzc:-7RvBmuvY2M:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=H3SrqaRiuzc:-7RvBmuvY2M:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=H3SrqaRiuzc:-7RvBmuvY2M:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=H3SrqaRiuzc:-7RvBmuvY2M:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=H3SrqaRiuzc:-7RvBmuvY2M:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/H3SrqaRiuzc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/11/do-not-forget-array/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/11/do-not-forget-array/</feedburner:origLink></item>
		<item>
		<title>Twitter Blue screen :D</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/STX3ligzcM0/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/11/twitter-blue-screen-d/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 10:43:08 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/11/twitter-blue-screen-d/</guid>
		<description><![CDATA[I’ve just twittered about a blue screen, and after some minutes I see from twitterfox that I have a reply message…here it is
 
Amazing :D, WindowsDeath answered me, I’m impressed hahahahaha
alk.
]]></description>
			<content:encoded><![CDATA[<p>I’ve just twittered about a blue screen, and after some minutes I see from twitterfox that I have a reply message…here it is</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image3.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="171" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb3.png" width="315" border="0" /></a> </p>
<p>Amazing :D, WindowsDeath answered me, I’m impressed hahahahaha</p>
<p>alk.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=STX3ligzcM0:HwSr99gWQxU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=STX3ligzcM0:HwSr99gWQxU:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=STX3ligzcM0:HwSr99gWQxU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=STX3ligzcM0:HwSr99gWQxU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=STX3ligzcM0:HwSr99gWQxU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=STX3ligzcM0:HwSr99gWQxU:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/STX3ligzcM0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/11/twitter-blue-screen-d/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/11/twitter-blue-screen-d/</feedburner:origLink></item>
		<item>
		<title>Fluent Syntax for Assertion in msTest</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/LolF17zgxBY/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/10/fluent-syntax-for-assertion-in-mstest/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 17:25:16 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/10/fluent-syntax-for-assertion-in-mstest/</guid>
		<description><![CDATA[Switching from Nunit to MsTest is quite simple, but the first thing I really miss with mstest was the lack of a fluent assertion syntax. Consider the assertion you must write if you want to check that a number is lesser than 100 or greater than 200

[TestMethod]
public void BaseAssertFluentWithSyntaxHelperLtOrGtRo()
{
    Int32 obj = [...]]]></description>
			<content:encoded><![CDATA[<p>Switching from <a href="http://www.nunit.org">Nunit</a> to <a href="http://en.wikipedia.org/wiki/MSTest">MsTest</a> is quite simple, but the first thing I really miss with mstest was the lack of a fluent assertion syntax. Consider the assertion you must write if you want to check that a number is lesser than 100 or greater than 200</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:d9478751-95b2-4bc7-af3e-74132a50465b" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">[TestMethod]
</span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> BaseAssertFluentWithSyntaxHelperLtOrGtRo()
{
    Int32 obj </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">400</span><span style="color: #000000;">;
    Assert.IsTrue(obj </span><span style="color: #000000;">&lt;</span><span style="color: #000000;"> </span><span style="color: #800080;">100</span><span style="color: #000000;"> </span><span style="color: #000000;">||</span><span style="color: #000000;"> obj </span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> </span><span style="color: #800080;">200</span><span style="color: #000000;">);
}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>It is quite clear, but with fluent syntax you can write test like this</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:8f237802-06b3-4f15-949f-758ec03993e6" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">[TestMethod]
</span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> BaseAssertFluentWithSyntaxHelperLtOrGtR()
{
    Int32 obj </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">400</span><span style="color: #000000;">;
    FluentAssert.That(obj, Is.LesserThan(</span><span style="color: #800080;">100</span><span style="color: #000000;">).Or.GreaterThan(</span><span style="color: #800080;">200</span><span style="color: #000000;">));
}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>I find it really clearer than the first form. The advantage of a fluent syntax is that you can read the assertion as if were English text. I’m actually writing an helper assembly to support fluent syntax with msTest, if someone is interested in I can publish in source form. For now I’m able to support basic syntax with operator precedence and parenthesis</p>
<p>&#160;</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:228b8659-8e1a-4156-a3f6-90e61c98f379" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">[TestMethod]
</span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> TestBasic2()
{
    IConstraint c </span><span style="color: #000000;">=</span><span style="color: #000000;"> Is.LesserThan(</span><span style="color: #800080;">100</span><span style="color: #000000;">) </span><span style="color: #000000;">|</span><span style="color: #000000;"> Is.GreaterThan(</span><span style="color: #800080;">200</span><span style="color: #000000;">) </span><span style="color: #000000;">&amp;</span><span style="color: #000000;"> Is.GreaterThan(</span><span style="color: #800080;">300</span><span style="color: #000000;">);
    Assert.IsTrue(c.Validate(</span><span style="color: #800080;">99</span><span style="color: #000000;">));
}

[TestMethod]
</span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> TestBasicParenthesis()
{
    IConstraint c </span><span style="color: #000000;">=</span><span style="color: #000000;"> (Is.LesserThan(</span><span style="color: #800080;">100</span><span style="color: #000000;">) </span><span style="color: #000000;">|</span><span style="color: #000000;"> Is.GreaterThan(</span><span style="color: #800080;">200</span><span style="color: #000000;">)) </span><span style="color: #000000;">&amp;</span><span style="color: #000000;"> Is.GreaterThan(</span><span style="color: #800080;">300</span><span style="color: #000000;">);
    Assert.IsFalse(c.Validate(</span><span style="color: #800080;">99</span><span style="color: #000000;">));
}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>As you can see the first test pass because the And operator ( expressed by &amp; because you cannot overload &amp;&amp;) has higher precedence over the or operator. The second test pass because you can alter precedence with parenthesis. </p>
<p>Alk.</p>
<div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f9efa7f3-f5af-48d0-b85f-cf984f9e5574" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/Unit+Testing" rel="tag">Unit Testing</a>,<a href="http://technorati.com/tags/MsTest" rel="tag">MsTest</a></div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=LolF17zgxBY:g0uVubNVWsA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=LolF17zgxBY:g0uVubNVWsA:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=LolF17zgxBY:g0uVubNVWsA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=LolF17zgxBY:g0uVubNVWsA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=LolF17zgxBY:g0uVubNVWsA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=LolF17zgxBY:g0uVubNVWsA:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/LolF17zgxBY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/10/fluent-syntax-for-assertion-in-mstest/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/10/fluent-syntax-for-assertion-in-mstest/</feedburner:origLink></item>
		<item>
		<title>Test and Context</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/8e62Z5VlwrQ/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/10/test-and-context/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 08:23:43 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/10/test-and-context/</guid>
		<description><![CDATA[For a Unit Test the most important concept, and probably the most difficult to manage is the concept of Fixture. Quite often part of the Fixture is composed by an external File. In a little project that I use as example for jQuery I have a really simple class that parses an XML file to [...]]]></description>
			<content:encoded><![CDATA[<p>For a Unit Test the most important concept, and probably the most difficult to manage is the concept of <a href="http://xunitpatterns.com/test%20fixture%20-%20xUnit.html">Fixture</a>. Quite often part of the Fixture is composed by an external File. In a little project that I use as example for jQuery I have a really simple class that parses an XML file to create a menu for Asp.Net MVC enabled site.</p>
<p>In such a situation the fixture of the test is using different source files to test the class with different input. In a classic NUNIT unit testing you can solve this problem including the file in the project with “Copy if newer”. With such a setting Visual Studio at each build check if the file is changed, and eventually copies the file into the appropriate directory (bin/debug/pathofthefile in standard debug configuration)</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image1.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="209" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb1.png" width="221" border="0" /></a> </p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image2.png"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="120" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb2.png" width="381" border="0" /></a> </p>
<p>This approach is good, but has some problems, if you simply change the XML file, and rebuild the project, the file gets no copied in the output directory . This happens because Visual Studio correctly checks that no source file was changed, so it has no need to recompile. Another stuff I do not like is that I need to find the file <em>with the pat</em><em>h I used to insert it into the test project</em>.</p>
</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:deb73764-52f3-42d8-b0e0-a41b847220e5" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">[Test]
</span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> GrabMenuWithActionUrl()
{
 MasterLogic sut </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> MasterLogic(</span><span style="color: #0000FF;">new</span><span style="color: #000000;"> MyTestUrlHelper());
 List</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">MenuItem</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> menu </span><span style="color: #000000;">=</span><span style="color: #000000;"> sut.CreateMenu(</span><span style="color: #800000;">"</span><span style="color: #800000;">SampleFiles\\MenuType1.Xml</span><span style="color: #800000;">"</span><span style="color: #000000;">).MenuItems;
 Assert.That(menu, Has.Count.EqualTo(</span><span style="color: #800080;">2</span><span style="color: #000000;">));
 Assert.That(menu[</span><span style="color: #800080;">1</span><span style="color: #000000;">].MenuItems[</span><span style="color: #800080;">0</span><span style="color: #000000;">], Has.Property(</span><span style="color: #800000;">"</span><span style="color: #800000;">Url</span><span style="color: #800000;">"</span><span style="color: #000000;">).EqualTo(</span><span style="color: #800000;">"</span><span style="color: #800000;">/Photo/ManageAlbum</span><span style="color: #800000;">"</span><span style="color: #000000;">));
}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>The same test can be written in msTest, but this time I have the DeploymentItem attribute, that can be used to specfy to mstest engine, that my test really need the file “SampleFiles\MenuType1.xml”. </p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:a9b6ea07-af50-4e9f-bb9e-1f8bf8d25ec3" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">[TestMethod()]
[DeploymentItem(</span><span style="color: #800000;">@"</span><span style="color: #800000;">.\SampleFiles\BaseMenu1.xml</span><span style="color: #800000;">"</span><span style="color: #000000;">)]
</span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> CreateMenuTest()
{
    PrivateObject param0 </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> PrivateObject(</span><span style="color: #0000FF;">new</span><span style="color: #000000;"> MasterLogic(</span><span style="color: #0000FF;">new</span><span style="color: #000000;"> MyTestUrlHelper()));
    MasterLogic_Accessor target </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> MasterLogic_Accessor(param0);
    </span><span style="color: #0000FF;">string</span><span style="color: #000000;"> menuFileName </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">@"</span><span style="color: #800000;">BaseMenu1.xml</span><span style="color: #800000;">"</span><span style="color: #000000;">;
    MenuItem expected </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> MenuItem(</span><span style="color: #800000;">"</span><span style="color: #800000;">TEST</span><span style="color: #800000;">"</span><span style="color: #000000;">);
    target.CreateMenu(menuFileName);
    Assert.AreEqual(expected.Text, </span><span style="color: #800000;">"</span><span style="color: #800000;">TEST</span><span style="color: #800000;">"</span><span style="color: #000000;">);
}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>This is a cleaner way to express the fixture, thanks to the DeploymentItem attribute it is clear that the test needs the file SampleFiles\BaseMenu.xml, and most important, the file was copied automatically before each test runs and it is located in the same dir of the test assembly, so i can simply refer to it with the BaseMenu1.xml name without any path.</p>
<p>alk.</p>
<p><div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:5db5523b-2653-473a-97de-be5886adcd0f" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/msTest" rel="tag">msTest</a>,<a href="http://technorati.com/tags/Unit+Testing" rel="tag">Unit Testing</a></div></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=8e62Z5VlwrQ:9-4NF98rTBg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=8e62Z5VlwrQ:9-4NF98rTBg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=8e62Z5VlwrQ:9-4NF98rTBg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=8e62Z5VlwrQ:9-4NF98rTBg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=8e62Z5VlwrQ:9-4NF98rTBg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=8e62Z5VlwrQ:9-4NF98rTBg:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/8e62Z5VlwrQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/10/test-and-context/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/10/test-and-context/</feedburner:origLink></item>
		<item>
		<title>Minimize test complexity</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/gMMPahOAMdg/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/09/minimize-test-complexity/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 12:46:34 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/09/minimize-test-complexity/</guid>
		<description><![CDATA[I have a function that does these steps
1) it accepts a string parameter let it call P   2) Manipulate that parameter P, transforming in P1 with an algorithm that is contained in a specific class    3) uses P1 it to ask for database instance of some classes and does a [...]]]></description>
			<content:encoded><![CDATA[<p>I have a function that does these steps</p>
<p>1) it accepts a string parameter let it call P   <br />2) Manipulate that parameter P, transforming in P1 with an algorithm that is contained in a specific class    <br />3) uses P1 it to ask for database instance of some classes and does a lot of manipulations and database operations</p>
<p>Now I want only to test that the class calls the algorithm to transform P in P1. All other functions of that sut are already verified, I first begun with a skeleton test I used previously to test the sut, this skeleton makes heavy use of Mocks and stubs objects to FULLY simulate the database. </p>
<p>In the end I have a test that works, but it was too complex, mainly because it is full of stub expectation. Moreover it is Fragile, because if I’ll change the way how this test interact with the DB, I’ll need also to change expectations. So I changed the test in this way.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:450115ed-07d9-4d4b-9366-80ba13e20099" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">[Test]
</span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> VerifyThatBlaBla()
{
    IParamTransformer pt </span><span style="color: #000000;">=</span><span style="color: #000000;"> MockRepository.GenerateStub</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">IParamTransformer</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">();
    </span><span style="color: #0000FF;">try</span><span style="color: #000000;">
    {
        </span><span style="color: #0000FF;">using</span><span style="color: #000000;"> (IoC.Override(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(IParamTransformer), pt))
        {
            MySut sut </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> MySut();
            sut.PerformStuff(</span><span style="color: #800000;">"</span><span style="color: #800000;">MyParameter</span><span style="color: #800000;">"</span><span style="color: #000000;">);
        }
    }
    </span><span style="color: #0000FF;">catch</span><span style="color: #000000;"> (System.Data.Common.DbException)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;">Ignore everything.</span><span style="color: #008000;">
</span><span style="color: #000000;">    }
    pd.AssertWasCalled(obj </span><span style="color: #000000;">=&gt;</span><span style="color: #000000;"> obj.TransformParam(Arg</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">String</span><span style="color: #000000;">&gt;</span><span style="color: #000000;">.Is.Equal(</span><span style="color: #800000;">"</span><span style="color: #800000;">MyParameter</span><span style="color: #800000;">"</span><span style="color: #000000;">));

}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>MySut is the class I need to test, it internally calls IoC.Resolve&lt;IParamTransformer&gt;(), to take a parameter transformer. Thanks to <a href="http://ayende.com/Blog/archive/2008/05/16/Rhino-Mocks--Arrange-Act-Assert-Syntax.aspx">AAA syntax of Rhino Mocks</a> I simply create a mock, use an internal override function to instruct the IoC component to return my mock when asked to resolve a IParamTransformer, then invoke sut method. Since I know that the test calls the DAL with transformed parameter I simply ask in the test to catch every DbException, ignore it and then assert that the TransformParam is called. The test is quick because I used SqlLite to have a Db in memory, the sut resolve the IParamTransformer, calls for parameter transformation, then calls the db; the db call failed because the test db is empty so a DbException is thrown. Now the exception is ignored and I finally verify that function TransformParam was called.</p>
<p>This test is less than half length respect to the first version that fully mimics the DAL with mock objects. I think that it is really clearer, because it is focused on “what I want to test” without distracting the reader with greedy details.</p>
<p>A still better solution could be a refactoring of the original class, making it more testable, but I think that this is enough.</p>
<p>Alk.</p>
<div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:0fcb7373-073e-4778-b63c-f5819a820299" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati Tags: <a href="http://technorati.com/tags/Unit+Testing" rel="tag">Unit Testing</a></div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=gMMPahOAMdg:TSUSf-mVNJ8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=gMMPahOAMdg:TSUSf-mVNJ8:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=gMMPahOAMdg:TSUSf-mVNJ8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=gMMPahOAMdg:TSUSf-mVNJ8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=gMMPahOAMdg:TSUSf-mVNJ8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=gMMPahOAMdg:TSUSf-mVNJ8:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/gMMPahOAMdg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/09/minimize-test-complexity/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/09/minimize-test-complexity/</feedburner:origLink></item>
		<item>
		<title>Programmatically run a Data Generation Plan</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/M6wdVs_KZ2o/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/01/programmatically-run-a-data-generation-plan/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 16:53:12 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/01/programmatically-run-a-data-generation-plan/</guid>
		<description><![CDATA[I’m quite surprised, I was simply looking for a way to run a Data Generation Plan (.dgen) file in Visual Studio Team Edition, but it seems to me that the class that does this have some internal methods. When You generate the first database test Visual Studio ask you all information to run schema sync [...]]]></description>
			<content:encoded><![CDATA[<p>I’m quite surprised, I was simply looking for a way to run a Data Generation Plan (.dgen) file in Visual Studio Team Edition, but it seems to me that the class that does this have some internal methods. When You generate the first database test Visual Studio ask you all information to run schema sync and data generation, if you look at generated code you can see this code.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:d44d35b4-8dc1-4b86-804b-386e3d5c8bb9" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">[AssemblyInitialize()]
</span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> IntializeAssembly(TestContext ctx)
{
    </span><span style="color: #008000;">//</span><span style="color: #008000;">Setup the test database based on setting in the configuration file</span><span style="color: #008000;">
</span><span style="color: #000000;">    DatabaseTestClass.TestService.DeployDatabaseProject();
    DatabaseTestClass.TestService.GenerateData();
}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>This is run first of every code in the test project, but I really have the need to run different data generation plan in different part of my code. If you look at the DatabaseTestClass with reflector you can be really surprised, it has a TestService class that is of type DatabaseTestService.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="256" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/06/image-thumb.png" width="584" border="0" /></a> </p>
<p>As you can see it has a GenerateData method that permits you to specify dgen file name, <em>but it is protected. </em>I really wonder why, but it seems that you cannot run database generation file programmatically…or not? </p>
<p>Here is the solution</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:640ba921-ce75-4ba9-b9e5-abc5465bb9e2" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> RunDataGenerationPlan(
    String path,
    String projectFile,
    String dataGenerationFile,
    </span><span style="color: #0000FF;">bool</span><span style="color: #000000;"> clearDatabase, </span><span style="color: #0000FF;">string</span><span style="color: #000000;"> providerInvariantName, </span><span style="color: #0000FF;">string</span><span style="color: #000000;"> connectionString)
{
    FileInfo project </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> FileInfo(Path.Combine(path, projectFile));
    FileInfo generation </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> FileInfo(Path.Combine(path, dataGenerationFile));

    Microsoft.Build.BuildEngine.Engine engine </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Engine(ToolsetDefinitionLocations.Registry);
    engine.DefaultToolsVersion </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">3.5</span><span style="color: #800000;">"</span><span style="color: #000000;">;
    Project msBuildProject </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Project(engine);

    msBuildProject.Load(project.FullName);
    BuildPropertyGroup group </span><span style="color: #000000;">=</span><span style="color: #000000;"> msBuildProject.AddNewPropertyGroup(</span><span style="color: #0000FF;">false</span><span style="color: #000000;">);
    group.AddNewProperty(</span><span style="color: #800000;">"</span><span style="color: #800000;">ConnectionString</span><span style="color: #800000;">"</span><span style="color: #000000;">, connectionString);

    group.AddNewProperty(</span><span style="color: #800000;">"</span><span style="color: #800000;">SourceFile</span><span style="color: #800000;">"</span><span style="color: #000000;">, generation.FullName);

    group.AddNewProperty(</span><span style="color: #800000;">"</span><span style="color: #800000;">PurgeTablesBeforePopulate</span><span style="color: #800000;">"</span><span style="color: #000000;">, clearDatabase.ToString());
    group.AddNewProperty(</span><span style="color: #800000;">"</span><span style="color: #800000;">Verbose</span><span style="color: #800000;">"</span><span style="color: #000000;">, </span><span style="color: #800000;">"</span><span style="color: #800000;">True</span><span style="color: #800000;">"</span><span style="color: #000000;">);

    </span><span style="color: #008000;">//</span><span style="color: #008000;">FileLogger logger = new FileLogger();
    </span><span style="color: #008000;">//</span><span style="color: #008000;">logger.Parameters = @"logfile=D:\temp\build.log";
    </span><span style="color: #008000;">//</span><span style="color: #008000;">engine.RegisterLogger(logger);</span><span style="color: #008000;">
</span><span style="color: #000000;">    </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (</span><span style="color: #000000;">!</span><span style="color: #000000;">engine.BuildProject(msBuildProject, </span><span style="color: #800000;">"</span><span style="color: #800000;">DataGeneration</span><span style="color: #800000;">"</span><span style="color: #000000;">))
    {
        </span><span style="color: #0000FF;">throw</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> AssertFailedException(</span><span style="color: #800000;">"</span><span style="color: #800000;">Cannot Generate Data plan</span><span style="color: #800000;">"</span><span style="color: #000000;">);
    }

}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
<p>The solution is really simple, it is true that I have no way to invoke that protected method (Except reflection), but msbuild can be invoked programmatically, so I create an Engine class, load the main project file, then set some properties for the project such as ConnectionString, Verbose etc. With properties&#160; you can specify the<strong> “SourceFile”</strong> that is the data generation file that you want to run. I’ve found a sample <a href="http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/5e750da2-24a0-4e4e-8eae-761f56c27b2c">here</a> that explain the xml syntax for msbuild, so I simply translate it into C# code using the Engine of msbuild directly from code. You need to imports Microsoft.Build.Engine to make this code compile. Now I can use that function in this way.</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:47cc061d-9896-4fd2-93d0-b7bbfa29b461" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">[TestMethod]
</span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> TestMethod1()
{
    DatabaseTestServiceHelper.RunDataGenerationPlan(
        </span><span style="color: #800000;">@"</span><span style="color: #800000;">..\..\..\NorthWindDatabase\</span><span style="color: #800000;">"</span><span style="color: #000000;">,
        </span><span style="color: #800000;">@"</span><span style="color: #800000;">NorthWindDatabase.dbproj</span><span style="color: #800000;">"</span><span style="color: #000000;">,
        </span><span style="color: #800000;">@"</span><span style="color: #800000;">Data Generation Plans\GenerationA.dgen</span><span style="color: #800000;">"</span><span style="color: #000000;">,
        </span><span style="color: #0000FF;">true</span><span style="color: #000000;">,
        </span><span style="color: #800000;">"</span><span style="color: #800000;">System.Data.SqlClient</span><span style="color: #800000;">"</span><span style="color: #000000;">,
        </span><span style="color: #800000;">@"</span><span style="color: #800000;">Data Source=localhost\sql2008;Initial Catalog=NorthWindForUnitTesting;Integrated Security=True;Pooling=False</span><span style="color: #800000;">"</span><span style="color: #000000;">);
}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>And I can decide programmatically when to run a specific data generation plan. The code to regenerate the whole structure is not important, it is enough for me to run at the beginning of test. The only thing I do not like is the need to use relative path to references project file and data generation plan file, but since it is uncommon to change relative path of the projects, I’m quite satisfied of it.</p>
<p>&#160;</p>
<p>Alk.</p>
<p>Tags: <a href="http://technorati.com/tag/data generation plan" rel="tag">data generation plan</a> <a href="http://technorati.com/tag/visual studio" rel="tag">visual studio</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=M6wdVs_KZ2o:Lm9U5eiHS5U:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=M6wdVs_KZ2o:Lm9U5eiHS5U:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=M6wdVs_KZ2o:Lm9U5eiHS5U:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=M6wdVs_KZ2o:Lm9U5eiHS5U:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=M6wdVs_KZ2o:Lm9U5eiHS5U:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=M6wdVs_KZ2o:Lm9U5eiHS5U:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/M6wdVs_KZ2o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/01/programmatically-run-a-data-generation-plan/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/01/programmatically-run-a-data-generation-plan/</feedburner:origLink></item>
		<item>
		<title>Compress your CSS files in asp.net with YUICompressor and an Handler</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/7hjLktHUo0Q/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/06/01/compress-your-css-files-in-aspnet-with-yuicompressor-and-an-handler/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 10:08:58 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/06/01/compress-your-css-files-in-aspnet-with-yuicompressor-and-an-handler/</guid>
		<description><![CDATA[Some times ago I spoke about using YUICompressor to reduce number and size of your css files. That solution was based on the original msbuild action included in youicompressor library. That solution has a major drawback, css files gets compressed only during the deploy phase, so during testing the site was tested only with the [...]]]></description>
			<content:encoded><![CDATA[<p>Some times ago <a href="http://www.nablasoft.com/alkampfer/index.php/2009/01/24/optimization-of-javascript-and-css-files/">I spoke</a> about using <a href="http://www.codeplex.com/YUICompressor">YUICompressor</a> to reduce number and size of your css files. That solution was based on the original msbuild action included in youicompressor library. That solution has a major drawback, css files gets compressed only during the deploy phase, so during testing the site was tested only with the original css set. I like to test in an environment similar to production one, so I decided to develop a simple IHttpHandler to handle css compression. </p>
<p>Moreover asp.net has a not so good handling of themes, and all css that are in theme folder are included in final pages (if I compress files into 1 with youicompressor I’ll end with a lot of 404 request), I want to insert only a single css in the theme. Here is the solution, place in theme folder a single css files and include all original css files with include directive</p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:f93ad116-0d4c-4336-b3ae-60205bb3aaa8" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #800000;">@import url("../../ThemesCss/v2/BackOffice.css");
@import url("../../ThemesCss/v2/CollapsiblePanel.css");
@import url("../../ThemesCss/v2/control.css");
@import url("../../ThemesCss/v2/EMailEditor.css");</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>Now create a folder in the root named ThemesCss and put all your css there. Now everything works ok, but you have no compression and you still suffer from too many css in the site, but now you have only a css file included in the theme.</p>
<p>Now I created another file, with the same name of the single theme css file, but with extension .FileList, inside it I put all path of the css files that are used in the site.</p>
<p><div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:14b7af1c-750f-45ea-9391-7a2513e8d973" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #800000;">~/ThemesCss/v2/BackOffice.css
~/ThemesCss/v2/CollapsiblePanel.css
~/ThemesCss/v2/control.css
~/ThemesCss/v2/EMailEditor.css</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
<p>It is a simple text file, but now I’m able to write an handler that use this file list to compress all site. </p>
<div class="wlWriterEditableSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:b6730d0e-258e-4bdb-9ae2-2581367753e2" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;"><span style="color: #000000;">    </span><span style="color: #0000FF;">class</span><span style="color: #000000;"> YUICompressorHandler : IHttpHandler
    {
        </span><span style="color: #0000FF;">#region</span><span style="color: #000000;"> IHttpHandler Members</span><span style="color: #000000;">

        </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">bool</span><span style="color: #000000;"> IsReusable
        {
            </span><span style="color: #0000FF;">get</span><span style="color: #000000;"> { </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> </span><span style="color: #0000FF;">true</span><span style="color: #000000;">; }
        }

        </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> ProcessRequest(HttpContext context)
        {

            </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (context.Request.FilePath.EndsWith(</span><span style="color: #800000;">"</span><span style="color: #800000;">.css</span><span style="color: #800000;">"</span><span style="color: #000000;">))
            {
                String path </span><span style="color: #000000;">=</span><span style="color: #000000;"> context.Server.MapPath(context.Request.FilePath);
                String compressedFileName </span><span style="color: #000000;">=</span><span style="color: #000000;"> Path.ChangeExtension(path, </span><span style="color: #800000;">"</span><span style="color: #800000;">.csscompressed</span><span style="color: #800000;">"</span><span style="color: #000000;">);
                String cssListFileName </span><span style="color: #000000;">=</span><span style="color: #000000;"> Path.ChangeExtension(path, </span><span style="color: #800000;">"</span><span style="color: #800000;">.FileList</span><span style="color: #800000;">"</span><span style="color: #000000;">);

                </span><span style="color: #008000;">//</span><span style="color: #008000;">Check if some source file was changed.</span><span style="color: #008000;">
</span><span style="color: #000000;">                </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (File.Exists(compressedFileName))
                {
                    DateTime csscompressedDate </span><span style="color: #000000;">=</span><span style="color: #000000;"> File.GetLastWriteTime(compressedFileName);
                    </span><span style="color: #0000FF;">foreach</span><span style="color: #000000;"> (String cssfile </span><span style="color: #0000FF;">in</span><span style="color: #000000;"> File.ReadAllLines(cssListFileName))
                    {
                        String realCssFile </span><span style="color: #000000;">=</span><span style="color: #000000;"> context.Server.MapPath(cssfile);
                        </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (File.GetLastWriteTime(realCssFile) </span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> csscompressedDate)
                        {
                            File.Delete(compressedFileName);
                        }
                    }
                }

                </span><span style="color: #008000;">//</span><span style="color: #008000;">if not in debug mode activate caching. in debug mode we does not want cache.</span><span style="color: #008000;">
</span><span style="color: #000000;">                </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (</span><span style="color: #000000;">!</span><span style="color: #000000;">context.IsDebuggingEnabled)
                {
                    </span><span style="color: #008000;">//</span><span style="color: #008000;">We are in release with debug="true" check for request cache</span><span style="color: #008000;">
</span><span style="color: #000000;">                    </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (File.Exists(compressedFileName))
                    {
                        </span><span style="color: #0000FF;">string</span><span style="color: #000000;"> ifModifiedSince </span><span style="color: #000000;">=</span><span style="color: #000000;"> context.Request.Headers[</span><span style="color: #800000;">"</span><span style="color: #800000;">If-Modified-Since</span><span style="color: #800000;">"</span><span style="color: #000000;">];
                        DateTime modifiedSince;
                        </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (</span><span style="color: #000000;">!</span><span style="color: #0000FF;">string</span><span style="color: #000000;">.IsNullOrEmpty(ifModifiedSince) </span><span style="color: #000000;">&amp;&amp;</span><span style="color: #000000;"> ifModifiedSince.Length </span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;"> </span><span style="color: #000000;">&amp;&amp;</span><span style="color: #000000;"> DateTime.TryParse(ifModifiedSince, </span><span style="color: #0000FF;">out</span><span style="color: #000000;"> modifiedSince))
                        {
                            DateTime fileDate </span><span style="color: #000000;">=</span><span style="color: #000000;"> File.GetLastWriteTime(compressedFileName);
                            TimeSpan difference </span><span style="color: #000000;">=</span><span style="color: #000000;"> fileDate </span><span style="color: #000000;">-</span><span style="color: #000000;"> modifiedSince;
                            </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (difference.TotalSeconds </span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">)
                            {
                                </span><span style="color: #008000;">//</span><span style="color: #008000;">Data is cachable.</span><span style="color: #008000;">
</span><span style="color: #000000;">                                context.Response.StatusCode </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">304</span><span style="color: #000000;">;
                                context.Response.StatusDescription </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">Not Modified</span><span style="color: #800000;">"</span><span style="color: #000000;">;
                                context.Response.AddHeader(</span><span style="color: #800000;">"</span><span style="color: #800000;">Content-Length</span><span style="color: #800000;">"</span><span style="color: #000000;">, </span><span style="color: #800000;">"</span><span style="color: #800000;">0</span><span style="color: #800000;">"</span><span style="color: #000000;">);
                                </span><span style="color: #0000FF;">return</span><span style="color: #000000;">;
                            }
                        }
                    }
                    </span><span style="color: #008000;">//</span><span style="color: #008000;">If we reach here the caller does not specified If-Modified-Since, tells client that this is cacheable</span><span style="color: #008000;">
</span><span style="color: #000000;">                    context.Response.Cache.SetCacheability(HttpCacheability.Public);
                    context.Response.Cache.SetLastModified(File.GetLastWriteTime(compressedFileName));
                    context.Response.Cache.VaryByHeaders[</span><span style="color: #800000;">"</span><span style="color: #800000;">If-Modified-Since</span><span style="color: #800000;">"</span><span style="color: #000000;">] </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">true</span><span style="color: #000000;">;
                }
                </span><span style="color: #008000;">//</span><span style="color: #008000;">If we reach here we must stream the file, if is not present recreate.</span><span style="color: #008000;">
</span><span style="color: #000000;">                </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (</span><span style="color: #000000;">!</span><span style="color: #000000;">File.Exists(compressedFileName))
                {
                    CompressCssFile(context, compressedFileName, cssListFileName);
                }
                context.Response.ContentType </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"</span><span style="color: #800000;">text/css</span><span style="color: #800000;">"</span><span style="color: #000000;">;
                context.Response.TransmitFile(compressedFileName);
            }
        }

        </span><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> CompressCssFile(HttpContext context, </span><span style="color: #0000FF;">string</span><span style="color: #000000;"> compressedFileName, </span><span style="color: #0000FF;">string</span><span style="color: #000000;"> cssListFileName)
        {
            StringBuilder sb </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> StringBuilder();
            String[] lines </span><span style="color: #000000;">=</span><span style="color: #000000;"> File.ReadAllLines(cssListFileName);
            </span><span style="color: #0000FF;">foreach</span><span style="color: #000000;"> (</span><span style="color: #0000FF;">string</span><span style="color: #000000;"> cssFile </span><span style="color: #0000FF;">in</span><span style="color: #000000;"> lines)
            {
                </span><span style="color: #008000;">//</span><span style="color: #008000;">Each line of the file is a relative path to real file name</span><span style="color: #008000;">
</span><span style="color: #000000;">                sb.AppendLine(File.ReadAllText(context.Server.MapPath(cssFile)));
            }
            File.WriteAllText(compressedFileName,
                              CssCompressor.Compress(sb.ToString(), </span><span style="color: #800080;">80</span><span style="color: #000000;">, CssCompressionType.StockYuiCompressor));
        }

        </span><span style="color: #0000FF;">#endregion</span><span style="color: #000000;">
    }</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>This is the very first version of the handler, it basically compress all original files into one, it checks if the previously compressed file is out-of-date because one of the original css is changed. If nothing is changed it returns the compressed file to the caller. It has even a simple check, if the site has debug=”false” and is in release mode, I honor cache of the browser, using appropriate headers.</p>
<p>It works really well, now even in test site deployed by CC.net I can have compression and I can enable/disable simply from the IIS control panel, if I send css request to asp.net engine I’ll have compression, if I do not map css extension to asp.net I have standard IIS behaviour.</p>
<p>In a site I’m working in I moved from 25 css files and 45Kb of uncompressed css, to a 1 css and a 28k of uncompressed css, that became 5.5k when gzipped.</p>
<p>alk.</p>
<p>Tags: <a href="http://technorati.com/tag/asp.net" rel="tag">asp.net</a> <a href="http://technorati.com/tag/css compression" rel="tag">css compression</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=7hjLktHUo0Q:NizBvMG_GlY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=7hjLktHUo0Q:NizBvMG_GlY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=7hjLktHUo0Q:NizBvMG_GlY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=7hjLktHUo0Q:NizBvMG_GlY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=7hjLktHUo0Q:NizBvMG_GlY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=7hjLktHUo0Q:NizBvMG_GlY:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/7hjLktHUo0Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/06/01/compress-your-css-files-in-aspnet-with-yuicompressor-and-an-handler/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/06/01/compress-your-css-files-in-aspnet-with-yuicompressor-and-an-handler/</feedburner:origLink></item>
		<item>
		<title>Going in production as often as you can</title>
		<link>http://feedproxy.google.com/~r/AlkampferEng/~3/4R-g6d8TzDQ/</link>
		<comments>http://www.nablasoft.com/alkampfer/index.php/2009/05/29/going-in-production-as-often-as-you-can/#comments</comments>
		<pubDate>Fri, 29 May 2009 09:22:16 +0000</pubDate>
		<dc:creator>alkampfer</dc:creator>
		
		<category><![CDATA[Experiences]]></category>

		<guid isPermaLink="false">http://www.nablasoft.com/alkampfer/index.php/2009/05/29/going-in-production-as-often-as-you-can/</guid>
		<description><![CDATA[I really care the concept of “going in production”, because it is the moment when the software bring to life. Going in production can be sometimes a really difficult thing to do, and there are a lot of reasons behind it.
First of all we have the syndrome of “It works on my machine”. The software [...]]]></description>
			<content:encoded><![CDATA[<p>I really care the concept of “<a href="http://www.nablasoft.com/alkampfer/index.php/2009/05/09/good-programmers-put-code-in-production/">going in production</a>”, because it is the moment when the software bring to life. Going in production can be sometimes a really difficult thing to do, and there are a lot of reasons behind it.</p>
<p>First of all we have the syndrome of “<strong>It works on my machine</strong>”. The software run perfectly in developer’s machines, but when you move in production servers or into customers machines nothing work. If you ask developer, quite always you get this answer: “HAve You installed library XYZ? Then have you wrote into the registry the SuperSecretKey XYXCWKDSAF, after you done this you should run for a mile, turn yourself for three time with fingers on your nose, …..” This is the sign that you need at least a <strong>document that explain how to deploy software, </strong>or you’re gonna kill your developers</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/05/image8.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="196" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/05/image-thumb8.png" width="135" border="0" /></a> </p>
<p>Then the software begin to work with real customer data, and you can see with horror that everything worked ok with test data, but when you import 10KK orders from the old system of your customer, the software stops working. But other problems can arise, maybe the customer works with order with negative amount and the software does not permits so. In the end, you find that test data were not representative, and now you are in trouble with a live system that is not capable to handle the data that the customer really needs. (you’ll end with unsatisfied customer)</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/05/image9.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="204" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/05/image-thumb9.png" width="198" border="0" /></a> </p>
<p>Maybe the software begin to crash, when you see the log it happens that users insert “Hello Folks!” where the software expects a DateTime&#8230;Ok, it is not so simple, but it often happens that real user uses the software in a way we never thought that was possible, and this pattern lead to a crash.</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/05/image10.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="199" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/05/image-thumb10.png" width="191" border="0" /></a> </p>
<p>You have your system in production, users begin to send feedback, after some time you have a new version ready, but… you now have to update database, update client machines, make sure that older version can work with the new data. Another typical problem is that you cannot stop production server, but you need to make changes online. </p>
<p>Customer Calls you telling “The system crashed”, if you ask more detail maybe you get “The System crash when we are working on it”, please do not expect customer to be technical skilled, he can never tells you real details of the error, if you want to laugh just ask to the customer “Can you send me the stack trace?”, the answer can range from “WHAT??” to “Hey does not bother me with technical terms, the system chrased, NOW YOU’LL FIX IT”. Then you can only go into production server and then you need to understand why, when, what part of the system crashed…. it sounds you need real careful logging system. Maybe you log everything in a file, but…. you have no access to production server because in the customer web farm, so you need to contact the IT manager, tell him you need log, typical answer is “in witch machine are those log…… this lead to pain and frustration</p>
<p><a href="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/05/image11.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="174" alt="image" src="http://www.nablasoft.com/alkampfer/wp-content/uploads/2009/05/image-thumb11.png" width="211" border="0" /></a> </p>
<p>I can continue but the real concept is that a system in production can generate an high number of problems that does not arise during developement stage. So what is the solution? It turns out that it can be as simple as the sentence </p>
<blockquote><p>“Go in production as often as you can”. </p>
</blockquote>
<p>I only gives you a little scenario. Set up a CC.net or similar integration machine, create a test production server, at each check in the integration machine compiles code , runs tests and if everything is ok, it deploys the software in the test machine, let it be called <strong>preproduction machine</strong> . Fill this machine with real data, and <strong>make it available to the customer</strong>. Now you immediately faces all the problems of a system live in production, because <strong>you are actually developing against a software in production</strong>, where you virtually go in production at each checkin <img src='http://www.nablasoft.com/alkampfer/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<ol>
<li>You are forced to create deploy script that automates the task of deploying the software</li>
<li>You are forced to maintain data of the customer in the preproduction machine, so you need to find a way to manage software updates.</li>
<li>You immediately works with real data and real user, moreover you immediately have feedback on the software</li>
<li>Since software is in development stage, bug arises, and you need a quick way to correct them, so you will setup a good error handling system such as <a href="http://www.raboof.com/projects/Elmah/">elmah</a>, or maybe you can setup a log system that email or send all data to a bug tracking system where developer will automatically see details about the error, without the need to go into the production machine. </li>
</ol>
<p>This means that you begin to <strong>face immediately typical problems of a live software, and you do not postpone solving them when you really are in production. </strong>Solving a problem when you are really in production, can be really a pain, so you better work hard to make all possible problem arising during developement stage. Time spent to immediately start developing with a production environment can be difficult, but in the long run it really saves your life.</p>
<p>Alk.</p>
<p>Tags: <a href="http://technorati.com/tag/Production" rel="tag">Production</a> <a href="http://technorati.com/tag/" rel="tag"></a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=4R-g6d8TzDQ:XoEyn2zoBIE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=4R-g6d8TzDQ:XoEyn2zoBIE:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=4R-g6d8TzDQ:XoEyn2zoBIE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?i=4R-g6d8TzDQ:XoEyn2zoBIE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=4R-g6d8TzDQ:XoEyn2zoBIE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/AlkampferEng?a=4R-g6d8TzDQ:XoEyn2zoBIE:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/AlkampferEng?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/AlkampferEng/~4/4R-g6d8TzDQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.nablasoft.com/alkampfer/index.php/2009/05/29/going-in-production-as-often-as-you-can/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.nablasoft.com/alkampfer/index.php/2009/05/29/going-in-production-as-often-as-you-can/</feedburner:origLink></item>
	</channel>
</rss>
