﻿<?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; HowTo</title>
	<atom:link href="http://www.justaprogrammer.net/tag/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.justaprogrammer.net</link>
	<description>We're Just Programmers...</description>
	<lastBuildDate>Sat, 03 Jul 2010 17:15:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<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>0</slash:comments>
		</item>
	</channel>
</rss>
