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

<channel>
	<title>IProgrammable &#187; MSBuild</title>
	<atom:link href="http://www.iprogrammable.com/category/msbuild/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.iprogrammable.com</link>
	<description>Kawalerowicz Consulting News</description>
	<lastBuildDate>Wed, 15 Feb 2012 13:21:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Visual Studio 2010 Professional and Hudson / Jenkins CI and FxCop</title>
		<link>http://www.iprogrammable.com/2011/06/15/visual-studio-2010-professional-and-hudson-jenkins-ci-and-fxcop/</link>
		<comments>http://www.iprogrammable.com/2011/06/15/visual-studio-2010-professional-and-hudson-jenkins-ci-and-fxcop/#comments</comments>
		<pubDate>Wed, 15 Jun 2011 09:03:35 +0000</pubDate>
		<dc:creator>marcin.kawalerowicz</dc:creator>
				<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[DotNet]]></category>
		<category><![CDATA[MSBuild]]></category>

		<guid isPermaLink="false">http://www.iprogrammable.com/2011/06/15/visual-studio-2010-professional-and-hudson-jenkins-ci-and-fxcop/</guid>
		<description><![CDATA[&#160; Visual Studio 2010 Premium and Ultimate do have the code analysis feature build in. What this feature does is static code analysis of your source code (or IL to be specific). Unfortunately the Professional edition lacks the build in integration (no Analysis tab in the project properties). Here is a way to easily integrate [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;</p>
<p>Visual Studio 2010 Premium and Ultimate do have the code analysis feature build in. What this feature does is static code analysis of your source code (or IL to be specific). Unfortunately the Professional edition lacks the build in integration (no Analysis tab in the project properties). Here is a way to easily integrate Visual Studio 2010 Professional with FxCop. FxCop is a standalone Code Analysis version that comes together with “Microsoft Windows SDK for Windows 7 and .NET Framework 4 Version 7.1”. Actually if you download and install the SDK you will get the FxCop installer in %ProgramFiles%\Microsoft SDKs\Windows\v7.1\Bin\FXCop. You will have to install it from there (yeah installer in a installer <img src='http://www.iprogrammable.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>Here is how to built it into Visual Studio 2010 and into continuous integration process. First of all, I like to have all the assets in my repository. So I went and copied all the FxCop files into the tools/FxCop directory into the repository. I didn’t wanted to use the FxCop project files (they add unnecessary friction with editing the file – sometimes on runtime). I decided to go the command line way all the way. The easiest solution is to define all the rules you want to obey in the ruleset file. Ruleset file is a XML file that looks like this:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;?</span><span style="color: #800000">xml</span> <span style="color: #ff0000">version</span><span style="color: #0000ff">=&quot;1.0&quot;</span> <span style="color: #ff0000">encoding</span><span style="color: #0000ff">=&quot;utf-8&quot;</span>?<span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">RuleSet</span> <span style="color: #ff0000">Name</span><span style="color: #0000ff">=&quot;Codefusion Rules&quot;</span> <span style="color: #ff0000">Description</span><span style="color: #0000ff">=&quot;This is the Codefusion rule set.&quot;</span> <span style="color: #ff0000">ToolsVersion</span><span style="color: #0000ff">=&quot;10.0&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">Localization</span> <span style="color: #ff0000">ResourceAssembly</span><span style="color: #0000ff">=&quot;Microsoft.VisualStudio.CodeAnalysis.RuleSets.Strings.dll&quot;</span> <span style="color: #ff0000">ResourceBaseName</span><span style="color: #0000ff">=&quot;Microsoft.VisualStudio.CodeAnalysis.RuleSets.Strings.Localized&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">Name</span> <span style="color: #ff0000">Resource</span><span style="color: #0000ff">=&quot;ExtendedDesignGuidelineRules_Name&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">Description</span> <span style="color: #ff0000">Resource</span><span style="color: #0000ff">=&quot;ExtendedDesignGuidelineRules_Description&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">Localization</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">IncludeAll</span> <span style="color: #ff0000">Action</span><span style="color: #0000ff">=&quot;Error&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">Rules</span> <span style="color: #ff0000">AnalyzerId</span><span style="color: #0000ff">=&quot;Microsoft.Analyzers.ManagedCodeAnalysis&quot;</span> <span style="color: #ff0000">RuleNamespace</span><span style="color: #0000ff">=&quot;Microsoft.Rules.Managed&quot;</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>     <span style="color: #0000ff">&lt;</span><span style="color: #800000">Rule</span> <span style="color: #ff0000">Id</span><span style="color: #0000ff">=&quot;CA1000&quot;</span> <span style="color: #ff0000">Action</span><span style="color: #0000ff">=&quot;Warining&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">Rules</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">RuleSet</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>The example above states that all the rules (IncludeAll) are threated as errors with one exception being a Warning (&lt;Rule Id=…). You can define the rules as you wish. Fortunately Visual Studio 2010 Professional has the build in editor for the ruleset files. Using this editor you can easily choose the rules to obey (or not).</p>
<p><a href="http://www.iprogrammable.com/files/2011/06/image.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.iprogrammable.com/files/2011/06/image_thumb.png" width="400" height="164" /></a></p>
<p>When you are done with the ruleset place it somewhere in your repository and define post build event like this one:</p>
<p><a href="http://www.iprogrammable.com/files/2011/06/image1.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.iprogrammable.com/files/2011/06/image_thumb1.png" width="244" height="166" /></a></p>
<p>The text for the post build event is:</p>
<p><font size="2" face="Courier New">if $(ConfigurationName) == Release $(SolutionDir)Codefusion.Common\Tools\FxCop\FxCopCmd.exe /file:$(SolutionDir)S000.Basic\bin\$(ConfigurationName)\Codefusion.S000.Basic.dll /ruleset:=$(SolutionDir)Codefusion.Common\FxCopRules\CodefusionRules.ruleset /rulesetdirectory:$(SolutionDir)Codefusion.Common\Tools\FxCop\Rules /console</font></p>
<p>This way if you compile the project in Release mode you will get all the rules defined in ruleset file checked. You will see the violations in the Error List area. You can still jump to the line where violation occurs by double-clicking the line with report.</p>
<p>You can always suppress the messages for the rules you chosen to obey if in this particular case they don’t make sense. You can do it globally in the GlobalSuppressions.cs file. Like that:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(<span style="color: #006080">&quot;Microsoft.Naming&quot;</span>, <span style="color: #006080">&quot;CA1704:IdentifiersShouldBeSpelledCorrectly&quot;</span>, MessageId = <span style="color: #006080">&quot;Codefusion&quot;</span>)]</pre>
<p><!--CRLF--></div>
</div>
<p>Or directly in the code like that:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> [System.Diagnostics.CodeAnalysis.SuppressMessage(<span style="color: #006080">&quot;Microsoft.Performance&quot;</span>, <span style="color: #006080">&quot;CA1820:TestForEmptyStringsUsingStringLength&quot;</span>)]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> MakeMD5Hash(<span style="color: #0000ff">this</span> <span style="color: #0000ff">string</span> <span style="color: #0000ff">value</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     <span style="color: #0000ff">if</span> (<span style="color: #0000ff">value</span> == <span style="color: #0000ff">null</span>)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>     {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>         <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentNullException(<span style="color: #006080">&quot;value&quot;</span>);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>     }</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>     <span style="color: #0000ff">else</span> <span style="color: #0000ff">if</span> (<span style="color: #0000ff">value</span> == <span style="color: #0000ff">string</span>.Empty)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>     {</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>         <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> ArgumentException(Resources.BasicStrings.ErrorMsgValueCannotBeEmpty + <span style="color: #006080">&quot;.&quot;</span>, <span style="color: #006080">&quot;value&quot;</span>);</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>     }</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span> ...</pre>
<p><!--CRLF--></div>
</div>
<p>To make the suppressions work (suppressions are inline or global exceptions from the ruleset) you will have to define the compiler directive like that:</p>
<p><a href="http://www.iprogrammable.com/files/2011/06/image2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.iprogrammable.com/files/2011/06/image_thumb2.png" width="244" height="63" /></a></p>
<p>It will define a constant in the project file:</p>
<p>&lt;DefineConstants&gt;CODE_ANALYSIS&lt;/DefineConstants&gt;</p>
<p>If you are using the continuous integration technique you can put the command similar to the one in post build event into the build project. In MSBuild it will look like this:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #0000ff">&lt;</span><span style="color: #800000">Target</span> <span style="color: #ff0000">Name</span><span style="color: #0000ff">=&quot;Analysis&quot;</span> <span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span>   <span style="color: #0000ff">&lt;</span><span style="color: #800000">Exec</span> <span style="color: #ff0000">Command</span><span style="color: #0000ff">=&quot;$(MSBuildProjectDirectory)\Codefusion.Common\Tools\FxCop\FxCopCmd.exe /file:S000.Basic\bin\$(Configuration)\Codefusion.S000.Basic.dll /ruleset:=Codefusion.Common\FxCopRules\CodefusionRules.ruleset /rulesetdirectory:Codefusion.Common\Tools\FxCop\Rules /out:FxCopReport.xml /forceoutput&quot;</span> <span style="color: #ff0000">ContinueOnError</span><span style="color: #0000ff">=&quot;false&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #0000ff">&lt;/</span><span style="color: #800000">Target</span><span style="color: #0000ff">&gt;</span></pre>
<p><!--CRLF--></div>
</div>
<p>This way you will get get the XML file with the violations report that your CI server can interpret and thanks to the ContinueOnError=”false” attribute you will get the broken build if any of the violations will be found. </p>
<p>In Hudson/Jenkins you can use the Violations plug-in (you will have to install it) to show the violations in the build report. To do so you need to to configure the project like this:</p>
<p><a href="http://www.iprogrammable.com/files/2011/06/image3.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.iprogrammable.com/files/2011/06/image_thumb3.png" width="244" height="107" /></a></p>
<p>Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iprogrammable.com/2011/06/15/visual-studio-2010-professional-and-hudson-jenkins-ci-and-fxcop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing MSBuild Custom Task</title>
		<link>http://www.iprogrammable.com/2008/03/13/writing-msbuild-custom-task/</link>
		<comments>http://www.iprogrammable.com/2008/03/13/writing-msbuild-custom-task/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 18:16:49 +0000</pubDate>
		<dc:creator>marcin.kawalerowicz</dc:creator>
				<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[MSBuild]]></category>

		<guid isPermaLink="false">http://www.iprogrammable.com/2008_03_13/writing-msbuild-custom-task/</guid>
		<description><![CDATA[Scenario: we have Subversion server to manage our source code and a build server (CruiseControl.NET) to manage our deployment. We have decided to automatically set the SVN revision number to our assembly version. [assembly: System.Reflection.AssemblyVersion("1.2.3.0")] [assembly: System.Reflection.AssemblyFileVersion("1.2.3.0")] So we will replace the last 0 with the current Subversion revision number. How to do this? One [...]]]></description>
			<content:encoded><![CDATA[<p>Scenario: we have Subversion server to manage our source code and a build server (CruiseControl.NET) to manage our deployment. We have decided to automatically set the SVN revision number to our assembly version.</p>
<pre><span style="background: #f8f8f8 none repeat scroll 0% 50%">[</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">assembly</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">: </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">System</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Reflection</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">AssemblyVersion</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">(</span><span style="background: #ffffe6 none repeat scroll 0% 50%">"1.2.3.0"</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">)]
[</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">assembly</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">: </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">System</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Reflection</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">AssemblyFileVersion</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">(</span><span style="background: #ffffe6 none repeat scroll 0% 50%">"1.2.3.0"</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">)]</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>So we will replace the last 0 with the current Subversion revision number. How to do this? One way to achieve this is to modify the AssemblyInfo.cs and read the modified number from that exists. The file modification is easy with MSBuild Community Task FileUpdate</p>
<pre><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">&lt;</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a31515">FileUpdate </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: red">Files</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">=</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">"</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">Cic.P001001PropertiesAssemblyInfo.cs</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">"
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: red">Regex</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">=</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">"</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">(d+).(d+).(d+).(d+)</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">"
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: red">ReplacementText</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">=</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">"</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">$1.$2.$3.$(RevisionNumber)</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">" </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">/&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>But how to read it back? Well there is no easy way. I have written a custom MSBuidl task to achieve this like this:</p>
<pre><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">&lt;</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a31515">AssemblyInfoReader </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: red">Path</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">=</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">"</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">PropertiesAssemblyInfo.cs</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">"
                    </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: red">Property</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">=</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">"</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">AssemblyVersion</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">"</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">&gt;
    &lt;</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a31515">Output </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: red">TaskParameter</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">=</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">"</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">Value</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">" </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: red">ItemName</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">=</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">"</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">ApplicationVersion</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">" </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">/&gt;
&lt;/</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a31515">AssemblyInfoReader</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a><br />
Writing a custom MSBuild task is fairly easy. You have to Reference Microsoft.Build.Framework and Microsoft.Build.Utilities and implement Microsoft.Build.Framework.ITask. Just like this:</p>
<pre><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">namespace </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Cic</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">MsBuildTasks
</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{
    </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">public class </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">AssemblyInfoReader </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">: </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Microsoft</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Build</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Framework</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">ITask
    </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{
        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">#region </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">Private Varaibels

        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">private string </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">path</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">;
        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">private string </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">property</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">;
        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">private string </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">value</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">;

        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">#endregion

        #region </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">Fields
        [</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Microsoft</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Build</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Framework</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">Required</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">]
        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">public string </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Path
        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">get </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{ </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">return </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">path</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">; }
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">set </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{ </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">path </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">= </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">value</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">; }
        }

        [</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Microsoft</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Build</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Framework</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">Required</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">]
        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">public string </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Property
        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">get </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{ </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">return </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">property</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">; }
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">set </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{ </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">property </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">= </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">value</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">; }
        }

        [</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Microsoft</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Build</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Framework</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">Output</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">]
        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">public string </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Value
        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">get </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{ </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">return this</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">value</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">; }
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">set </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{ </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">this</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">value </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">= </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">value</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">; }
        }

        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">#endregion

        #region </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">ITask Members
        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">private </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Microsoft</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Build</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Framework</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">IBuildEngine </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">engine</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">;
        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Microsoft</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Build</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Framework</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">IBuildEngine
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Microsoft</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Build</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Framework</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">ITask</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">BuildEngine
        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">get
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{
                </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">return </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">engine</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">;
            }
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">set
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{
                </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">engine </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">= </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">value</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">;
            }
        }

        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">bool </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Microsoft</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Build</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Framework</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">ITask</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Execute</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">()
        {
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">string </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">message</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">;
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">value </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">= </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">string</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Empty</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">;
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">try
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{
                </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">value </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">= </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">MyReadAssemblyInfoProperty</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">();
                </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">message </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">= </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">string</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Format</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">(
                    </span><span style="background: #ffffe6 none repeat scroll 0% 50%">"AssemblyInfo property {0} read. Property value {1}"</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">,
                    </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">property</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">, </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">value</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">);
            }
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">catch </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">(</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">System</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">Exception </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">e</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">)
            {
                </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">message </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">= </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">string</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Format</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">(
                    </span><span style="background: #ffffe6 none repeat scroll 0% 50%">"Error reading AssemblyInfo property {0}. Error: {1}"</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">,
                    </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">property</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">, </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">e</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Message</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">);
            }

            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Microsoft</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Build</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Framework</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">BuildMessageEventArgs </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">args </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">=
                </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">new </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Microsoft</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Build</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Framework</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">BuildMessageEventArgs</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">(
                </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">message</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">, </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">string</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Empty</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">, </span><span style="background: #ffffe6 none repeat scroll 0% 50%">"AssemblyInfoReaderTask"</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">,
                </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Microsoft</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Build</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Framework</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">MessageImportance</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Normal</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">);
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">engine</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">LogMessageEvent</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">(</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">args</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">);

            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">return true</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">;
        }

        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">private </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Microsoft</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Build</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Framework</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">ITaskHost </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">host</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">;
        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Microsoft</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Build</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Framework</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">ITaskHost </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Microsoft</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Build</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Framework</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">ITask</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">HostObject
        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">get
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{
                </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">return </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">host</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">;
            }
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">set
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{
                </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">host </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">= </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">value</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">;
            }
        }

        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">#endregion

        #region </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">Internals
        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">private string </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">MyReadAssemblyInfoProperty</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">()
        {
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">string </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">propertyValue</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">;

            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: green">// Eraly return
            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">if </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">(!</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">System</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">IO</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">File</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Exists</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">(</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">path</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">)) </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">return </span><span style="background: #ffffe6 none repeat scroll 0% 50%">""</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">;

            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">foreach </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">(</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">string </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">line </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">in </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">System</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">IO</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: #a65300">File</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">ReadAllLines</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">(</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">path</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">))
            {
                </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">if </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">(</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">line</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Contains</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">(</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">property</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">))
                {
                    </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">try
                    </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{
                        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">propertyValue </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">= </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">line</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Remove</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">(</span><span style="background: #e6ffff none repeat scroll 0% 50%">0</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">, </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">line</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">IndexOf</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">(</span><span style="background: #ffffe6 none repeat scroll 0% 50%">'"'</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">) + </span><span style="background: #e6ffff none repeat scroll 0% 50%">1</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">);
                        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">propertyValue </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">= </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">propertyValue</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Remove</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">(
                            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">propertyValue</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">LastIndexOf</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">(</span><span style="background: #ffffe6 none repeat scroll 0% 50%">'"'</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">),
                            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">propertyValue</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Length </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">- </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">propertyValue</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">LastIndexOf</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">(</span><span style="background: #ffffe6 none repeat scroll 0% 50%">'"'</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">));
                        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: green">// return matching property value
                        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">return </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">propertyValue</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">;
                    }
                    </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">catch
                    </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">{
                        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: green">// Ignore errors
                    </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">}
                }
            }

            </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: navy">return string</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">.</span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: maroon">Empty</span><span style="background: #f8f8f8 none repeat scroll 0% 50%">;
        }
        </span><span style="background: #f8f8f8 none repeat scroll 0% 50%;color: blue">#endregion
    </span><span style="background: #f8f8f8 none repeat scroll 0% 50%">}
}
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a><br />
<a href="http://11011.net/software/vspaste"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iprogrammable.com/2008/03/13/writing-msbuild-custom-task/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Developing Vista Sidebar Gadget with Script#</title>
		<link>http://www.iprogrammable.com/2008/01/19/developing-vista-sidebar-gadget/</link>
		<comments>http://www.iprogrammable.com/2008/01/19/developing-vista-sidebar-gadget/#comments</comments>
		<pubDate>Sat, 19 Jan 2008 13:08:37 +0000</pubDate>
		<dc:creator>marcin.kawalerowicz</dc:creator>
				<category><![CDATA[MSBuild]]></category>
		<category><![CDATA[Vista Sidebar Gadget]]></category>

		<guid isPermaLink="false">http://www.iprogrammable.com/2008_01_19/developing-vista-sidebar-gadget/</guid>
		<description><![CDATA[C# to JavaScript compiler? What? Jea! I thought the same way. It&#8217;s amazing what smart people can invent. My men is Nikhil Kothari with his Script#. What do I need the C# to JavaScript compiler for, you ask. Is IL not enough? Well think of enriching your ASP.NET web sites with JavaScript written in C#. [...]]]></description>
			<content:encoded><![CDATA[<p>C# to JavaScript compiler? What? Jea! I thought the same way. It&#8217;s amazing what smart people can invent. My men is <a href="http://www.nikhilk.net/">Nikhil Kothari</a> with his Script#. What do I need the C# to JavaScript compiler for, you ask. Is IL not enough? Well think of enriching your ASP.NET web sites with JavaScript written in C#. Or using Ajax with scripts written in Visual Studio with Intelisense and refactoring. Or developing the Vista Sidebar Gadgets without writing a single line of code in Javascript!</p>
<p><a href="http://www.iprogrammable.com/files/2008/01/image4.png"><img src="http://www.iprogrammable.com/files/2008/01/image-thumb4.png" style="border: 0px none" alt="Leasing Calculator" align="right" border="0" height="162" width="162" /></a> I instantly lookd at the third possibility. since I have Vista on board I was thinking about writing my own Sidebar Gadget (you know the little programs written in HTML an JavaScript, sticked to the right side of your screen). Of course I wonted it to by at least useful <img src='http://www.iprogrammable.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  I thought about writing a small Leasing Calculator. I had my leasing mathematics library ready, but it was written in C#. I didn&#8217;t feel like rewriting it in JavaScript &#8211; what for? So Script# was a blast for me. I had my Leasing Calculator gadget in view hours.</p>
<p>What do you need to start working with Script#:</p>
<p>1. download the latest binaries from <a href="http://www.nikhilk.net/Project.ScriptSharp.aspx">Script# project page</a></p>
<p>2. install it</p>
<p>3. create new <em>Visual C# -&gt; Script# -&gt; Sidebar Gadget</em> project in Visual Studio</p>
<p>You will get quite useful project template. The inside of Content folder is your gadget. If you compile everything Script# will transform your C# into JavaScript and place it in this folder. The last thing you have to do is to copy this folder into your Vista Gadgets folder (<em>C:\Users\user\AppData\Local\Microsoft\Windows Sidebar\Gadgets\</em>). You will have to do the same every time you will compile. Surely it is something to automate. The easiest way is to use the Post-build event in your project and a small MSBuild script that will copy the needed files to the place they should by.</p>
<p><a href="http://www.iprogrammable.com/files/2008/01/image5.png"><img src="http://www.iprogrammable.com/files/2008/01/image-thumb5.png" style="border: 0px none" alt="VS2005 post build event" border="0" height="396" width="542" /></a></p>
<p>$(WinDir)\Microsoft.NET\Framework\v2.0.50727\msbuild.exe $(SolutionDir)build.msbuild</p>
<p>And use this script:</p>
<pre><span style="color: blue">&lt;</span><span style="color: #a31515">Project </span><span style="color: red">DefaultTargets</span><span style="color: blue">=</span>"<span style="color: blue">Deploy</span>" <span style="color: red">xmlns</span><span style="color: blue">=</span>"<span style="color: blue">http://schemas.microsoft.com/developer/msbuild/2003</span>"<span style="color: blue">&gt;
  &lt;</span><span style="color: #a31515">PropertyGroup</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">DeploymentFolder</span><span style="color: blue">&gt;</span>YourVistaGadgetFolder.gadget<span style="color: blue">&lt;/</span><span style="color: #a31515">DeploymentFolder</span><span style="color: blue">&gt;
  &lt;/</span><span style="color: #a31515">PropertyGroup</span><span style="color: blue">&gt;
  &lt;</span><span style="color: #a31515">ItemGroup</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">DeploymentSourceFiles </span><span style="color: red">Include</span><span style="color: blue">=</span>"<span style="color: blue">LeasingCalculatorContent***.*</span>" <span style="color: blue">/&gt;
  &lt;/</span><span style="color: #a31515">ItemGroup</span><span style="color: blue">&gt;
   &lt;</span><span style="color: #a31515">Target </span><span style="color: red">Name</span><span style="color: blue">=</span>"<span style="color: blue">Deploy</span>"<span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">RemoveDir </span><span style="color: red">Directories</span><span style="color: blue">=</span>"<span style="color: blue">$(DeploymentFolder)</span>" <span style="color: red">ContinueOnError</span><span style="color: blue">=</span>"<span style="color: blue">false</span>"<span style="color: blue">&gt;&lt;/</span><span style="color: #a31515">RemoveDir</span><span style="color: blue">&gt;
    &lt;</span><span style="color: #a31515">Copy </span><span style="color: red">SourceFiles</span><span style="color: blue">=</span>"<span style="color: blue">@(DeploymentSourceFiles)</span>"
      <span style="color: red">DestinationFiles</span><span style="color: blue">=</span>"<span style="color: blue">@(DeploymentSourceFiles-&gt;
      '$(DeploymentFolder)%(RecursiveDir)%(Filename)%(Extension)')</span>"<span style="color: blue">/&gt;
   &lt;/</span><span style="color: #a31515">Target</span><span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">Project</span><span style="color: blue">&gt;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a></p>
<p>So you are equipped with fully functional development platform for Vista Sidebar Gadgets.</p>
<p>One more thing. I do think that writing a JavaScript in C# is a good idea <img src='http://www.iprogrammable.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  but if you are new to Sidebar Gadgets you probably would like to take one <a href="http://microsoftgadgets.com/Sidebar/DevelopmentOverview.aspx">step by step tutorial</a>. It would help to understand Gadgets on the low level an d will get you up to speed with Schipr# later.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iprogrammable.com/2008/01/19/developing-vista-sidebar-gadget/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Continuous Integration article in SDJ</title>
		<link>http://www.iprogrammable.com/2007/09/03/continuous-integration-article-in-sdj/</link>
		<comments>http://www.iprogrammable.com/2007/09/03/continuous-integration-article-in-sdj/#comments</comments>
		<pubDate>Mon, 03 Sep 2007 17:24:59 +0000</pubDate>
		<dc:creator>marcin.kawalerowicz</dc:creator>
				<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[MSBuild]]></category>

		<guid isPermaLink="false">http://www.iprogrammable.com/2007/09/03/continuous-integration-article-in-sdj/</guid>
		<description><![CDATA[I would like to invite all my polish speaking readers to online version of my article about continuous integration in .NET. It was published in July 2007 in Software Developers Journal. You can find it in the download section of SDJ web page. You can read there about: setting up CI server with CruiseControl.NET creating [...]]]></description>
			<content:encoded><![CDATA[<p>I would like to invite all my polish speaking readers to online version of my article about continuous integration in .NET. It was published in July 2007 in <a href="http://www.sdjournal.org/">Software Developers Journal</a>. You can find it in the <a href="http://www.sdjournal.org/pl/sdj/download.html">download section of SDJ web page</a>. You can read there about:</p>
<ul>
<li>setting up CI server with CruiseControl.NET</li>
<li>creating one click build script with MSBuild</li>
<li>incorporating unit testing and code coverage into CI process</li>
<li>using WebDashboard and CCTray to control the process</li>
<li>introducing code analyze with FxCop</li>
<li>creating install file and deploying the project.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.iprogrammable.com/2007/09/03/continuous-integration-article-in-sdj/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

