﻿<?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; MSBuild</title>
	<atom:link href="http://www.justaprogrammer.net/tag/msbuild/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>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>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>

