<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Third Shelf &#187; msbuild</title>
	<atom:link href="http://thirdshelf.com/tag/msbuild/feed/" rel="self" type="application/rss+xml" />
	<link>http://thirdshelf.com</link>
	<description></description>
	<lastBuildDate>Sun, 13 May 2012 17:08:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='thirdshelf.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Third Shelf &#187; msbuild</title>
		<link>http://thirdshelf.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://thirdshelf.com/osd.xml" title="Third Shelf" />
	<atom:link rel='hub' href='http://thirdshelf.com/?pushpress=hub'/>
		<item>
		<title>Unit testing with Jenkins</title>
		<link>http://thirdshelf.com/2011/03/21/unit-testing-with-jenkins/</link>
		<comments>http://thirdshelf.com/2011/03/21/unit-testing-with-jenkins/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 15:51:23 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Jenkins]]></category>
		<category><![CDATA[MbUnit]]></category>
		<category><![CDATA[Microsoft Visual Studio]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[MsTest]]></category>
		<category><![CDATA[NUnit]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[Unit testing]]></category>
		<category><![CDATA[XUnit]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=511</guid>
		<description><![CDATA[Continuing to setup a build for the first time with Jenkins there is, uh, another challenge. For some reason, I thought it clever to make use of MsTest. This works wonderfully on the development machine. But, of course, when it comes to the build server, you can expect all sorts of weirdness. For example, error CS0246: The [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=511&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Continuing to setup a build for the first time with Jenkins there is, uh, another challenge. For some reason, I thought it clever to make use of MsTest. This works wonderfully on the development machine. But, of course, when it comes to the build server, you can <a href="http://thirdshelf.com/2011/03/19/building-a-net-application-with-jenkins/">expect all sorts of weirdness</a>. For example, error CS0246: The type or namespace name &#8216;TestMethodAttribute&#8217; could not be found&#8230;</p>
<p>We&#8217;re sorry, but our testing tools don&#8217;t come standard with the .NET Framework, or in any other way, except TFS and Visual Studio, unless you are willing to follow this <a href="http://www.shunra.com/shunrablog/index.php/2009/04/23/running-mstest-without-visual-studio/">brave soul</a>. I share <a href="http://devlicio.us/blogs/derik_whittaker/archive/2008/09/25/clean-build-server-with-mstest-fail.aspx">Derik Whittaker&#8217;s sentiment on the MsTest and build server</a> issue.</p>
<blockquote><p>This is another issue to me because MSTest is the ONLY test framework (for .Net) that I know of that does not run with a single DLL placed into the bin (or any other output directory).  I just have to ask the genius&#8217; over in Redmond what the hell were they smoking when they decided to build MSTest.  It is pretty clear they had no prior knowledge of how to use the other tools such as NUnit, MBUnit or xUnit (I know, xUnit was not out yet).  I know this because of all the various testing frameworks MSTest is the one that does everything different.  You could argue they were on the cutting edge and were innovating, but I call BS on that.</p></blockquote>
<p>This can be solved. <em>So long MsTest&#8230; Hello NUnit!</em></p>
<p><strong>Converting from MsTest to NUnit</strong></p>
<p>Converting from MsTest is a simple case of find and replace of <a href="http://nunit.org/index.php?p=attributes&amp;r=2.5.9">attributes</a>. NUnit  has the nifty Assert.Catch&lt;T&gt; which beats <a href="http://www.mbunit.com/">MbUnit</a>, MsTest and <a href="http://xunit.codeplex.com">xUnit</a>. xUnit comes with Assert.Throws&lt;T&gt; but cannot assert the exception message whereas NUnit can. No more [ExpectedException] attributes.</p>
<p>Integrating NUnit with the build file (which is MsBuild) is pretty easy:</p>
<p>&lt;Exec Command=&#8221;$(NUnitFolder)\nunit-console-x86.exe [TestAssembly] /framework=net-4.0 /xml=$(TestResultsFolder)\TestResults.xml&#8221; /&gt;</p>
<p>A single Exec statement and out comes an Xml file. To keep the build server clean, I decided to add all the necessary files for unit testing into source control along with the project. The bare minimum files for running NUnit from the command line comes down to the following files:</p>
<ul>
<li>nunit.core.dll</li>
<li>nunit.core.interfaces.dll</li>
<li>nunit.framework.dll</li>
<li>nunit.util.dll</li>
<li>nunit.console-runner.dll</li>
<li>nunit-console-x86.exe</li>
<li>nunit-agent-x86.exe</li>
<li>nunit-agent-x86.exe.config</li>
</ul>
<p>To make it work on .Net Framework 4.0, you have to include the <em>/framework=net-4.0</em> switch on the command line.</p>
<p><strong>Setting up Jenkins with NUnit</strong></p>
<p>Install the NUnit plugin for Jenkins, point it to your test results file and after a build you&#8217;ll get the summarised test results.  It&#8217;s a neat table with all the classes and their respective timings and so on.</p>
<p><a href="http://thirdshelf.files.wordpress.com/2011/03/jenkins-test-results.png"><img class="alignnone size-full wp-image-541" title="Jenkins-Test-Results" src="http://thirdshelf.files.wordpress.com/2011/03/jenkins-test-results.png?w=720" alt=""   /></a></p>
<p>Finally, I have a working build with unit testing. If only it had an installer&#8230;</p>
<p><strong><br />
</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/511/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/511/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/511/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/511/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/511/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/511/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/511/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=511&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2011/03/21/unit-testing-with-jenkins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>

		<media:content url="http://thirdshelf.files.wordpress.com/2011/03/jenkins-test-results.png" medium="image">
			<media:title type="html">Jenkins-Test-Results</media:title>
		</media:content>
	</item>
		<item>
		<title>Git and Hudson Brothers</title>
		<link>http://thirdshelf.com/2011/03/10/git-and-hudson-brothers/</link>
		<comments>http://thirdshelf.com/2011/03/10/git-and-hudson-brothers/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 19:04:55 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[reviews]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[hudson]]></category>
		<category><![CDATA[Internet Information Services]]></category>
		<category><![CDATA[Microsoft Windows]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[msysgit]]></category>
		<category><![CDATA[Revision control]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=462</guid>
		<description><![CDATA[For a while now, I&#8217;ve been thinking about creating a source control and build server for a couple of projects that I&#8217;m working on. I&#8217;ll admit, I moonlight. Anyway, a great analysis ensued. Starting with the OS; what will it be, what does it need to be? Considering that I&#8217;m building .NET projects and they&#8217;re Windows [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=462&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://thirdshelf.files.wordpress.com/2011/03/hudson-watermark.png"><img class="size-full wp-image-470 alignright" title="Hudson-Watermark" src="http://thirdshelf.files.wordpress.com/2011/03/hudson-watermark.png?w=720" alt=""   /></a>For a while now, I&#8217;ve been thinking about creating a <a href="http://en.wikipedia.org/wiki/Source_control">source control</a> and <a href="http://en.wikipedia.org/wiki/Continuous_integration">build server</a> for a couple of projects that I&#8217;m working on. I&#8217;ll admit, I moonlight. Anyway, a great analysis ensued. Starting with the OS; what will it be, what does it need to be? Considering that I&#8217;m building .NET projects and they&#8217;re Windows based; well that kind of settles that. Next up, which source control system? Oh boy, this took a while&#8230;</p>
<h3>Source Control</h3>
<p>Since everyone, OK, almost everyone, raves about <a href="http://en.wikipedia.org/wiki/Git_(software)">Git</a>, I suppose I&#8217;ll have to succumb. But, this is where the fun starts. I want Git, I want Windows. <a href="http://www.kernel.org/pub/software/scm/git/docs/git-push.html">Pushing</a>, <a href="http://www.kernel.org/pub/software/scm/git/docs/git-clone.html">cloning</a> and so on is what really I want. What a painful story&#8230; This requires the installation of <a href="http://code.google.com/p/msysgit/">MSysGit</a> or <a href="http://www.cygwin.com">Cygwin </a>and some <a href="http://en.wikipedia.org/wiki/Secure_Shell">SSH server</a>, blah blah, whatever. It was simply too much.</p>
<p>I decided to run <a href="http://www.visualsvn.com/">VisualSVN </a>on the server and then use <a href="http://www.kernel.org/pub/software/scm/git/docs/git-svn.html">git-svn</a> to bridge that little dilemma. Well, that kinda sucked. After formatting and configuring and formatting and configuring, I finally found<a href="http://www.jeremyskinner.co.uk/2010/06/25/hosting-a-git-server-under-iis7-on-windows/" target="_blank"> this post by Jeremy Skinner</a>. It explains how to setup Git on Windows using IIS 7.0, without any other fancy installations and configurations. He calls it <a href="https://github.com/JeremySkinner/git-dot-aspx/downloads" target="_blank">git-dot-aspx (GitAspx)</a>. To my surprise, this worked elegantly, the first time. Push, pull and clone without any issues. Great.</p>
<h3>Continuous Integration</h3>
<p>What a mental battle this turned out to be! What should I use, what do I need to use? There is from <a href="http://sourceforge.net/projects/ccnet/" target="_blank">CruiseControl.NET</a> to <a href="http://hudson-ci.org/" target="_blank">Hudson</a>. A colleague mentioned Hudson and, being quite popular, I decided to investigate. This turned out to be a fantastic piece of software. It is a Java application, but I decided that it is well worth it. One click and it installs as a Windows service. One command line and it uninstalls cleanly. Unbelievable! Such a polished product. Also, it has many plugins from MsBuild to Git to Twitter. Talk about pressure, having your build status published to Twitter!</p>
<p>For a good Windows alternative, these two products turned out to be highly effective and user friendly.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/462/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/462/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/462/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/462/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/462/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/462/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/462/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/462/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=462&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2011/03/10/git-and-hudson-brothers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>

		<media:content url="http://thirdshelf.files.wordpress.com/2011/03/hudson-watermark.png" medium="image">
			<media:title type="html">Hudson-Watermark</media:title>
		</media:content>
	</item>
		<item>
		<title>Automating a ClickOnce Deployment &#8211; Part3</title>
		<link>http://thirdshelf.com/2010/03/20/automating-a-clickonce-deployment-part3/</link>
		<comments>http://thirdshelf.com/2010/03/20/automating-a-clickonce-deployment-part3/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 18:34:33 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[team foundation server]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[TFS]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=320</guid>
		<description><![CDATA[Continuing the series on Automating a ClickOnce Deployment it’s time to implement the deployment scheme in a build file. After the build file compiled the solution we are ready to start the copying of the installation files to the deployment server. Before we start the copy process we have to create a new directory for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=320&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://thirdshelf.com/2010/03/20/automating-a-clickonce-deployment-%e2%80%93-part2/">Continuing  the series</a> on Automating a ClickOnce Deployment it’s time to implement the deployment scheme in a build file.</p>
<p>After the build file compiled the solution we are ready to start the copying of the installation files to the deployment server. Before we start the copy process we have to create a new directory for the new application version. In the following snippet I simply generate a new version number and then create a directory where we will copy the installation files to:</p>
<p><pre class="brush: xml;">
&lt;Target Name=&quot;DeployApplication&quot;&gt;
  &lt;Message Text=&quot;Deploying the client application to $(PublishServer)&quot; /&gt;
  &lt;MakeDir Directories=&quot;$(DeploymentServer)\Published\App\$(VersionNumber)&quot; /&gt;
</pre></p>
<p>We are ready to copy the application files to the server:</p>
<p><pre class="brush: xml;">
&lt;Message Text=&quot;Copying files to deployment directory [$(DeploymentServer)\Published\App\$(VersionNumber)]&quot; /&gt;
&lt;Copy DestinationFiles=&quot;@(ApplicationFiles-&gt;'$(DeploymentServer)\Published\App\$(VersionNumber)\%(Filename)%(Extension)')&quot; SourceFiles=&quot;@(ApplicationFiles-&gt;'$(BinariesFolder)\%(Filename)%(Extension)')&quot; /&gt;
</pre></p>
<p>The ApplicationFiles is an item group with the installation files that we are copying. <em>Note:</em> we do not transform the filename to include the .deploy extension because we first need to generate the deployment manifest with the files in the right location before changing the name of the files. (See Gotcha #3). Next, we create the application manifest with the <a href="http://msdn.microsoft.com/en-us/library/acz3y3te%28VS.80%29.aspx">Mage</a> utility which will be stored in the application directory (not in the version directory). Mage is a manifest generator and is used to generate both application and deployment manifests. In the snippet below we are using Mage explicitly to generate the application manifest:</p>
<p><pre class="brush: xml;">
&lt;CreateProperty Value=&quot;$(DeploymentServer)\Published\App\$(VersionNumber)\App.exe.manifest&quot;&gt;
  &lt;Output TaskParameter=&quot;Value&quot; PropertyName=&quot;ApplicationManifestFile&quot;/&gt;
&lt;/CreateProperty&gt;
&lt;Message Text=&quot;Generating application manifest  [$(ApplicationManifestFile)] using  [$(DeploymentServer)\Published\App\$(VersionNumber)]&quot; /&gt;
&lt;Exec Command=&quot;mage.exe -New  Application -p msil -TrustLevel FullTrust -ToFile  $(ApplicationManifestFile) -Name  &amp;quot;App&amp;quot; -Version $(VersionNumber) -FromDirectory  $(DeploymentServer)\Published\App\$(VersionNumber)&quot; /&gt;
</pre></p>
<p>So far so good, we have now managed to generate the deployment manifest from the files located in the &#8230;\Published\App directory and placed the file in the &#8230;\Published\App\$(VersionNumber) directory. We will now point the application manifest to this deployment manifest so that the correct files are installed on the client machine.</p>
<p>We now have everything that we need in order to generate the application manifest.</p>
<p><pre class="brush: xml;">
&lt;CreateItem Include=&quot;$(ApplicationManifestFile)&quot; AdditionalMetadata=&quot;TargetPath=$(VersionNumber)\App.exe.manifest&quot;&gt;
  &lt;Output TaskParameter=&quot;Include&quot; ItemName=&quot;RelativeApplicationManifestFile&quot;/&gt;
&lt;/CreateItem&gt;

&lt;GenerateDeploymentManifest AssemblyName=&quot;App.exe.application&quot;
  AssemblyVersion=&quot;$(VersionNumber)&quot;
  DeploymentUrl=&quot;http://deployment-server/Published/App/App.exe.application&quot;
  Product=&quot;App&quot;
  Description=&quot;App&quot;
  Publisher=&quot;thirdshelf.com&quot;
  Install=&quot;true&quot;
  UpdateEnabled=&quot;true&quot;
  UpdateMode=&quot;Foreground&quot;
  OutputManifest=&quot;$(DeploymentServer)\Published\App\App.exe.application&quot;
  MapFileExtensions=&quot;true&quot;
  EntryPoint=&quot;@(RelativeApplicationManifestFile)&quot; /&gt;
</pre></p>
<p>If you read <a href="http://thirdshelf.com/2010/03/20/automating-a-clickonce-deployment-%e2%80%93-part2/">part 2</a> of this series you should be able to map these properties straight to their positions in the application manifest file and their functions. The only thing that remains is to rename the files to include their .deploy extensions. This can easily be done in the following way:</p>
<p><pre class="brush: xml;">
&lt;Message Text=&quot;Replacing files in [$(DeploymentServer)\Published\App\$(VersionNumber)\] with [.deploy]&quot; /&gt;
&lt;Delete Files=&quot;@(ApplicationFiles-&gt;'$(DeploymentServer)\Published\App\$(VersionNumber)\%(Filename)%(Extension)')&quot; /&gt;
&lt;Copy SourceFiles=&quot;@(ApplicationFiles-&gt;'$(BinariesFolder)\%(Filename)%(Extension)')
  DestinationFiles=&quot;@(ApplicationFiles-&gt;'$(DeploymentServer)\Published\App\$(VersionNumber)\%(Filename)%(Extension).deploy')&quot; /&gt;
</pre></p>
<p>Visiting the URL http://deployment-server/Published/App/App.exe.manifest and clicking on the Install button you should see the following dialog:</p>
<p><img class="aligncenter size-full wp-image-335" title="ClickOnceInstallingApplication" src="http://thirdshelf.files.wordpress.com/2010/03/clickonceinstallingapplication1.png?w=720" alt=""   /><strong>Gotchas</strong></p>
<p>There are a few gotchas that you might find on your way to success and I&#8217;ve listed the most common ones here and their solutions for your convenience:</p>
<p><strong>Gotcha #1:</strong> Reference in the manifest does not match the identity of the downloaded  assembly &#8230;</p>
<p>This is easily resolved by adding the NoWin32Manifest property to solution in the SolutionsToBuild group:</p>
<p><pre class="brush: xml;">
&lt;SolutionToBuild Include=&quot;$(SolutionRoot)\Application.sln&quot;&gt;
  &lt;Properties&gt;NoWin32Manifest=true&lt;/Properties&gt;
&lt;/SolutionToBuild&gt;
</pre></p>
<p><strong>Gotcha #2:</strong> XML files are marked as data files, by default.</p>
<p>This means that XML files are  published to the data directory whose location can found by querying the<code> </code>System.Deployment.Application.ApplicationDeployment.CurrentDeployment.DataDirectory  property.</p>
<p><strong>Gotcha #3: </strong>The customHostSpecified attribute is not supported for Windows Forms  applications.</p>
<p>Not a very helpful error, but chances are that you generated the deployment manifest with the installation files having the .deploy extension and not on the original filenames.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/320/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/320/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/320/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=320&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2010/03/20/automating-a-clickonce-deployment-part3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>

		<media:content url="http://thirdshelf.files.wordpress.com/2010/03/clickonceinstallingapplication1.png" medium="image">
			<media:title type="html">ClickOnceInstallingApplication</media:title>
		</media:content>
	</item>
		<item>
		<title>Automating a ClickOnce Deployment – Part2</title>
		<link>http://thirdshelf.com/2010/03/20/automating-a-clickonce-deployment-%e2%80%93-part2/</link>
		<comments>http://thirdshelf.com/2010/03/20/automating-a-clickonce-deployment-%e2%80%93-part2/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 14:47:42 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[team foundation server]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[TFS]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=278</guid>
		<description><![CDATA[Continuing the series on Automating a ClickOnce Deployment it&#8217;s time to have a look at the manifest files. There are two required manifest files that give clickonce the necessary information to deploy the application: an application manifest (.application); a deployment manifest (.manifest). Application Manifest The application manifest describes the application that we are going to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=278&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://thirdshelf.com/2009/09/06/automating-clickonce-deployment/">Continuing the series</a> on Automating a ClickOnce Deployment it&#8217;s time to have a look at the manifest files. There are two required manifest files that give clickonce the necessary information to deploy the application:</p>
<ul>
<li>an application manifest (.application);</li>
<li>a deployment manifest (.manifest).</li>
</ul>
<p><strong>Application Manifest</strong></p>
<p>The <a href="http://msdn.microsoft.com/en-us/library/ws1c2fch.aspx">application  manifest</a> describes the application that we are going to install. So, let&#8217;s have a look at the contents of this file:</p>
<p><pre class="brush: xml;">
xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;asmv1:assembly xsi:schemaLocation=&quot;urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd&quot; manifestVersion=&quot;1.0&quot; xmlns:asmv3=&quot;urn:schemas-microsoft-com:asm.v3&quot; xmlns:dsig=&quot;http://www.w3.org/2000/09/xmldsig#&quot; xmlns:co.v1=&quot;urn:schemas-microsoft-com:clickonce.v1&quot; xmlns=&quot;urn:schemas-microsoft-com:asm.v2&quot; xmlns:asmv1=&quot;urn:schemas-microsoft-com:asm.v1&quot; xmlns:asmv2=&quot;urn:schemas-microsoft-com:asm.v2&quot; xmlns:xrml=&quot;urn:mpeg:mpeg21:2003:01-REL-R-NS&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
  &lt;assemblyIdentity name=&quot;App.application&quot; version=&quot;1.0.903.18476&quot; publicKeyToken=&quot;0000000000000000&quot; language=&quot;neutral&quot; processorArchitecture=&quot;msil&quot; xmlns=&quot;urn:schemas-microsoft-com:asm.v1&quot; /&gt;
  asmv2:publisher=&quot;App Publishers Company&quot; asmv2:product=&quot;App&quot; xmlns=&quot;urn:schemas-microsoft-com:asm.v1&quot;&gt;App
  mapFileExtensions=&quot;true&quot;&gt;
    &lt;subscription&gt;
      &lt;update&gt;
        &lt;beforeApplicationStartup /&gt;
      &lt;/update&gt;
    &lt;/subscription&gt;
    &lt;deploymentProvider codebase=&quot;http://deployment-server/Published/App/app.exe.application&quot; /&gt;
  &lt;/deployment&gt;
  &lt;dependency&gt;
    &lt;dependentAssembly dependencyType=&quot;install&quot; codebase=&quot;1.0.903.18476\App.exe.manifest&quot; size=&quot;33600&quot;&gt;
      &lt;assemblyIdentity name=&quot;App.exe&quot; version=&quot;1.0.903.18476&quot; publicKeyToken=&quot;0000000000000000&quot; language=&quot;neutral&quot; processorArchitecture=&quot;msil&quot; type=&quot;win32&quot; /&gt;
      &lt;hash&gt;
        &lt;dsig:Transforms&gt;
          &lt;dsig:Transform Algorithm=&quot;urn:schemas-microsoft-com:HashTransforms.Identity&quot; /&gt;
        &lt;/dsig:Transforms&gt;
        &lt;dsig:DigestMethod Algorithm=&quot;http://www.w3.org/2000/09/xmldsig#sha1&quot; /&gt;
        &lt;dsig:DigestValue&gt;DrLiyVjtlKhOmtuzuXhFSTqi/9Q=
      &lt;/hash&gt;
    &lt;/dependentAssembly&gt;
  &lt;/dependency&gt;
&lt;/asmv1:assembly&gt;
</pre></p>
<p>One of the important things to note in this manifest is the <em>mapFileExtensions</em> attribute in the<em> deployment </em>tag. This attribute indicates that our installation files have a .deploy extension &#8211; MyApplication.exe is copied to the deployment server as MyApplication.exe.deploy and is renamed when installed on the client machine. In the <em>deploymentProvider</em> tag we specify where the application can find future updates and from where this application was installed.</p>
<p>The next interesting tag is <em>dependentAssembly, </em>which points to the deployment manifest to use when installing the application on the client machine. We specify the deployment manifest in the <em>codeBase</em> attribute which describes how the application installs. Note that the <em>codebase</em> attribute points to a version folder in which the deployment manifest resides &#8211; for every new release of the application this application manifest is either overwritten or updated to point to the new version of the installation files and deployment manifest.</p>
<p><strong>Deployment Manifest</strong></p>
<p>The <a href="http://msdn.microsoft.com/en-us/library/k26e96zf.aspx">deployment manifest</a> describes the how the application installs and what files to install on the client. Once again, let&#8217;s have a look at the contents:</p>
<p><pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;asmv1:assembly xsi:schemaLocation=&quot;urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd&quot; manifestVersion=&quot;1.0&quot; xmlns:asmv3=&quot;urn:schemas-microsoft-com:asm.v3&quot; xmlns:dsig=&quot;http://www.w3.org/2000/09/xmldsig#&quot; xmlns=&quot;urn:schemas-microsoft-com:asm.v2&quot; xmlns:asmv1=&quot;urn:schemas-microsoft-com:asm.v1&quot; xmlns:asmv2=&quot;urn:schemas-microsoft-com:asm.v2&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:co.v1=&quot;urn:schemas-microsoft-com:clickonce.v1&quot;&gt;
  &lt;asmv1:assemblyIdentity name=&quot;App.exe&quot; version=&quot;1.0.903.18476&quot; publicKeyToken=&quot;0000000000000000&quot; language=&quot;neutral&quot; processorArchitecture=&quot;msil&quot; type=&quot;win32&quot; /&gt;
  &lt;application /&gt;
  &lt;entryPoint&gt;
    &lt;assemblyIdentity name=&quot;App&quot; version=&quot;1.0.903.18476&quot; language=&quot;neutral&quot; processorArchitecture=&quot;msil&quot; /&gt;
    &lt;commandLine file=&quot;App.exe&quot; parameters=&quot;&quot; /&gt;
  &lt;/entryPoint&gt;
  &lt;trustInfo&gt;
    &lt;security&gt;
      &lt;applicationRequestMinimum&gt;
        &lt;PermissionSet Unrestricted=&quot;true&quot; ID=&quot;Custom&quot; SameSite=&quot;site&quot; /&gt;
        &lt;defaultAssemblyRequest permissionSetReference=&quot;Custom&quot; /&gt;
      &lt;/applicationRequestMinimum&gt;
      &lt;requestedPrivileges xmlns=&quot;urn:schemas-microsoft-com:asm.v3&quot;&gt;
        &lt;requestedExecutionLevel level=&quot;asInvoker&quot; uiAccess=&quot;false&quot; /&gt;
      &lt;/requestedPrivileges&gt;
    &lt;/security&gt;
  &lt;/trustInfo&gt;
  &lt;dependency&gt;
    &lt;dependentOS&gt;
      &lt;osVersionInfo&gt;
        &lt;os majorVersion=&quot;5&quot; minorVersion=&quot;1&quot; buildNumber=&quot;0&quot; servicePackMajor=&quot;0&quot; /&gt;
      &lt;/osVersionInfo&gt;
    &lt;/dependentOS&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
    &lt;dependentAssembly dependencyType=&quot;preRequisite&quot; allowDelayedBinding=&quot;true&quot;&gt;
      &lt;assemblyIdentity name=&quot;Microsoft.Windows.CommonLanguageRuntime&quot; version=&quot;2.0.50727.0&quot; /&gt;
    &lt;/dependentAssembly&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
    &lt;dependentAssembly dependencyType=&quot;install&quot; allowDelayedBinding=&quot;true&quot; codebase=&quot;DevExpress.Data.v9.1.dll&quot; size=&quot;855552&quot;&gt;
      &lt;assemblyIdentity name=&quot;App&quot; version=&quot;9.1.5.0&quot; publicKeyToken=&quot;B88D1754D700E49A&quot; language=&quot;neutral&quot; processorArchitecture=&quot;msil&quot; /&gt;
      &lt;hash&gt;
        &lt;dsig:Transforms&gt;
          &lt;dsig:Transform Algorithm=&quot;urn:schemas-microsoft-com:HashTransforms.Identity&quot; /&gt;
        &lt;/dsig:Transforms&gt;
        &lt;dsig:DigestMethod Algorithm=&quot;http://www.w3.org/2000/09/xmldsig#sha1&quot; /&gt;
        &lt;dsig:DigestValue&gt;CXehkPHON56TeTj7ZWsy++QsymE=
      &lt;/hash&gt;
    &lt;/dependentAssembly&gt;
  &lt;/dependency&gt;
  &lt;file name=&quot;GlobalConfiguration.xml&quot; size=&quot;21074&quot;&gt;
    &lt;hash&gt;
      &lt;dsig:Transforms&gt;
        &lt;dsig:Transform Algorithm=&quot;urn:schemas-microsoft-com:HashTransforms.Identity&quot; /&gt;
      &lt;/dsig:Transforms&gt;
      &lt;dsig:DigestMethod Algorithm=&quot;http://www.w3.org/2000/09/xmldsig#sha1&quot; /&gt;
      &lt;dsig:DigestValue&gt;6hHtbL9F9sfgWmKLYrWRpYmILCE=
    &lt;/hash&gt;
  &lt;/file&gt;
&lt;/asmv1:assembly&gt;
</pre></p>
<p>The first tag of interest here is the <em>entryPoint</em> tag that identifies the application to run once the installation completes. In order to start the application clickonce will execute the command with the parameters specified in the <em>commandLine</em> tag.</p>
<p>Every application has dependencies that must either be installed with the program or should have been installed. In the first <em>dependency</em> tag we see that the minimum <a href="http://support.microsoft.com/kb/189249">operating system version</a> required is Windows XP. In the second dependency tag we see that the <em>dependencyType</em> attribute instructs clickonce to verify that the .NET Framework 2.0 is already installed on the client.</p>
<p>In the third dependency tag we see that the <em>dependencyType</em> is <em>install</em>, which instructs clickonce to install this dependency on the client. Remember that the .deploy extension will automatically be removed during the installation process.</p>
<p>The next tag is a file tag that specifies a non-assembly file that is copied into the application installation directory. <em>Note:</em> by default when clickonce encounters a xml file it assumes it as a configuration file and will copy it to a data directory; along the application directory; instead of the application directory. You can find the data directory location by querying the <em>System.Deployment.ApplicationApplicationDeployment.DataDirectory</em> property<em>.<br />
</em></p>
<p>In the <a href="http://thirdshelf.com/2010/03/20/automating-a-clickonce-deployment-part3/">next installment</a> of this series we will show a build file example and generate a deployment manifest with the <a href="http://msdn.microsoft.com/en-us/library/acz3y3te%28VS.80%29.aspx">Mage</a> tool.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/278/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=278&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2010/03/20/automating-a-clickonce-deployment-%e2%80%93-part2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>
	</item>
		<item>
		<title>Executing a task remotely with MsBuild</title>
		<link>http://thirdshelf.com/2009/10/19/executing-a-task-remotely-with-msbuild/</link>
		<comments>http://thirdshelf.com/2009/10/19/executing-a-task-remotely-with-msbuild/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 16:47:36 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[team foundation server]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[TFS]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=282</guid>
		<description><![CDATA[Recently, we were in need of executing a command on a remote server as part of our automated build process. For this we decided to make use of Windows Management Instrumentation (WMI). Before jumping to the code, copying and pasting it, there are always some security issues that need to be addressed. For this task [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=282&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently, we were in need of executing a command on a remote server as part of our automated build process. For this we decided to make use of <a href="http://en.wikipedia.org/wiki/Windows_Management_Instrumentation">Windows Management Instrumentation</a> (WMI). Before jumping to the code, copying and pasting it, there are always some security issues that need to be addressed. For this task there are also some service configurations that are required on the remote machine.</p>
<p><strong>Note: </strong>All of the following settings are configured on the remote machine on which the command will be run remotely.</p>
<p><strong>Security</strong></p>
<p><em>Follow the steps below to set the WMI permissions for the build service account:</em></p>
<ol>
<li>Click on <strong>Start</strong> &gt; <strong>Control Panel</strong> &gt; <strong>Administrative Tools</strong> &gt; <strong>Computer Management</strong>.</li>
<li>Expand <strong>Service and Applications</strong>.</li>
<li>Right-click on <strong>WMI Control</strong> and click on <strong>Properties</strong>.</li>
<li>On the property dialog select the <strong>Security</strong> tab.</li>
<li>Expand <strong>Root</strong> &gt; <strong>CIMV2</strong>.</li>
<li>Click on the <strong>Security</strong> button.</li>
<li>Click on <strong>Add</strong> and add &lt;TFSSERVICE&gt; account.</li>
<li>In the list of permissions, allow the following permissions:
<ul>
<li>Execute methods</li>
</ul>
<ul>
<li>Remote enable</li>
</ul>
</li>
<li>Click on <strong>OK</strong>.</li>
</ol>
<p><em>Follow the step below to set the Local Security Policy for the build service account:</em></p>
<ol>
<li>Click on <strong>Start</strong> &gt; <strong>Control Panel</strong> &gt; <strong>Administrative Tools</strong> &gt; <strong>Local Security Policy</strong>.</li>
<li>Expand <strong>Local Policies</strong> &gt; <strong>User Rights Assignment</strong>.</li>
<li>Find and double-click on <strong>Log on as a service</strong>.</li>
<li>Click on <strong>Add User or Group</strong> and add &lt;TFSSERVICE&gt; account.</li>
<li>Click on <strong>OK</strong>.</li>
<li>Find and double-click <strong>Log on as a batch job</strong>.</li>
<li>Click on <strong>Add User or Group</strong> and add &lt;TFSSERVICE&gt; account.</li>
<li>Click on <strong>OK</strong> and close the <strong>Local Security Policy</strong> window.</li>
</ol>
<p><strong>Services</strong></p>
<p><em>Follow the steps below set the dependent services to automatically start:</em></p>
<ol>
<li>Click on <strong>Start </strong>&gt; <strong>Control Panel</strong> &gt; <strong>Administrative Tools</strong>.</li>
<li>Double click on <strong>Services</strong>.</li>
<li>Ensure that the following services are <strong>Started</strong>, and are set to start <strong>Automatic</strong>.
<ul>
<li>COM+ Event System</li>
<li>Remote Access Auto Connection Manager</li>
<li>Remote Access Connection Manager</li>
<li>Remote Procedure Call (RPC)</li>
<li>Remote Procedure Call (RPC) Locator</li>
<li>Remote Registry</li>
<li>Server</li>
<li>Windows Management Instrumentation</li>
<li>Windows Management Instrumentation Driver Extensions</li>
<li>WMI Performance Adapter</li>
<li>Workstation</li>
</ul>
</li>
<li>Close the services dialog.</li>
</ol>
<p>Here is the code for the build task that will execute a command on a remote machine:</p>
<p><pre class="brush: csharp;">
/// &lt;summary&gt;
/// Executes a command line on a remote machine.
/// &lt;/summary&gt;
public class RemoteExec : Task
{
 /// &lt;summary&gt;
 /// Initialises a new instance of the &lt;see cref=&quot;RemoteExec&quot;/&gt; class.
 /// &lt;/summary&gt;
 public RemoteExec()
 {
   RemoteMachine = Environment.MachineName;
 }

 /// &lt;summary&gt;
 /// Gets or sets the name of the machine on which to execute the command.
 /// &lt;/summary&gt;
 public string RemoteMachine
 {
   get;
   set;
 }

 /// &lt;summary&gt;
 /// Gets or sets the command to execute on the remote machine.
 /// &lt;/summary&gt;
 [Required]
 public string Command
 {
   get;
   set;
 }

 /// &lt;summary&gt;
 /// Executes the task on the remote machine.
 /// &lt;/summary&gt;
 /// &lt;returns&gt;true if the task succeeded, otherwise, false&lt;/returns&gt;
 public override bool Execute()
 {
   if (string.IsNullOrEmpty(Command))
   {
     Log.LogError(&quot;Command property was not set.&quot;);
     throw new ArgumentNullException(&quot;Command&quot;);
   }

   var connOptions = new ConnectionOptions();
   connOptions.Impersonation = ImpersonationLevel.Impersonate;
   connOptions.EnablePrivileges = true;

   var managementScope = new ManagementScope(
     string.Format(@&quot;\\{0}\ROOT\CIMV2&quot;, RemoteMachine), connOptions);
   managementScope.Connect();

   Log.LogMessage(string.Format(CultureInfo.CurrentCulture, &quot;Connected to {0}: {1}&quot;,
   RemoteMachine, managementScope.IsConnected));

   if (!managementScope.IsConnected)
   return false;

   var objectGetOptions = new ObjectGetOptions();
   var managementPath = new ManagementPath(&quot;Win32_Process&quot;);
   var processClass = new ManagementClass(managementScope, managementPath, objectGetOptions);

   var processParameters = processClass.GetMethodParameters(&quot;Create&quot;);

   processParameters[&quot;CommandLine&quot;] = Command;
   try
   {
     var outParams = processClass.InvokeMethod(&quot;Create&quot;, processParameters, null);
     var processID = Convert.ToUInt32(outParams[&quot;processId&quot;]);

     Log.LogMessage(string.Format(CultureInfo.CurrentCulture,
       &quot;Creation of the process {0} returned: {1}&quot;, processID, outParams[&quot;returnValue&quot;]));

     var stopQuery = new WqlEventQuery(string.Format(CultureInfo.CurrentCulture,
       &quot;select * from Win32_ProcessStopTrace where ProcessID={0}&quot;, processID));

     var processStopEvent = new ManagementEventWatcher(managementScope, stopQuery);
     processStopEvent.Options.Timeout = new TimeSpan(0, 1, 0);

     Log.LogMessage(&quot;Waiting for process to complete...&quot;);
     processStopEvent.WaitForNextEvent();
     processStopEvent.Stop();

     Log.LogMessage(&quot;Completed.&quot;);
   }
   catch (Exception ex)
   {
     Log.LogError(ex.Message);
   }

   return true;
   }
}
</pre></p>
<p>The task can then be used as follows:</p>
<p><pre class="brush: xml;">
&lt;UsingTask TaskName=&quot;RemoteExec&quot; AssemblyFile=&quot;BuildTasks.dll&quot;/&gt;
&lt;RemoteExec RemoteMachine=&quot;$(Server)&quot; Command=&quot;application.exe&quot; /&gt;
</pre></p>
<p>There we have it, executing a command remotely from MsBuild!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/282/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/282/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/282/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=282&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2009/10/19/executing-a-task-remotely-with-msbuild/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating JunctionPoints with MsBuild</title>
		<link>http://thirdshelf.com/2009/10/10/creating-junctionpoints-with-msbuild/</link>
		<comments>http://thirdshelf.com/2009/10/10/creating-junctionpoints-with-msbuild/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 14:32:37 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[team foundation server]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[TFS]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=260</guid>
		<description><![CDATA[With our build process we decided on a deployment folder structure that required us to create NTFS Junction Points. Junction Points are links to other folders, also known as soft links. Below is an example of how these links appear in Windows 7. It also shows our deployment folders for various build types: All the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=260&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>With our build process we decided on a deployment folder structure that required us to create <a href="http://en.wikipedia.org/wiki/NTFS_junction_point">NTFS Junction Points</a>. Junction Points are links to other folders, also known as soft links. Below is an example of how these links appear in Windows 7. It also shows our deployment folders for various build types:</p>
<p style="text-align:left;"><img class="size-full wp-image-262  aligncenter" title="JunctionPointFolderStructure" src="http://thirdshelf.files.wordpress.com/2009/09/junctionpointfolderstructure.png?w=720" alt="JunctionPointFolderStructure"   />All the folders with shortcut arrows are junction points or links to folders in the <em>Published</em> folder. For each build, the binaries are copied to a build numbered folder in the <em>Published</em> folder. Only when a build is successful; meaning that all code compiled and unit tests passed; do we update the junction point to the relevant build numbered folder in <em>Published</em>.</p>
<p>By using the code written by Jeff Brown in this <a href="http://www.codeproject.com/KB/files/JunctionPointsNet.aspx">article</a>, I was able to create a custom build task that enabled us to the create and delete junction points with relative ease. Here is a <a href="http://www.mediafire.com/?sharekey=8d2e5bea19404d71d9d5c56d04dfa8b0e04e75f6e8ebb871">link</a> to the source code for an MsBuild task that will enable you to manage junction points with MsBuild.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/260/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=260&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2009/10/10/creating-junctionpoints-with-msbuild/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>

		<media:content url="http://thirdshelf.files.wordpress.com/2009/09/junctionpointfolderstructure.png" medium="image">
			<media:title type="html">JunctionPointFolderStructure</media:title>
		</media:content>
	</item>
		<item>
		<title>Automating a ClickOnce Deployment &#8211; Part1</title>
		<link>http://thirdshelf.com/2009/09/06/automating-clickonce-deployment/</link>
		<comments>http://thirdshelf.com/2009/09/06/automating-clickonce-deployment/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 17:50:55 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[team foundation server]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[TFS]]></category>

		<guid isPermaLink="false">http://thirdshelf.com/?p=240</guid>
		<description><![CDATA[In our build process, using Team Foundation Build, we decided to use ClickOnce for application deployment. In this post I&#8217;ll try to set the lay of the land. In the following couple of posts I will take you through the process of setting up a clickonce deployment. Choosing the deployment strategy There are essentially two [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=240&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In our build process, using Team Foundation Build, we decided to use C<a href="http://msdn.microsoft.com/en-us/library/t71a733d%28VS.80%29.aspx">lickOnce</a> for application deployment. In this post I&#8217;ll try to set the lay of the land. In the following couple of posts I will take you through the process of setting up a clickonce deployment.</p>
<p><strong>Choosing the deployment strategy</strong></p>
<p>There are essentially two <a href="http://msdn.microsoft.com/en-us/library/71baz9ah%28VS.80%29.aspx">different ways</a> to deploy clickonce applications. They are:</p>
<ol>
<li>Physical media such as CD or DVD</li>
<li>Network share or web</li>
</ol>
<p>Deciding on the strategy that will work for you is largely determined by the available bandwidth at the client site. If there is none to very little bandwidth, or no internet connectivity, choose CD / DVD. Otherwise choose Network share or web.</p>
<p>We opted for the web strategy and so I will base the series around this strategy.</p>
<p><strong>Lay of the land</strong></p>
<p>Assume that we have one build server and one deployment server. The build server will push the build artifacts to the deployment server from where clients will use clickonce to install the application. The application is pushed to the deployment server after every build  with a new version number.</p>
<p>To make the explanations easier we will setup a hypothetical configuration and base the deployment configuration on it. Our hypothetical solution consists of a single application, which we will call App. Below is a diagram that demonstrates this configuration:</p>
<p><a href="http://thirdshelf.files.wordpress.com/2009/09/clickoncelayout1.png"><img class="aligncenter size-full wp-image-312" title="ClickOnceLayout" src="http://thirdshelf.files.wordpress.com/2009/09/clickoncelayout1.png?w=720" alt=""   /></a></p>
<p><em>Note: </em>To hide the published share simply name it with a trailing dollar sign  i.e. &#8220;Published$&#8221;.</p>
<p style="text-align:center;">
<p><strong>Initial configuration</strong></p>
<p>First of all we need a folder on the deployment server to push the build artifacts to. For this, create a published<em> </em>folder on the deployment server and share it with modify permissions granted to the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=FF12844F-398C-4FE9-8B0D-9E84181D9923&amp;displaylang=en">TFSSERVICE account</a>. Remember the TFSSERVICE account that TFS uses for the build service?</p>
<p>Furthermore, we need to configure Internet Information Services (IIS) to interpret the clickonce files correctly according to their extension. For this, add the following <a href="http://en.wikipedia.org/wiki/MIME">MIME</a> types in IIS:</p>
<pre>.application    application/x-ms-application
.manifest       application/x-ms-manifest
.deploy         application/octet-stream
</pre>
<p>If you are using IIS 6.0, have a look at this<a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;326965"> article</a> &#8220;IIS 6.0 Does Not Serve Unknown MIME Types&#8221;.</p>
<p>In the <a href="http://thirdshelf.com/2010/03/20/automating-a-clickonce-deployment-%E2%80%93-part2/">next installment</a> I&#8217;ll discuss the different files that describe the application and deployment.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/240/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=240&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2009/09/06/automating-clickonce-deployment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>

		<media:content url="http://thirdshelf.files.wordpress.com/2009/09/clickoncelayout1.png" medium="image">
			<media:title type="html">ClickOnceLayout</media:title>
		</media:content>
	</item>
		<item>
		<title>CopyDirectoryDifferences Build Task</title>
		<link>http://thirdshelf.com/2008/09/01/copydirectorydifferences-build-task/</link>
		<comments>http://thirdshelf.com/2008/09/01/copydirectorydifferences-build-task/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 16:20:41 +0000</pubDate>
		<dc:creator>Sydney du Plooy</dc:creator>
				<category><![CDATA[team foundation server]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[msbuild]]></category>
		<category><![CDATA[TFS]]></category>

		<guid isPermaLink="false">http://thirdshelf.wordpress.com/?p=145</guid>
		<description><![CDATA[In my attempt to optimize our build script work, I found myself needing to copy a list of files from one directory to another without overwriting existing files in the destination directory. Scenario: We need to gather code coverage information using multiple test containers (assemblies with unit tests inside them). This results in instrumenting all [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=145&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my attempt to optimize our build script work, I found myself needing to copy a list of files from one directory to another without overwriting existing files in the destination directory.</p>
<p><strong>Scenario:</strong></p>
<p>We need to gather code coverage information using multiple test containers (assemblies with unit tests inside them). This results in instrumenting all the assemblies that the test container depends on. This happens before the execution of unit tests in each test container.</p>
<p><strong>Solution:</strong></p>
<p>Use the MSBuild copy task to copy all the files from the source directory to the destination directory without overwriting the files that already exists in the destination directory. Simple enough, eh? Except, there is no support for this scenario to be found in the <a href="http://msdn.microsoft.com/en-us/library/3e54c37h.aspx">Copy Task</a> that ships with MSBuild by default.</p>
<p>We are left no choice but to roll our own. Here is a code listing of the task that I wrote to do precisely that:</p>
<p><pre class="brush: csharp;">
/// &lt;summary&gt;
/// Copies files from a source directory to a destination directory that
/// do not exist in the destination directory.
/// &lt;/summary&gt;
public class CopyDirectoryDifference : Task
{
  private string _SourcePath = string.Empty;
  private string _DestinationPath = string.Empty;
  private ITaskItem[] _FilesCopied = {};

  /// &lt;summary&gt;
  /// Gets or sets the source path from where files will be copied.
  /// &lt;/summary&gt;
  [Required]
  public string SourcePath
  {
    get { return _SourcePath; }
    set { _SourcePath = value; }
  }

  /// &lt;summary&gt;
  /// Gets or sets the destination path to where files will be copied.
  /// &lt;/summary&gt;
  [Required]
  public string DestinationPath
  {
    get { return _DestinationPath; }
    set { _DestinationPath = value; }
  }

  /// &lt;summary&gt;
  /// Gets the files that were copied to the destination path.
  /// &lt;/summary&gt;
  [Output]
  public ITaskItem[] FilesCopied
  {
    get { return _FilesCopied; }
  }

  /// &lt;summary&gt;
  /// Finds the files that are different between two directories and copies them from
  /// the source directory to the target directory.
  /// &lt;/summary&gt;
  /// &lt;returns&gt;true if the task completed successfully, otherwise false.&lt;/returns&gt;
  public override bool Execute()
  {
    if (!Directory.Exists(_SourcePath))
    {
      Log.LogError(&quot;Source path does not exist.&quot;);
      return false;
    }

    if (!Directory.Exists(_DestinationPath))
    {
      Log.LogError(&quot;Destination path does not exist.&quot;);
      return false;
    }

    string[] sourceFiles = Directory.GetFiles(_SourcePath);
    string[] destinationFiles = Directory.GetFiles(_DestinationPath);
    List&lt;itaskitem&gt; copiedFiles = new List&lt;/itaskitem&gt;&lt;itaskitem&gt;();

    foreach (string file in sourceFiles)
    {
      string fileName = Path.GetFileName(file);

      if (!File.Exists(Path.Combine(_DestinationPath, fileName)))
      {
        Log.LogMessage(&quot;Copying file {0} from {1} to {2}.&quot;, fileName, _SourcePath, _DestinationPath);

	try
	{
	  File.Copy(Path.Combine(_SourcePath, fileName), Path.Combine(_DestinationPath, fileName), false);
	  copiedFiles.Add(new TaskItem(Path.Combine(_SourcePath, fileName)));
	}
	catch (IOException ex)
	{
	  Log.LogError(&quot;Failed to copy the file {0}. Exception: {1}&quot;, Path.Combine(_SourcePath, fileName), ex.ToString());
	  return false;
	}
      }
    }

    if(copiedFiles.Count &gt; 0)
      _FilesCopied = copiedFiles.ToArray();

    Log.LogMessage(&quot;Done.&quot;);

    return true;
  }
}
</pre></itaskitem></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thirdshelf.wordpress.com/145/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thirdshelf.wordpress.com/145/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirdshelf.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirdshelf.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirdshelf.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirdshelf.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thirdshelf.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thirdshelf.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thirdshelf.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thirdshelf.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirdshelf.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirdshelf.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirdshelf.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirdshelf.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirdshelf.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirdshelf.wordpress.com/145/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirdshelf.com&#038;blog=3179385&#038;post=145&#038;subd=thirdshelf&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thirdshelf.com/2008/09/01/copydirectorydifferences-build-task/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Sydney</media:title>
		</media:content>
	</item>
	</channel>
</rss>
