﻿<?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>Just A Programmer &#187; Visual Studio</title>
	<atom:link href="http://www.justaprogrammer.net/tag/visual-studio/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.justaprogrammer.net</link>
	<description>We're Just Programmers...</description>
	<lastBuildDate>Tue, 10 Jan 2012 03:59:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Continuous Integration with TFS2010, MSDeploy &amp; VSDBCMD</title>
		<link>http://www.justaprogrammer.net/2011/10/27/continuous-integration-with-tfs2010-msdeploy-vsdbcmd/</link>
		<comments>http://www.justaprogrammer.net/2011/10/27/continuous-integration-with-tfs2010-msdeploy-vsdbcmd/#comments</comments>
		<pubDate>Fri, 28 Oct 2011 01:18:03 +0000</pubDate>
		<dc:creator>Stanley</dc:creator>
				<category><![CDATA[Just A Programmer]]></category>
		<category><![CDATA[MS Web Deploy]]></category>
		<category><![CDATA[Team Foundation Server]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[VSDBCMD]]></category>

		<guid isPermaLink="false">http://www.justaprogrammer.net/?p=965</guid>
		<description><![CDATA[After I created an account at Cytanium, I quickly discovered the glory of One-Click Publish. After setting up my source control in TFS. All I could think of, was getting TFS to do the same thing for me, but even I knew that wouldn&#8217;t be enough. I wanted TFS to deploy my database changes as [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.justaprogrammer.net%252F2011%252F10%252F27%252Fcontinuous-integration-with-tfs2010-msdeploy-vsdbcmd%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2Frsad6L%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Continuous%20Integration%20with%20TFS2010%2C%20MSDeploy%20%26%20VSDBCMD%22%20%7D);"></div>
<p>After I created an account at <a href="http://www.cytanium.com/" title="Cytanium" target="_blank">Cytanium</a>, I quickly discovered the glory of One-Click Publish. After setting up my source control in TFS. All I could think of, was getting TFS to do the same thing for me, but even I knew that wouldn&#8217;t be enough. I wanted TFS to deploy my database changes as well. Well, there is that Schema Compare utility in Visual Studio, I know it can figure out and deploy changes to a database. I figured if Visual Studio can do all of these things, I should be able to as well&#8230; shouldn&#8217;t I?</p>
<h4>Custom Build Process Templates</h4>
<p>Very soon after you start to ask these kinds of questions, you find yourself looking at TFS Build Process Templates. The templates are designed in Windows Workflow and thanks to a few good blogs out there this is a rather approachable topic. Most of my starting information came from this blog sequence: <a href="http://www.ewaldhofman.nl/post/2010/04/20/Customize-Team-Build-2010-e28093-Part-1-Introduction.aspx" title="Ewald Hofman's - Customize Team Build 2010" target="_blank">Ewald Hofman&#8217;s &#8211; Customize Team Build 2010</a>.</p>
<p>Before you start, save yourself the pain, take Ewald&#8217;s advice and <a title="Customize Team Build 2010 – Part 11: Speed up opening my build process template" href="http://www.ewaldhofman.nl/post/2010/10/01/Customize-Team-Build-2010-e28093-Part-11-Speed-up-opening-my-build-process-template.aspx" target="_blank">add the Team Foundation Build Activities to your Toolbox</a>. This <strong>will</strong> shave 15 seconds off the time to open every template.</p>
<h5>Exposing Arguments and Providing Metadata</h5>
<p>More lessons from Ewald on <a href="http://www.ewaldhofman.nl/post/2010/04/27/Customize-Team-Build-2010-e28093-Part-2-Add-arguments-and-variables.aspx" title="Add arguments and variables" target="_blank">adding arguments</a> and <a href="http://www.ewaldhofman.nl/post/2010/04/28/Customize-Team-Build-2010-e28093-Part-3-Use-more-complex-arguments.aspx" title="Use more complex arguments" target="_blank">adding more complex arguments</a>. We will use them and see how the values are supplied a bit later on.</p>
<ul>
<li>Continuous Integration Database Deployment
<ul>
<li><strong>ciVSDBCMDConnectionString</strong>: &#8220;Database Connection String&#8221;</li>
<li><strong>ciVSDBCMDManifestFile</strong>: &#8220;Database Manifest File&#8221;</li>
<li><strong>ciVSDBCMDTargetDatabase</strong>: &#8220;Target Database&#8221;</li>
</ul>
</li>
<li>Continuous Integration Website Deployment
<ul>
<li><strong>ciMSDeployWebProject</strong>: &#8220;Web Project&#8221;</li>
<li><strong>ciMSDeployUsername</strong>: &#8220;MSDeploy Credentials: Username&#8221;</li>
<li><strong>ciMSDeployPassword</strong>: &#8220;MSDeploy Credentials: Password&#8221;</li>
<li><strong>ciMSDeployWebService</strong>: &#8220;MSDeploy Web Service Url&#8221;</li>
<li><strong>ciMSDeployWebApplication</strong>: &#8220;Web Application Name&#8221;</li>
</ul>
</li>
</ul>
<p><a href="http://www.justaprogrammer.net/wp-content/uploads/2011/10/2011-10-26_2015.png"><img src="http://www.justaprogrammer.net/wp-content/uploads/2011/10/2011-10-26_2015-300x189.png" alt="" title="Build Process Template Variables" width="300" height="189" class="aligncenter size-medium wp-image-1055" /></a></p>
<h5>Customizing the Template</h5>
<p>Under your Team Project, go to the folder BuildProcessTemplates, and branch DefaultTemplate.xaml to ContinuousIntegrationTemplate.xaml.<br />
<a href="http://www.justaprogrammer.net/wp-content/uploads/2011/10/2011-10-25_2309.png"><img src="http://www.justaprogrammer.net/wp-content/uploads/2011/10/2011-10-25_2309.png" alt="" title="Branch Default Build Process Template" width="491" height="105" class="aligncenter size-full wp-image-1013" /></a></p>
<p>Open it up and and take a look around. It will help if you take a top down approach, Collapse All, using the controls in the top right. Locate the AgentScope Activity named &#8220;Run On Agent&#8221; and expand it. Now look for the open space after the &#8220;Try Compile, Test, and Associate Work Item&#8221; Sequence Activity; this is where we will start adding our custom functionality.</p>
<p>In this space add a If Activity and name it: &#8220;If Build and Test Succeeded&#8221;. In its condition we are going to add the following VB statement:</p>
<pre><pre class="brush: vb; title: ; notranslate">BuildDetail.CompilationStatus = BuildPhaseStatus.Succeeded And
    (BuildDetail.TestStatus = BuildPhaseStatus.Succeeded Or
        BuildDetail.TestStatus = BuildPhaseStatus.Unknown)</pre></pre>
<p>In the Then clause we drop a sequence named: &#8220;Deploy Database and Website&#8221;. Inside that sequence, go ahead and create a &#8220;Deploy Database&#8221; Sequence and a &#8220;Deploy Website&#8221; Sequence. In the else clause we can create a WriteBuildWarning with the message: &#8220;Deployment Skipped&#8221;. It should all look like this in the end&#8230;<br />
<a href="http://www.justaprogrammer.net/wp-content/uploads/2011/10/2011-10-26_1845.png"><img src="http://www.justaprogrammer.net/wp-content/uploads/2011/10/2011-10-26_1845.png" alt="" title="If Build and Test Succeeded" width="455" height="793" class="aligncenter size-full wp-image-1003" /></a></p>
<h5>Deploy Database</h5>
<p>A large part of my introduction to VSDBCMD (not to mention a large part of this idea) came from this <a href="http://msdn.microsoft.com/en-us/library/ff805001.aspx#checkintemplate" title="Visual Studio Walkthrough" target="_blank">Visual Studio Walkthrough</a> on the topic. If you are willing to work through the <a href="https://connect.microsoft.com/VisualStudio/feedback/details/575383/datadude-valid-sqlcmd-syntax-throws-error-at-build-time" target="_blank">various</a> <a href="http://connect.microsoft.com/VisualStudio/feedback/details/424035/visual-studio-2008-database-edition-gdr-finer-grain-control-of-user-schema-permission-scripting" target="_blank">issues</a> with using Database Deployment, it is worth it.</p>
<p>I happen to have Visual Studio installed on my TFS Server, if you dont, copy this application from your Visual Studio install to all your TFS Build Agents.</p>
<blockquote><p>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VSTSDB\Deploy\</p></blockquote>
<p>We are going to use an InvokeProcess Activity to call VSDMCMD.exe with the following code for arguments property. The manifest file will contain the Database name and Connection String that was configured in the project, but chances are you are going to want to override this per environment.</p>
<pre><pre class="brush: vb; title: ; wrap-lines: true; notranslate">String.Format(&quot;/a:Deploy /dd+ /dsp:Sql&quot; _
     &amp; &quot; /manifest:&quot;&quot;{0}\{1}&quot;&quot;&quot; _
     &amp; &quot; /p:TargetDatabase=&quot;&quot;{2}&quot;&quot; /cs:&quot;&quot;{3}&quot;&quot;&quot;, _
     BuildDetail.DropLocation, ciVSDBCMDManifestFile, _
     ciVSDBCMDTargetDatabase, ciVSDBCMDConnectionString)</pre></pre>
<p>Be sure to properly name the InvokeProcess Activity, as well as provide WriteBuildMessage and WriteBuildError Actvities for the standard and error output.</p>
<p><a href="http://www.justaprogrammer.net/wp-content/uploads/2011/10/2011-10-26_2036.png"><img src="http://www.justaprogrammer.net/wp-content/uploads/2011/10/2011-10-26_2036.png" alt="" title="Deploy Database Sequence" width="268" height="336" class="aligncenter size-full wp-image-1064" /></a></p>
<h5>Deploy Website</h5>
<p>Deploying databases was actually a lot easier than I expected, which is fortunate, because deploying websites was a lot more challenging. </p>
<p>Lets add a few variables to the Deploy Website Sequence:</p>
<ul>
<li>Name: websitePublishDirectoryPath</li>
<li>Variable type: String</li>
<li>Default:
<pre><pre class="brush: vb; title: ; notranslate">String.Format(&quot;{0}\Website Deployment&quot;, BinariesDirectory)</pre></pre>
</li>
</ul>
<ul>
<li>Name: msDeployManifestFilePath</li>
<li>Variable type: String</li>
<li>Default:
<pre><pre class="brush: vb; title: ; notranslate">String.Format(&quot;{0}\{1}.manifest&quot;, websitePublishDirectoryPath, ciMSDeployWebProject)</pre></pre>
</li>
</ul>
</li>
<p>As we will continue by defining a Sequence named &#8220;Prepare Deployment&#8221;. This sequence is responsible for preparing a folder to publish. So we have to create the directory copy the output to it and perform any Web.config transformations. First lets declare a variable in this scope:</p>
<ul>
<li>Name: platformConfiguration</li>
<li>Variable type: Microsoft.TeamFoundation.Build.Workflow.Activities.PlatformConfiguration</li>
<li>Default:
<pre><pre class="brush: vb; title: ; notranslate">BuildSettings.PlatformConfigurations.First</pre></pre>
</li>
</ul>
<ul>
<li>Name: websiteSourceDirectory</li>
<li>Variable type: String</li>
<li>Default:
<pre><pre class="brush: vb; title: ; notranslate">String.Format(&quot;{0}\_PublishedWebsites\{1}&quot;, BinariesDirectory, ciMSDeployWebProject)</pre></pre>
</li>
</ul>
<ul>
<li>Name: websiteDestinationDirectory</li>
<li>Variable type: Microsoft.TeamFoundation.Build.Workflow.Activities.PlatformConfiguration</li>
<li>Default:
<pre><pre class="brush: vb; title: ; notranslate">String.Format(&quot;{0}\{1}&quot;, websitePublishDirectoryPath, ciMSDeployWebProject)</pre></pre>
</li>
</ul>
<p>One CreateDirectory Activity to create the folder named in variable `websitePublishDirectory`, one CopyDirectory Activity to copy `websiteSourceDirectory` to `websiteDestinationDirectory` and an additonal Sequence named &#8220;Find and Transform Web.config Files&#8221;</p>
<div id="attachment_1105" class="wp-caption alignright" style="width: 232px"><a href="http://www.justaprogrammer.net/wp-content/uploads/2011/10/Find-and-Transform-Web.config-Files-Full.jpg"><img src="http://www.justaprogrammer.net/wp-content/uploads/2011/10/Find-and-Transform-Web.config-Files-Mini.jpg" alt="" title="Find and Transform Web.config Files Mini" width="222" height="237" class="size-full wp-image-1105" /></a><p class="wp-caption-text">Click for the full workflow</p></div>
<h6>Yet Another Web.config Transform</h6>
<p>There seems to be <a href="http://msdn.microsoft.com/en-us/library/dd465318.aspx" title="How to: Transform Web.config When Deploying a Web Application Project" target="_blank">a lot</a> <a href="http://geekswithblogs.net/EltonStoneman/archive/2010/08/20/using-msbuild-4.0-web.config-transformation-to-generate-any-config-file.aspx" title="Using MSBuild 4.0 web.config Transformation to Generate Any Config File" target="_blank">of places</a> <a href="http://blog.foxxtrot.net/2011/01/using-vs2010-webconfig-transforms-without-vs2010-web-deployment.html" title="Using VS2010 Web.Config Transforms Without VS2010 Web Deployment" target="_blank">to find</a> <a href="http://rachelappel.com/deployment/keeping-configurations-consistent-with-web-config-transformations/" title="Keeping Configurations Consistent with web.config Transformations" target="_blank">good information</a> on the <a href="http://www.leniel.net/2011/06/replace-webconfig-appsetting-transform.html" title="Replacing Web.config settings with Transforms" target="_blank">Web.config</a><br />
<a href="http://www.hanselman.com/blog/SlowCheetahWebconfigTransformationSyntaxNowGeneralizedForAnyXMLConfigurationFile.aspx" title="SlowCheetah - Web.config Transformation Syntax now generalized for any XML configuration file " target="_blank">transformation</a> <a href="http://stackoverflow.com/search?q=web.config+transform+transformation" title="StackOverflow" target="_blank">topic</a>. So I&#8217;m not reinventing anything here. Generally I looked for web.config files and any matching transformation files. An MSBuild Activity is used to perform the transformation. Finally delete all transform files, and continue. It&#8217;s important, but rather boring&#8230; and this blog post is long enough already.</p>
<h6 style='clear:both;'>Web Deploy 2.0</h6>
<p>Hopefully you can have someone else configure Web Deploy 2.0 for you, but since you are reading this, I doubt that is the case. On learn.iis.net, I found the best set of tutorials to <a href="http://learn.iis.net/page.aspx/421/installing-web-deploy/" title="Installing Web Deploy" target="_blank">install</a>, <a href="http://learn.iis.net/page.aspx/516/configure-the-web-deployment-handler/" title="Configure the Web Deployment Handler" target="_blank">configure</a>, (and most importantly) <a href="http://blogs.iis.net/msdeploy/archive/2010/09/24/debugging-delegation-rules-for-web-deploy.aspx" title="Debugging Delegation Rules for Web Deploy" target="_blank">debug</a>. If you are having problems with the setup, don&#8217;t hesitate to enable tracing of failed requests. Once you are able to deploy with Visual Studio you are ready to continue&#8230; right? I mean, the MSDeploy command doesn&#8217;t seem too intimidating. After a day and change, I was ready to scream uncle. Until I found this <a href="http://stackoverflow.com/questions/6296669/msdeploy-how-can-i-access-the-command-generated-by-visual-studio" target="_blank">StackOverflow Question</a>, I was unable to figure out the arguments of the command that Visual Studio used to initiate the deployment.</p>
<p>First we have to generate a msdeploy manifest file. An InvokeMethod Activity to call `System.IO.File.WriteAllText` with the following expression</p>
<pre><pre class="brush: vb; title: ; notranslate">String.Format(&quot;&lt;?xml version=&quot;&quot;1.0&quot;&quot; encoding=&quot;&quot;utf-8&quot;&quot;?&gt;&quot; _
    &amp; &quot;&lt;sitemanifest&gt;&quot; _
        &amp; &quot;&lt;contentPath path=&quot;&quot;{0}\{1}&quot;&quot; /&gt;&quot; _
        &amp; &quot;&lt;setAcl path=&quot;&quot;{0}\{1}&quot;&quot; setAclResourceType=&quot;&quot;Directory&quot;&quot; /&gt;&quot; _
        &amp; &quot;&lt;setAcl path=&quot;&quot;{0}\{1}&quot;&quot; setAclUser=&quot;&quot;anonymousAuthenticationUser&quot;&quot; &quot; _
            &amp; &quot;setAclResourceType=&quot;&quot;Directory&quot;&quot; /&gt;&quot; _
    &amp;&quot;&lt;/sitemanifest&gt;&quot;, _
    websitePublishDirectoryPath, ciMSDeployWebProject)</pre></pre>
<p>Finally we can execute MSDeploy with an InvokeProcess Activity and the following arguments.</p>
<pre><pre class="brush: vb; title: ; notranslate">String.Format(&quot;-source:manifest='{0}'&quot; _
              &amp; &quot; -dest:auto,ComputerName='{1}?site={2}',UserName='{3}',Password='{4}',IncludeAcls='False',AuthType='Basic'&quot; _
              &amp; &quot; -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension&quot; _
              &amp; &quot; -setParam:kind='ProviderPath',scope='contentPath',match='^{5}\\{6}$',value='{2}'&quot; _
              &amp; &quot; -setParam:kind='ProviderPath',scope='setAcl',match='^{5}\\{6}$',value='{2}' -allowUntrusted&quot;, _
              msDeployManifestFilePath, ciMSDeployWebService, ciMSDeployWebApplicationName, _
              ciMSDeployUsername, ciMSDeployPassword, _
              websitePublishDirectoryPath.Replace(&quot;\&quot;, &quot;\\&quot;).Replace(&quot; &quot;, &quot;\ &quot;).Replace(&quot;.&quot;, &quot;\.&quot;), _
              ciMSDeployWebProject.Replace(&quot; &quot;, &quot;\ &quot;).Replace(&quot;.&quot;, &quot;\.&quot;))</pre></pre>
<h5>Configure and Queue the Build</h5>
<p>We can finally see the light at the end of the tunnel here. Since we provided the metadata for our arguments, we get a rather impressive display of customization.</p>
<p><a href="http://www.justaprogrammer.net/wp-content/uploads/2011/10/2011-10-27_2058.png"><img src="http://www.justaprogrammer.net/wp-content/uploads/2011/10/2011-10-27_2058-300x257.png" alt="" title="Build Process Parameters" width="300" height="257" class="aligncenter size-medium wp-image-1128" /></a></p>
<p>Queue up your build and hopefully you wont have to do too much debugging to get this to work for yourself.</p>
<h5>Conclusion</h5>
<p>After seeing this work, it was all worth it. Of course, this is all very custom, I have my xaml attached here as an example, but you will have to be prepared to work with it to make it work for you. Drop me a line, I&#8217;ll help you out if I can.</p>
<p><a href="http://www.mediafire.com/file/uvd8kcaa0pm8gro/ContinuousIntegrationTemplate.zip" title="ContinuousIntegrationTemplate.zip" target="_blank">ContinuousIntegrationTemplate.zip</a></p>

]]></content:encoded>
			<wfw:commentRss>http://www.justaprogrammer.net/2011/10/27/continuous-integration-with-tfs2010-msdeploy-vsdbcmd/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>YUI&#8217;s CompressorTask with MSBuild and Visual Studio</title>
		<link>http://www.justaprogrammer.net/2011/09/24/yuis-compressortask-with-msbuild-and-visual-studio/</link>
		<comments>http://www.justaprogrammer.net/2011/09/24/yuis-compressortask-with-msbuild-and-visual-studio/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 07:25:21 +0000</pubDate>
		<dc:creator>Stanley</dc:creator>
				<category><![CDATA[Just A Programmer]]></category>
		<category><![CDATA[MSBuild]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[YUICompressor]]></category>

		<guid isPermaLink="false">http://www.justaprogrammer.net/?p=872</guid>
		<description><![CDATA[While trying to integrate YUI Compressor as a build task in my current project&#8230; http://yuicompressor.codeplex.com/documentation Post Build Event: I got the error: It seems that the spaces in the folder path are preventing me from enjoying YUI Compressor. Quite the same problem this person is having: MSDN Forums: Unable to correctly pass parameters to MS [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.justaprogrammer.net%252F2011%252F09%252F24%252Fyuis-compressortask-with-msbuild-and-visual-studio%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2Fp732Nd%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22YUI%27s%20CompressorTask%20with%20MSBuild%20and%20Visual%20Studio%22%20%7D);"></div>
<p>While trying to integrate YUI Compressor as a build task in my current project&#8230;</p>
<p><a href="http://yuicompressor.codeplex.com/documentation" target="_blank">http://yuicompressor.codeplex.com/documentation</a></p>
<p>Post Build Event:</p>
<pre>
<pre class="brush: plain; title: ; notranslate">
$(MSBuildBinPath)\msbuild.exe &quot;$(SolutionDir)MinificationSettings.xml&quot; /property:SourceLocation=$(ProjectDir) /p:JavaScriptOutputFile=$(ProjectDir)ContentMin\Scripts\Example.min.js /p:CssOutputFile=$(ProjectDir)ContentMin\CSS\Site.min.css
</pre>
</pre>
<p>I got the error:</p>
<pre>
<pre class="brush: plain; title: ; notranslate">
MSBUILD : error MSB1008: Only one project can be specified.

C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe &quot;c:\users\spade\documents\visual studio 2010\Projects\ExampleYUICompressorTask\MinificationSettings.xml&quot;
    /p:SourceLocation=c:\users\spade\documents\visual studio 2010\Projects\ExampleYUICompressorTask\MVCExample\
    /p:JavaScriptOutputFile=c:\users\spade\documents\visual studio 2010\Projects\ExampleYUICompressorTask\MVCExample\ContentMin\Scripts\Example.min.js
    /p:CssOutputFile=c:\users\spade\documents\visual studio 2010\Projects\ExampleYUICompressorTask\MVCExample\ContentMin\CSS\Site.min.css
</pre>
</pre>
<p>It seems that the spaces in the folder path are preventing me from enjoying YUI Compressor. Quite the same problem this person is having: <a href="http://social.msdn.microsoft.com/Forums/en-AU/msbuild/thread/8f4418dc-92e0-4b9c-b6ff-a9503049c413" title="MSDN Forums: Unable to correctly pass parameters to MS build" target="_blank">MSDN Forums: Unable to correctly pass parameters to MS build</a>. Although I suspect he gave up a bit too early.</p>
<p>I tried adding quotes around the value of the parameters, you would think this is going to work, it doesn&#8217;t.</p>
<p>Looking for a way to replace the spaces, I came across <a href="http://blogs.msdn.com/b/msbuild/archive/2010/04/02/msbuild-property-functions.aspx" title="MS Build Property Functions" target="_blank">MS Build Property Functions</a>.</p>
<p>With Build Property Functions, it becomes possible to run the simple replace command in all the spots where I need to, my first guess was to replace space with &#8216;%20&#8242;. That had mixed results, so I was left with choosing an arbitrary token for replacement.</p>
<p>Post Build Event:</p>
<pre>
<pre class="brush: plain; title: ; notranslate">
$(MSBuildBinPath)\msbuild.exe &quot;$(SolutionDir)MinificationSettings.xml&quot;
    /p:SourceLocation=$(ProjectDir.Replace(&quot; &quot;, &quot;[[REPLACESPACE]])
    /p:JavaScriptOutputFile=$(ProjectDir.Replace(&quot; &quot;, &quot;[[REPLACESPACE]])ContentMin\Scripts\Example.min.js
    /p:CssOutputFile=$(ProjectDir.Replace(&quot; &quot;, &quot;[[REPLACESPACE]])ContentMin\CSS\Site.min.css
</pre>
</pre>
<p>MinificationSettings.Xml:</p>
<pre>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;Project xmlns=&quot;http://schemas.microsoft.com/developer/MsBuild/2003&quot;&gt;
  &lt;UsingTask
      TaskName=&quot;CompressorTask&quot;
      AssemblyFile=&quot;packages\YUICompressor.NET-MsBuild-Task.1.6.0.2\lib\NET35\Yahoo.Yui.Compressor.MsBuildTask.dll&quot; /&gt;

  &lt;PropertyGroup&gt;
    &lt;CssOutputFile Condition=&quot; '$(CssOutputFile)'=='' &quot;&gt;SylesSheetFinal.css&lt;/CssOutputFile&gt;
    &lt;JavaScriptOutputFile Condition=&quot; '$(JavaScriptOutputFile)'=='' &quot;&gt;JavaScriptFinal.js&lt;/JavaScriptOutputFile&gt;
  &lt;/PropertyGroup&gt;

  &lt;PropertyGroup&gt;
    &lt;CssOutputFileFix&gt;$(CssOutputFile.Replace('[[REPLACESPACE]]', ' '))&lt;/CssOutputFileFix&gt;
    &lt;JavaScriptOutputFileFix&gt;$(JavaScriptOutputFile.Replace('[[REPLACESPACE]]', ' '))&lt;/JavaScriptOutputFileFix&gt;
  &lt;/PropertyGroup&gt;

  &lt;Target Name=&quot;MyTaskTarget&quot;&gt;
    &lt;ItemGroup&gt;

      &lt;JavaScriptFiles Include=&quot;$(SourceLocation.Replace('[[REPLACESPACE]]', ' '))Content\Scripts\Example.js&quot;/&gt;
	  &lt;CssFiles Include=&quot;$(SourceLocation.Replace('[[REPLACESPACE]]', ' '))Content\CSS\Site.css&quot;/&gt;

    &lt;/ItemGroup&gt;
    &lt;CompressorTask
        CssFiles=&quot;@(CssFiles)&quot;
        DeleteCssFiles=&quot;false&quot;
        CssOutputFile=&quot;$(CssOutputFileFix)&quot;
        CssCompressionType=&quot;YuiStockCompression&quot;
        JavaScriptFiles=&quot;@(JavaScriptFiles)&quot;
        ObfuscateJavaScript=&quot;True&quot;
        PreserveAllSemicolons=&quot;False&quot;
        DisableOptimizations=&quot;Nope&quot;
        EncodingType=&quot;Default&quot;
        DeleteJavaScriptFiles=&quot;false&quot;
        LineBreakPosition=&quot;-1&quot;
        JavaScriptOutputFile=&quot;$(JavaScriptOutputFileFix)&quot;
        LoggingType=&quot;ALittleBit&quot;
        ThreadCulture=&quot;en-au&quot;
        IsEvalIgnored=&quot;false&quot;
            /&gt;
  &lt;/Target&gt;
&lt;/Project&gt;
</pre>
</pre>
<p><a href="http://www.mediafire.com/file/ir5937a6r6ejpa6/ExampleYUICompressorTask.zip" title="Source: Example YUI CompressorTask" target="_blank">Source Code</a></p>

]]></content:encoded>
			<wfw:commentRss>http://www.justaprogrammer.net/2011/09/24/yuis-compressortask-with-msbuild-and-visual-studio/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Visual Studio, Line Numbers and Ankhsvn</title>
		<link>http://www.justaprogrammer.net/2011/01/30/visual-studio-line-numbers-and-anhksvn/</link>
		<comments>http://www.justaprogrammer.net/2011/01/30/visual-studio-line-numbers-and-anhksvn/#comments</comments>
		<pubDate>Sun, 30 Jan 2011 21:29:10 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[Just A Programmer]]></category>
		<category><![CDATA[Anhksvn]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.justaprogrammer.net/?p=414</guid>
		<description><![CDATA[Although I am a git and DVCS true believer, I still deal with SVN. In Visual Studio this usually means I use AnkhSVN. For anyone paying for the VisualSVN client, I really think you should evaluate this tool. Its Visual Studio Integration is superb and I&#8217;ve had no usability problems in recent versions. One thing [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.justaprogrammer.net%252F2011%252F01%252F30%252Fvisual-studio-line-numbers-and-anhksvn%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2FezmKV1%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Visual%20Studio%2C%20Line%20Numbers%20and%20Ankhsvn%22%20%7D);"></div>
<p>Although I am a git and DVCS true believer, I still deal with SVN. In Visual Studio this usually means I use <a href="http://ankhsvn.open.collab.net/">AnkhSVN</a>. For anyone paying for the <a href="http://www.visualsvn.com/visualsvn/">VisualSVN client</a>, I really think you should evaluate this tool. Its Visual Studio Integration is superb and I&#8217;ve had no usability problems in recent versions.</p>
<p>One thing about it annoyed me was caused by it integrating too well with Visual Studio. That problem was it is the display of line numbers on the editor screen. I setup Visual Studio to display line numbers in editor windows, and this has the side effect of displaying line numbers in the log message editor of the commit screen. I find this annoying. I don&#8217;t need line numbers for my commit log files and they take up precious screen real estate.</p>
<p><a href="http://www.justaprogrammer.net/wp-content/uploads/2011/01/Commit-to-Subversion_LineNumbers1.png"><img class="alignnone size-full wp-image-453" title="Commit to Subversion With Line Numbers" src="http://www.justaprogrammer.net/wp-content/uploads/2011/01/Commit-to-Subversion_LineNumbers1.png" alt="Commit to Subversion With Line Numbers" width="850" height="660" /></a></p>
<p>Luckily I found a solution. Apparently, in the current version of AnkhSVN, the commit editor has its own section in the Visual Studio Text editor options. So turning off the line numbers on the commit screen, but not the other editor screens can be done from the Tools | Options menu.</p>
<div id="attachment_451" class="wp-caption alignnone" style="width: 860px"><a href="http://www.justaprogrammer.net/wp-content/uploads/2011/01/Options_TextEditor_General.png"><img class="size-full wp-image-451" title="General text editor options" src="http://www.justaprogrammer.net/wp-content/uploads/2011/01/Options_TextEditor_General.png" alt="Options|TextEditor|General" width="850" height="566" /></a><p class="wp-caption-text">Options|TextEditor|General</p></div>
<div id="attachment_450" class="wp-caption alignnone" style="width: 860px"><a href="http://www.justaprogrammer.net/wp-content/uploads/2011/01/Options_TextEditor_LogMessages.png"><img class="size-full wp-image-450" title="Log Messages text editor options" src="http://www.justaprogrammer.net/wp-content/uploads/2011/01/Options_TextEditor_LogMessages.png" alt="Options|TextEditor|Log Messages (AnkhSVN)" width="850" height="566" /></a><p class="wp-caption-text">Options|TextEditor|Log Messages (AnkhSVN)</p></div>
<p>After that, the line numbers disappear in the commit dialog.</p>
<p><a href="http://www.justaprogrammer.net/wp-content/uploads/2011/01/Commit-to-Subversion_SansLineNumbers.png"><img class="alignnone size-full wp-image-452" title="Commit to Subversion Sans Line Numbers" src="http://www.justaprogrammer.net/wp-content/uploads/2011/01/Commit-to-Subversion_SansLineNumbers.png" alt="Commit to Subversion Sans Line Numbers" width="850" height="660" /></a></p>
<p>Its the little things like this that make a software experience truly great.</p>

]]></content:encoded>
			<wfw:commentRss>http://www.justaprogrammer.net/2011/01/30/visual-studio-line-numbers-and-anhksvn/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using the registry to resolve Visual Studio reference paths.</title>
		<link>http://www.justaprogrammer.net/2010/01/28/using-the-registry-to-resolve-visual-studio-reference-paths/</link>
		<comments>http://www.justaprogrammer.net/2010/01/28/using-the-registry-to-resolve-visual-studio-reference-paths/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 14:01:13 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[Just A Programmer]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[MSBuild]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.justaprogrammer.net/?p=88</guid>
		<description><![CDATA[Note: To skip the long journey of what lead me to figuring this out, click here to go to the howto. Recently I was asked to look at a fiddler plugin Stan, the founder of this blog, was developing. He gave me a SVN path and asked me to build it and test it. So [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwww.justaprogrammer.net%252F2010%252F01%252F28%252Fusing-the-registry-to-resolve-visual-studio-reference-paths%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Using%20the%20registry%20to%20resolve%20Visual%20Studio%20reference%20paths.%22%20%7D);"></div>
<p><strong>Note:</strong> To skip the long journey of what lead me to figuring this out, <a href="#howto">click here to go to the howto</a>.</p>
<p>Recently I was asked to look at a fiddler plugin Stan, the founder of this blog, was developing. He gave me a SVN path and asked me to build it and test it.</p>
<p>So I checked out the source code and hit F5. I got a bunch of compiler errors relating to the fact that I didn&#8217;t have fiddler installed. I rectified that matter and still got errors. The problem was that the hintpath of fiddler.exe was wrong. On my machine, Fiddler is installed in &#8216;C:\Program Files\Fiddler2\&#8217;, while on Stan&#8217;s machine it is installed to &#8216;C:\Program Files <strong>(x86)</strong>\Fiddler2&#8242;. I consulted the mighty google, which led me to a <a href="http://stackoverflow.com/questions/462564/hintpath-on-a-added-reference-in-visual-studio">stackoverflow question</a>. The question pointed out that you can have multiple hintpaths to an assembly. However, I wanted a better solution. What if someone installed Fiddler to a custom location?</p>
<p>I got the idea of using the registry. Fiddler has an installer. Surely the installer records its install location to the registry. It does in &#8216;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fiddler2&#8242; (Apparently fiddler is written by a Microsoft Employee). So the question is how to get MSBuild, the tool that visual studio uses to parse project files, to read a value from the registry.</p>
<p>The answer was found in a <a href="http://blogs.msdn.com/msbuild/archive/2007/05/04/new-registry-syntax-in-msbuild-v3-5.aspx">post</a> on the MSBuild team blog.</p>
<p><a name="howto"></a></p>
<h2>How To</h2>
<p>Unfortunately, Visual Studio does not allow you to edit hintpaths to referenced assemblies. So you&#8217;re going to have to edit your vcproj or vbproj file in notepad or some other text editor.  Here are the steps:</p>
<ol>
<li>Open the project file in your text editor.</li>
<li>Look for the &lt;Reference/&gt; element for fiddler.exe. It should look similar to this:<br />
<blockquote><p>
&lt;Reference Include=&#8221;Fiddler, Version=2.2.7.5, Culture=neutral, processorArchitecture=MSIL&#8221;&gt;<br/><br />
&lt;SpecificVersion&gt;False&lt;/SpecificVersion&gt;<br/><br />
&lt;HintPath&gt;C:\Program Files\Fiddler.exe&lt;/HintPath&gt;<br/><br />
&lt;Private&gt;False&lt;/Private&gt;<br/><br />
&lt;/Reference&gt;<br/>
</p></blockquote>
</li>
<li>Change the hintpath as follows:<br />
<blockquote><p>
&lt;Reference Include=&#8221;Fiddler, Version=2.2.7.5, Culture=neutral, processorArchitecture=MSIL&#8221;&gt;<br />
&lt;SpecificVersion&gt;False&lt;/SpecificVersion&gt;<br />
&lt;HintPath&gt;$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fiddler2@InstallPath)\Fiddler.exe&lt;/HintPath&gt;<br />
&lt;Private&gt;False&lt;/Private&gt;<br />
&lt;/Reference&gt;
</p></blockquote>
</li>
<li>Save the file</li>
<li>Visual studio will detect the file change and ask you to reload the file. If you are using <a href="http://www.icsharpcode.net/OpenSource/SD/">SharpDevelop</a> as you&#8217;re IDE, you will have to close and reopen the solution.</li>
</ol>
<p>Thats all there is to it. Happy coding!</p>

]]></content:encoded>
			<wfw:commentRss>http://www.justaprogrammer.net/2010/01/28/using-the-registry-to-resolve-visual-studio-reference-paths/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

