<?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>Development in a Blink &#187; F#</title>
	<atom:link href="http://www.dougfinke.com/blog/index.php/category/f/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dougfinke.com/blog</link>
	<description>Researching the optimal; implementing the practical</description>
	<lastBuildDate>Fri, 03 May 2013 19:47:05 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Calling Excel Math Functions From PowerShell</title>
		<link>http://www.dougfinke.com/blog/index.php/2011/04/05/calling-excel-math-functions-from-powershell/</link>
		<comments>http://www.dougfinke.com/blog/index.php/2011/04/05/calling-excel-math-functions-from-powershell/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 01:19:04 +0000</pubDate>
		<dc:creator>Doug Finke</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.dougfinke.com/blog/index.php/2011/04/05/calling-excel-math-functions-from-powershell/</guid>
		<description><![CDATA[I came across this post Calling Excel Math Functions From F# FSI and figured it would be very useful to do from PowerShell. This can also be done a line at a time in the PowerShell command line REPL (Read Eval Print Loop). Meaning, you can create different arrays and multidimensional arrays at the command [...]]]></description>
				<content:encoded><![CDATA[<p>I came across this post <a href="http://blogs.msdn.com/b/jackhu/archive/2011/04/05/using-excel-math-functions-from-f-fsi.aspx">Calling Excel Math Functions From F# FSI</a> and figured it would be very useful to do from PowerShell.</p>
<p>This can also be done a line at a time in the PowerShell command line REPL (Read Eval Print Loop). Meaning, you can create different arrays and multidimensional arrays at the command line and then type and call the Excel functions.</p>
<p>Plus, these are only 4 of the many Excel functions available.</p>
<p>If you want to find out the other Excel math functions available, type this line at the command line (run the first three lines of code up to the WorksheetFunction first):</p>
<p><em>$wf | Get-Member -MemberType method | Out-GridView</em></p>
<pre class="PowerShellColorizedScript" style="width: 454px; height: 430px;"><span style="color: #006400;"># Calling Excel Math Functions From PowerShell</span>            

<span style="color: #ff4500;">$xl</span>        <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">New-Object</span> <span style="color: #000080;">-ComObject</span> <span style="color: #8a2be2;">Excel.Application</span>
<span style="color: #ff4500;">$xlprocess</span> <span style="color: #a9a9a9;">=</span> <span style="color: #0000ff;">Get-Process</span> <span style="color: #8a2be2;">excel</span>            

<span style="color: #ff4500;">$wf</span>   <span style="color: #a9a9a9;">=</span> <span style="color: #ff4500;">$xl</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">WorksheetFunction</span>
<span style="color: #ff4500;">$data</span> <span style="color: #a9a9a9;">=</span> <span style="color: #800080;">1</span><span style="color: #a9a9a9;">,</span><span style="color: #800080;">2</span><span style="color: #a9a9a9;">,</span><span style="color: #800080;">3</span><span style="color: #a9a9a9;">,</span><span style="color: #800080;">4</span>
<span style="color: #ff4500;">$m</span>    <span style="color: #a9a9a9;">=</span> <span style="color: #000000;">(</span><span style="color: #000000;">(</span><span style="color: #800080;">1</span><span style="color: #a9a9a9;">,</span><span style="color: #800080;">2</span><span style="color: #a9a9a9;">,</span><span style="color: #800080;">3</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">,</span><span style="color: #000000;">(</span><span style="color: #800080;">4</span><span style="color: #a9a9a9;">,</span><span style="color: #800080;">5</span><span style="color: #a9a9a9;">,</span><span style="color: #800080;">6</span><span style="color: #000000;">)</span><span style="color: #a9a9a9;">,</span><span style="color: #000000;">(</span><span style="color: #800080;">7</span><span style="color: #a9a9a9;">,</span><span style="color: #800080;">8</span><span style="color: #a9a9a9;">,</span><span style="color: #800080;">9</span><span style="color: #000000;">)</span><span style="color: #000000;">)</span>            

<span style="color: #0000ff;">Write-Host</span> <span style="color: #000080;">-ForegroundColor</span> <span style="color: #8a2be2;">green</span> <span style="color: #8a2be2;">Median</span>
<span style="color: #ff4500;">$wf</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Median</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$data</span><span style="color: #000000;">)</span>            

<span style="color: #0000ff;">Write-Host</span> <span style="color: #000080;">-ForegroundColor</span> <span style="color: #8a2be2;">green</span> <span style="color: #8a2be2;">StDev</span>
<span style="color: #ff4500;">$wf</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">StDev</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$data</span><span style="color: #000000;">)</span>            

<span style="color: #0000ff;">Write-Host</span> <span style="color: #000080;">-ForegroundColor</span> <span style="color: #8a2be2;">green</span> <span style="color: #8a2be2;">Var</span>
<span style="color: #ff4500;">$wf</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">Var</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$data</span><span style="color: #000000;">)</span>            

<span style="color: #0000ff;">Write-Host</span> <span style="color: #000080;">-ForegroundColor</span> <span style="color: #8a2be2;">green</span> <span style="color: #8a2be2;">MInverse</span>
<span style="color: #ff4500;">$wf</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">MInverse</span><span style="color: #000000;">(</span><span style="color: #ff4500;">$m</span><span style="color: #000000;">)</span>            

<span style="color: #ff4500;">$xl</span><span style="color: #a9a9a9;">.</span><span style="color: #000000;">quit</span><span style="color: #000000;">(</span><span style="color: #000000;">)</span>
<span style="color: #ff4500;">$xlprocess</span> <span style="color: #a9a9a9;">|</span> <span style="color: #0000ff;">kill</span></pre>
<pre class="PowerShellColorizedScript" style="width: 237px; height: 327px;"><span style="color: #006400;"># Results</span>
<span style="color: #8b0000;"><span style="color: #80ff00;"><span style="color: #008000;">Median</span>
</span>2.5
<span style="color: #008000;">StDev</span>
1.29099444873581
<span style="color: #008000;">Var</span>
1.66666666666667
<span style="color: #008000;">MInverse</span>
-4.5035996273705E+15
9.00719925474099E+15
-4.5035996273705E+15
9.007199254741E+15
-1.8014398509482E+16
9.00719925474099E+15
-4.5035996273705E+15
9.00719925474099E+15
-4.5035996273705E+15</span></pre>
<h3>Grab the Code</h3>
<p>I put the code up on my <a href="https://github.com/dfinke/powershell/blob/master/Calling%20Excel%20Functions%20From%20PowerShell/Invoke-ExcelFunction.ps1">GitHub PowerShell Repository</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dougfinke.com/blog/index.php/2011/04/05/calling-excel-math-functions-from-powershell/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PowerShell Inside of Visual Studio &#8211; NuGet (formerly known as NuPack)</title>
		<link>http://www.dougfinke.com/blog/index.php/2010/10/29/powershell-inside-of-visual-studio-nuget-formerly-known-as-nupack/</link>
		<comments>http://www.dougfinke.com/blog/index.php/2010/10/29/powershell-inside-of-visual-studio-nuget-formerly-known-as-nupack/#comments</comments>
		<pubDate>Fri, 29 Oct 2010 19:22:36 +0000</pubDate>
		<dc:creator>Doug Finke</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[NuPack]]></category>
		<category><![CDATA[PDC10]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>

		<guid isPermaLink="false">http://www.dougfinke.com/blog/index.php/2010/10/29/powershell-inside-of-visual-studio-nuget-formerly-known-as-nupack/</guid>
		<description><![CDATA[Scott Hanselman demoed the PowerShell Package Manager at PDC10. PowerShell inside Visual Studio 2010 That’s right, PowerShell inside Visual Studio 2010. Interesting possibilities. He also demoed (code that won’t will be shipped) where he worked Visual Studio like a puppet on strings from the PowerShell console. Again, interesting possibilities. NuPack is a free, open source [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.hanselman.com/blog/">Scott Hanselman</a> demoed the PowerShell Package Manager at <a href="http://player.microsoftpdc.com/Session/e0c3ce51-9869-456c-a197-63dc0283f57e">PDC10</a>. </p>
<h3>PowerShell inside Visual Studio 2010</h3>
<p>That’s right, PowerShell inside Visual Studio 2010. Interesting possibilities. He also demoed (code that <strike>won’t</strike> <em>will</em> be shipped) where he worked Visual Studio like a puppet on strings from the PowerShell console. Again, interesting possibilities.</p>
<p><a href="http://nupack.codeplex.com/">NuPack</a> is a free, open source developer focused package management system for the .NET platform. I’ve blogged on NuPack and Power Console. PowerConsole has been re-released as part of NuPack.</p>
<ul>
<li><a href="http://www.dougfinke.com/blog/index.php/2010/10/21/check-available-net-packages-without-nupack-installed/">Check Available .NET Packages without NuPack Installed</a> </li>
<li><a href="http://www.dougfinke.com/blog/index.php/2010/10/06/nupack-open-source-package-manager-for-net-includes-a-powershell-interface/">NuPack &#8211; Open Source Package Manager for .NET &#8211; Includes a PowerShell Interface</a> </li>
<li><a href="http://www.dougfinke.com/blog/index.php/2010/05/16/visual-studio-keymaps-using-powershell/">Visual Visual Studio Keymaps using PowerShell</a> </li>
<li><a href="http://www.dougfinke.com/blog/index.php/2010/05/16/accessing-visual-studios-automation-api-from-powershell/">Accessing Visual Studio’s Automation API From PowerShell</a> </li>
<li><a href="http://www.dougfinke.com/blog/index.php/2010/04/02/powershell-and-f-consoles-in-visual-studio-2010/">PowerShell and F# Consoles in Visual Studio 2010</a> </li>
<li><a href="http://www.dougfinke.com/blog/index.php/2010/03/14/powerconsole-powershell-integrated-with-visual-studio-2010/">PowerConsole &#8211; PowerShell Integrated with Visual Studio 2010</a> </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.dougfinke.com/blog/index.php/2010/10/29/powershell-inside-of-visual-studio-nuget-formerly-known-as-nupack/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How To Load .NET Assemblies In A PowerShell Session</title>
		<link>http://www.dougfinke.com/blog/index.php/2010/08/29/how-to-load-net-assemblies-in-a-powershell-session/</link>
		<comments>http://www.dougfinke.com/blog/index.php/2010/08/29/how-to-load-net-assemblies-in-a-powershell-session/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 17:08:00 +0000</pubDate>
		<dc:creator>Doug Finke</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Add-Type]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[DLL]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[JScript]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VB.Net]]></category>
		<category><![CDATA[Visual Basic]]></category>

		<guid isPermaLink="false">http://www.dougfinke.com/blog/index.php/2010/08/29/how-to-load-net-assemblies-in-a-powershell-session/</guid>
		<description><![CDATA[PowerShell is built on top of .NET. This allows you to tap into the power of the .NET framework as well as any DLLs/Assemblies you build. In version 2 of PowerShell the Add-type cmdlet was added which is the preferred way to load .NET assemblies. In PowerShell Version 1 that cmdlet is not available so [...]]]></description>
				<content:encoded><![CDATA[<p>PowerShell is built on top of .NET. This allows you to tap into the power of the .NET framework as well as any DLLs/Assemblies you build. In version 2 of PowerShell the <em><strong>Add-type</strong></em> cmdlet was added which is the preferred way to load .NET assemblies. </p>
<p>In PowerShell Version 1 that cmdlet is not available so you need to use the one of the Load* static methods found in System.Reflection.Assembly.</p>
<table border="0" cellspacing="0" cellpadding="2" width="565">
<tbody>
<tr>
<td valign="top" width="200"><span style="color: #008080">[Reflection.Assembly]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">Load</span></td>
<td valign="top" width="363">
<p>Loads an assembly</p>
</td>
</tr>
<tr>
<td valign="top" width="200"><span style="color: #008080">[Reflection.Assembly]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">LoadFile</span></td>
<td valign="top" width="363">Loads the contents of an assembly file on the specified path</td>
</tr>
<tr>
<td valign="top" width="200"><span style="color: #008080">[Reflection.Assembly]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">LoadFrom</span> </td>
<td valign="top" width="363">Loads an assembly given its file name or path</td>
</tr>
<tr>
<td valign="top" width="200"><span style="color: #008080">[Reflection.Assembly]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">LoadWithPartialName</span></td>
<td valign="top" width="363">Loads an assembly from the application directory or from the global assembly cache using a partial name</td>
</tr>
</tbody>
</table>
<h3>Why?</h3>
<p>For example, in PowerShell, if you want to encode a Url you can use the UrlEncode method found in the .NET HttpUtility Class.</p>
<p>If you fire up PowerShell and try to call the static method UrlEncode found in System.Web.HttpUtility you’ll get this error.</p>
<pre class="PowerShellColorizedScript"><span style="color: #008080">[System.Web.HttpUtility]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">UrlEncode</span><span style="color: #000000">(</span><span style="color: #8b0000">&quot;this is a test&quot;</span><span style="color: #000000">)</span></pre>
<p><font color="#ff0000">Unable to find type [System.Web.HttpUtility]: make sure that the assembly containing this type is loaded.</font></p>
<p><font color="#000000">You can solve this by loading the System.Web .NET assembly. This is equivalent to being in the Visual Studio IDE, adding a reference and then adding a using statement.</font></p>
<h3>Using Reflection.Assembly in PowerShell Version 1</h3>
<p><font color="#ff0000"></font></p>
<pre class="PowerShellColorizedScript"><span style="color: #008080">[Reflection.Assembly]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">LoadFile</span><span style="color: #000000">(</span> <span style="color: #000000">`
</span>  <span style="color: #8b0000">'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.dll'</span><span style="color: #000000">)</span><span style="color: #000000">`
</span>  <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">out-null</span>            
              
<span style="color: #008080">[System.Web.HttpUtility]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">UrlEncode</span><span style="color: #000000">(</span><span style="color: #8b0000">&quot;this is a test&quot;</span><span style="color: #000000">)</span></pre>
<h3>Using Add-Type in PowerShell Version 2</h3>
<pre class="PowerShellColorizedScript"><span style="color: #0000ff">Add-Type</span> <span style="color: #000080">-AssemblyName</span> <span style="color: #8a2be2">System.Web</span>            
<span style="color: #008080">[System.Web.HttpUtility]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">UrlEncode</span><span style="color: #000000">(</span><span style="color: #8b0000">&quot;this is a test&quot;</span><span style="color: #000000">)</span></pre>
<h3>Additional Reflection.Assembly usage</h3>
<pre style="width: 559px; height: 93px" class="PowerShellColorizedScript"><span style="color: #008080">[void]</span> <span style="color: #008080">[Reflection.Assembly]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">LoadWithPartialName</span><span style="color: #000000">(</span><span style="color: #8b0000">&quot;System.Windows.Forms&quot;</span><span style="color: #000000">)</span>
<span style="color: #008080">[reflection.assembly]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">Load</span><span style="color: #000000">(</span><span style="color: #8b0000">&quot;mscorlib.dll&quot;</span><span style="color: #000000">)</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">Out-Null</span>
<span style="color: #008080">[void]</span><span style="color: #008080">[system.reflection.assembly]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">loadfrom</span><span style="color: #000000">(</span><span style="color: #8b0000">&quot;c:\windows\system32\inetsrv\microsoft.web.administration.dll&quot;</span><span style="color: #000000">)</span></pre>
<h3>Additional Add-Type usage</h3>
<pre style="width: 565px; height: 54px" class="PowerShellColorizedScript"><span style="color: #0000ff">Add-Type</span> <span style="color: #000080">-AssemblyName</span> <span style="color: #8b0000">&quot;System.Windows.Forms&quot;</span>
<span style="color: #0000ff">Add-Type</span> <span style="color: #000080">-AssemblyName</span> <span style="color: #8b0000">&quot;mscorlib.dll&quot;</span>
<span style="color: #0000ff">Add-Type</span> <span style="color: #000080">-Path</span> <span style="color: #8b0000">&quot;c:\windows\system32\inetsrv\microsoft.web.administration.dll&quot;</span></pre>
<h3>Compiling C# on the fly in Version 2</h3>
<pre class="PowerShellColorizedScript"><span style="color: #0000ff">Add-Type</span> <span style="color: #000080">-TypeDefinition</span> <span style="color: #8b0000">@&quot;
public class Test
{
    public static int Add(int n1, int n2)
    {
        return n1 + n2;
    }
}
&quot;@</span></pre>
<p>If you change the <em>signature</em> of the Add method you will get this error:</p>
<p><a href="http://dougfinke.com/uploadPictures/LoadingaDLLintoaPowerShellSession_114E7/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://dougfinke.com/uploadPictures/LoadingaDLLintoaPowerShellSession_114E7/image_thumb.png" width="540" height="18" /></a></p>
<p>When compiling code on the fly or loading assemblies they <em><strong>cannot </strong></em>be unloaded.</p>
<blockquote>
<p>.NET assemblies can&#8217;t be unloaded from a session (it&#8217;s a .NET thing, not a PowerShell thing) therefore DLLs can&#8217;t be unloaded from a session. This means that you can&#8217;t update a DLLs once it&#8217;s been loaded. We can&#8217;t even update the assembly on disk because the file is locked when the assembly is loaded.</p>
<p>- Bruce Payette <strong><a href="http://www.manning.com/payette2/">Windows PowerShell in Action, Second Edition</a></strong></p>
</blockquote>
<h3>Another way to use the –Path parameter on Add-Type</h3>
<p>You can point to a C# source code file directly.</p>
<pre class="PowerShellColorizedScript"><span style="color: #0000ff">Add-Type</span> <span style="color: #000080">–Path</span> <span style="color: #8a2be2">c:\test\Hello.cs</span></pre>
<h3>Add-Type is not limited to compiling only C#</h3>
<p>You can inline these languages using the –Language parameter CSharp, CSharpVersion3, VisualBasic, JScript.</p>
<p>Notice, F# is not supported. Here is a post <a href="http://www.dougfinke.com/blog/index.php/2010/04/18/how-to-add-an-f-type-to-a-powershell-session/">How to add an F# type to a PowerShell session</a> that inlines F#.</p>
<p><strong>NOTE: </strong>This uses the F# DLLs shipped with .NET 4.0</p>
<pre class="PowerShellColorizedScript"><span style="color: #0000ff">Add-TypeFSharp</span> <span style="color: #000080">-TypeDefinition</span> <span style="color: #8b0000">@&quot;
module MyModule

let Add a b = a + b;;
&quot;@</span>                        

<span style="color: #800080">1</span><span style="color: #a9a9a9">..</span><span style="color: #800080">10</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">%</span> <span style="color: #000000">{</span> <span style="color: #008080">[MyModule]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">Add</span><span style="color: #000000">(</span> <span style="color: #ff4500">$_</span><span style="color: #a9a9a9">,</span> <span style="color: #ff4500">$_</span><span style="color: #a9a9a9">*</span><span style="color: #800080">2</span> <span style="color: #000000">)</span> <span style="color: #000000">}</span></pre>
<h3>Finally</h3>
<p>There are additional parameters that the Add-Type cmdlet supports. You can generate a DLL file for the assembly with the specified name in the location, specify compiler parameters, specify assemblies which your code depends on and use wild cards when loading assemblies.</p>
<p>Check out the <a href="http://technet.microsoft.com/en-us/library/dd315241.aspx">online help for Add-Type</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dougfinke.com/blog/index.php/2010/08/29/how-to-load-net-assemblies-in-a-powershell-session/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Accessing Visual Studio&#8217;s Automation API From PowerShell</title>
		<link>http://www.dougfinke.com/blog/index.php/2010/05/16/accessing-visual-studios-automation-api-from-powershell/</link>
		<comments>http://www.dougfinke.com/blog/index.php/2010/05/16/accessing-visual-studios-automation-api-from-powershell/#comments</comments>
		<pubDate>Sun, 16 May 2010 18:44:25 +0000</pubDate>
		<dc:creator>Doug Finke</dc:creator>
				<category><![CDATA[DTE]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[PowerConsole]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>
		<category><![CDATA[Visual Studio Automation]]></category>
		<category><![CDATA[VS 2010]]></category>

		<guid isPermaLink="false">http://dougfinke.com/blog/index.php/2010/05/16/accessing-visual-studios-automation-api-from-powershell/</guid>
		<description><![CDATA[Kurt Schelfthout blogs Accessing Visual Studio&#8217;s Automation API from F# Interactive and reasons: Because why anyone would want to write VBA in the Visual Studio macro editor is beyond me. I agree! Kurt lays out&#160; the &#8220;how to&#8221; for injecting the Visual Studio&#8217;s DTE object (Development Tools Extensibility) into the F# console. He also provides [...]]]></description>
				<content:encoded><![CDATA[<p>Kurt Schelfthout blogs <a href="http://fortysix-and-two.blogspot.com/2010/05/accessing-visual-studios-automation-api.html">Accessing Visual Studio&rsquo;s Automation API from F# Interactive</a> and reasons: </p>
<blockquote><p>Because why anyone would want to write VBA in the Visual Studio macro editor is beyond me<font color="#111111">.</font></p>
</blockquote>
<p>I agree!</p>
<p>Kurt lays out&#160; the &ldquo;how to&rdquo; for injecting the Visual Studio&rsquo;s DTE object (Development Tools Extensibility) into the F# console. He also provides the link to <a href="http://msdn.microsoft.com/en-us/library/za2b25t3(v=VS.71).aspx">Visual Studio .NET Automation Object Model</a>.</p>
<h3>PowerShell PowerConsole</h3>
<p>Makes accessing the Automation API simple. It brings the Visual Studio DTE automation object to your finger tips. Check this post for downloading <a href="http://dougfinke.com/blog/index.php/2010/03/14/powerconsole-powershell-integrated-with-visual-studio-2010/">PowerConsole &#8211; PowerShell Integrated with Visual Studio 2010</a>. </p>
<h3>$DTE.Solution.Projects | ForEach {$_.Fullname}</h3>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">PS&gt; $DTE.Solution.Projects | ForEach {$_.Fullname}</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">C:\PoShScripts\NYC Code Camp\CSharp\WPF+PoSh\Simple\Simple.csproj</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">C:\PoShScripts\NYC Code Camp\CSharp\WPF+PoSh\PowerShellExtensions\PowerShellExtensions.csproj</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">C:\PoShScripts\NYC Code Camp\CSharp\WPF+PoSh\HostAndAddVariables\HostAndAddVariables.csproj</pre>
<p><!--CRLF--></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.dougfinke.com/blog/index.php/2010/05/16/accessing-visual-studios-automation-api-from-powershell/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to add an F# type to a PowerShell session</title>
		<link>http://www.dougfinke.com/blog/index.php/2010/04/18/how-to-add-an-f-type-to-a-powershell-session/</link>
		<comments>http://www.dougfinke.com/blog/index.php/2010/04/18/how-to-add-an-f-type-to-a-powershell-session/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 20:18:27 +0000</pubDate>
		<dc:creator>Doug Finke</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Add-Type]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[JScript]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Visual Basic]]></category>

		<guid isPermaLink="false">http://dougfinke.com/blog/index.php/2010/04/18/how-to-add-an-f-type-to-a-powershell-session/</guid>
		<description><![CDATA[The PowerShell Add-Type cmdlet lets you define a .NET Framework class in your Windows PowerShell session. It supports the following languages CSharp, CSharpVersion3, VisualBasic, JScript. It does not support FSharp directly. No problem Add-Type has a parameter CodeDomProvider and you can pass the FSharpCodeProvider to it (see the function Add-TypeFSharp). Add-TypeFSharp lets you inline F# [...]]]></description>
				<content:encoded><![CDATA[<p>The PowerShell <em><strong>Add-Type</strong></em> cmdlet lets you define a .NET Framework class in your Windows PowerShell session. It supports the following languages CSharp, CSharpVersion3, VisualBasic, JScript. It does not support FSharp directly.</p>
<h3>No problem</h3>
<p>Add-Type has a parameter CodeDomProvider and you can pass the FSharpCodeProvider to it (see the function Add-TypeFSharp).</p>
<p>Add-TypeFSharp lets you inline F# code. </p>
<pre class="PowerShellColorizedScript"><span style="color: #0000ff">Add-TypeFSharp</span> <span style="color: #000080">-TypeDefinition</span> <span style="color: #8b0000">@&quot;
module MyModule

let Add a b = a + b;;
&quot;@</span>            
            
<span style="color: #800080">1</span><span style="color: #a9a9a9">..</span><span style="color: #800080">10</span> <span style="color: #a9a9a9">|</span> <span style="color: #0000ff">%</span> <span style="color: #000000">{</span> <span style="color: #008080">[MyModule]</span><span style="color: #a9a9a9">::</span><span style="color: #000000">Add</span><span style="color: #000000">(</span> <span style="color: #ff4500">$_</span><span style="color: #a9a9a9">,</span> <span style="color: #ff4500">$_</span><span style="color: #a9a9a9">*</span><span style="color: #800080">2</span> <span style="color: #000000">)</span> <span style="color: #000000">}</span></pre>
<p>&#160;<a href="http://dougfinke.com/uploadPictures/HowtoaddanFtypetoaPowerShellsession_D9E2/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://dougfinke.com/uploadPictures/HowtoaddanFtypetoaPowerShellsession_D9E2/image_thumb.png" width="558" height="263" /></a> </p>
<h3>Things TODO</h3>
<ul>
<li>Install .NET 4.0, VS 2010 installs this and the latest F# bits </li>
<li>Download and install <a href="http://fsharppowerpack.codeplex.com/">The F# PowerPack</a> </li>
<li>Update the registry so PowerShell can work with .NET 4.0 </li>
</ul>
<h4>Updating the registry</h4>
<p>This is a bit tricky, thanks to the help of the <a href="https://mvp.support.microsoft.com/communities/mvp.aspx?product=1&amp;competency=PowerShell&amp;page=1">PowerShell MVP community</a> (<a href="http://blogs.microsoft.co.il/blogs/ScriptFanatic/">Shay</a>, <a href="http://www.nivot.org/">OisÃ­n</a>, <a href="http://marcoshaw.blogspot.com/">Marco</a> and <a href="https://mvp.support.microsoft.com/profile=6D90E2F1-24FE-4818-9FB3-D1B4F336C887">Vadims</a>)on getting this to work. </p>
<p>Before you are allowed to edit this entry, you need to change the permissions on that key and take full ownership.</p>
<p>Then change the <em><strong>RuntimeVersion</strong></em> value, under the following key, to <strong>v4.0.30319</strong>.</p>
<p><font size="2" face="Courier New">HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine</font></p>
<h3>Function Add-TypeFSharp</h3>
<pre class="PowerShellColorizedScript"><span style="color: #00008b">Function</span> <span style="color: #8a2be2">Add-TypeFSharp</span> <span style="color: #000000">{</span>            
    <span style="color: #00008b">param</span><span style="color: #000000">(</span>            
        <span style="color: #008080">[string]</span><span style="color: #ff4500">$TypeDefinition</span>                    
    <span style="color: #000000">)</span>            
                
    <span style="color: #0000ff">Add-Type</span> <span style="color: #000080">-Path</span> <span style="color: #000000">`
</span>        <span style="color: #8b0000">&quot;C:\Program Files\FSharpPowerPack-1.9.9.9\bin\FSharp.Compiler.CodeDom.dll&quot;</span>            
                
    <span style="color: #ff4500">$provider</span> <span style="color: #a9a9a9">=</span> <span style="color: #0000ff">New-Object</span> <span style="color: #000000">`
</span>        <span style="color: #8a2be2">Microsoft.FSharp.Compiler.CodeDom.FSharpCodeProvider</span>            
                    
    <span style="color: #0000ff">Add-Type</span> <span style="color: #000080">-TypeDefinition</span> <span style="color: #ff4500">$TypeDefinition</span> <span style="color: #000080">-CodeDomProvider</span> <span style="color: #ff4500">$provider</span>            
<span style="color: #000000">}</span></pre>
<h3>Notes</h3>
<ul>
<li>Investigate using a PowerShell Proxy command for Add-Type and extend the Language parameter </li>
<li>Enhance Add-TypeFSharp to take an F# file in addition to a string </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.dougfinke.com/blog/index.php/2010/04/18/how-to-add-an-f-type-to-a-powershell-session/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>PowerShell and F# Consoles in Visual Studio 2010</title>
		<link>http://www.dougfinke.com/blog/index.php/2010/04/02/powershell-and-f-consoles-in-visual-studio-2010/</link>
		<comments>http://www.dougfinke.com/blog/index.php/2010/04/02/powershell-and-f-consoles-in-visual-studio-2010/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 01:36:27 +0000</pubDate>
		<dc:creator>Doug Finke</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[IronPython]]></category>
		<category><![CDATA[IronRuby]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>

		<guid isPermaLink="false">http://dougfinke.com/blog/index.php/2010/04/02/powershell-and-f-consoles-in-visual-studio-2010/</guid>
		<description><![CDATA[Who would have thought? The PowerConsole also supports IronPython and IronRuby.]]></description>
				<content:encoded><![CDATA[<p>Who would have thought?</p>
<p>The <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/67620d8c-93dd-4e57-aa86-c9404acbd7b3">PowerConsole</a> also supports <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/777407db-348b-4ac6-8106-ce4da1bd3bd2">IronPython and IronRuby</a>.</p>
</p>
</p>
<p><a href="http://dougfinke.com/uploadPictures/Whowouldhavethought_12E88/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://dougfinke.com/uploadPictures/Whowouldhavethought_12E88/image_thumb.png" width="570" height="119" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dougfinke.com/blog/index.php/2010/04/02/powershell-and-f-consoles-in-visual-studio-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use MongoDB from PowerShell and F#</title>
		<link>http://www.dougfinke.com/blog/index.php/2009/10/25/how-to-use-mongodb-from-powershell-and-f/</link>
		<comments>http://www.dougfinke.com/blog/index.php/2009/10/25/how-to-use-mongodb-from-powershell-and-f/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 02:36:16 +0000</pubDate>
		<dc:creator>Doug Finke</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://dougfinke.com/blog/index.php/2009/10/25/how-to-use-mongodb-from-powershell-and-f/</guid>
		<description><![CDATA[Dwight Merriman, founder of 10gen,&#160; presented today, at Lab49 where I work, about his new database platform: Mongo (from &#34;humongous&#34;) is a high-performance, open source, schema-free document-oriented database. MongoDB is written in C++ and offers the following features: Collection oriented storage: easy storage of object/JSON -style data Dynamic queries Full index support, including on inner [...]]]></description>
				<content:encoded><![CDATA[<p>Dwight Merriman, founder of 10gen,&#160; presented today, at <a href="http://www.lab49.com/">Lab49</a> where I work, about his new database platform:</p>
<p>Mongo (from &quot;humongous&quot;) is a high-performance, open source, schema-free document-oriented database. <a href="http://www.mongodb.org/display/DOCS/Home">MongoDB</a> is written in C++ and offers the following features:</p>
<ul>
<li>Collection oriented storage: easy storage of object/<a href="http://www.mongodb.org/display/DOCS/BSON">JSON</a> -style data </li>
<li>Dynamic <a href="http://www.mongodb.org/display/DOCS/Querying">queries</a> </li>
<li>Full <a href="http://www.mongodb.org/display/DOCS/Indexes">index</a> support, including on inner objects and embedded arrays </li>
<li>Query <a href="http://www.mongodb.org/display/DOCS/Database+Profiler">profiling</a> </li>
<li><a href="http://www.mongodb.org/display/DOCS/Replication">Replication</a> and fail-over support </li>
<li>Efficient storage of binary data including <a href="http://www.mongodb.org/display/DOCS/GridFS">large objects</a> (e.g. photos and videos) </li>
<li><a href="http://www.mongodb.org/display/DOCS/Sharding">Auto-sharding</a> for cloud-level scalability </li>
</ul>
<h3>PowerShell</h3>
<p>Dwight pointed out the way different languages could to talk to MongoDB and C# was one of them using a <a href="http://github.com/samus/mongodb-csharp">community developed driver</a>.</p>
<p>Following the post <a href="http://odetocode.com/blogs/scott/archive/2009/10/13/experimenting-with-mongodb-from-c.aspx">Experimenting with MongoDB from C#</a>, MongoDB was up and running and I was storing and retrieving data in no time.</p>
<p><a href="http://dougfinke.com/uploadPictures/HowtouseMongoDBfromPowerShell_1123E/image.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://dougfinke.com/uploadPictures/HowtouseMongoDBfromPowerShell_1123E/image_thumb.png" width="366" height="261" /></a> </p>
<h3>F#</h3>
<p>Looks like Matthew Podwysocki used the same reference and has <a href="http://gist.github.com/218388">MongoDB working with F#</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dougfinke.com/blog/index.php/2009/10/25/how-to-use-mongodb-from-powershell-and-f/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Don Syme&#8217;s F# deck from JAOO</title>
		<link>http://www.dougfinke.com/blog/index.php/2009/10/12/don-symes-f-deck-from-jaoo/</link>
		<comments>http://www.dougfinke.com/blog/index.php/2009/10/12/don-symes-f-deck-from-jaoo/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 13:04:55 +0000</pubDate>
		<dc:creator>Doug Finke</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[JAOO]]></category>

		<guid isPermaLink="false">http://dougfinke.com/blog/?p=820</guid>
		<description><![CDATA[Don Syme, creator of F#, posts his F# tutorial he presented at JAOO 2009. Over 100 crunchy slides. Some highlights of the code are: Foundational material on F# async programming, and samples including: Fetching web pages in parallel The Bing translator sample using async programming A Graphical, asynchronous twitter client in 50 lines A Twitter [...]]]></description>
				<content:encoded><![CDATA[<p>Don Syme, creator of F#, posts his <a href="http://blogs.msdn.com/dsyme/archive/2009/10/10/f-tutorial-code-and-slides-jaoo-2009-edition.aspx">F# tutorial</a> he presented at <a href="http://jaoo.dk/aarhus-2009/">JAOO 2009</a>. Over 100 crunchy slides.</p>
<p>Some highlights of the code are:</p>
<ul>
<li>Foundational material on F# async programming, and samples including:
<ul>
<li>Fetching web pages in parallel</li>
<li>The Bing translator sample using async programming</li>
<li>A Graphical, asynchronous twitter client in 50 lines</li>
<li>A Twitter feed example that uses F# first class reactive event processing to process the stream of feeds</li>
<li>An asynchronous web crawler</li>
<li>Processing images in parallel, using a mixture of I/O and CPU parallelism</li>
</ul>
</li>
<li>An updated version of the famous Interactive DirectX demo</li>
<li>Lots of great micro samples on foundational topics such as
<ul>
<li>object oriented programming</li>
<li>language oriented programming</li>
<li>function composition</li>
<li>design patterns</li>
<li>discriminated unions</li>
<li>records</li>
<li>units of measure</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.dougfinke.com/blog/index.php/2009/10/12/don-symes-f-deck-from-jaoo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>F# Integrated with Visual Studio 2010 and .NET 4</title>
		<link>http://www.dougfinke.com/blog/index.php/2009/10/10/f-integrated-with-visual-studio-2010-and-net-4/</link>
		<comments>http://www.dougfinke.com/blog/index.php/2009/10/10/f-integrated-with-visual-studio-2010-and-net-4/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 13:35:45 +0000</pubDate>
		<dc:creator>Doug Finke</dc:creator>
				<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[VS 2010]]></category>

		<guid isPermaLink="false">http://dougfinke.com/blog/index.php/2009/10/10/f-integrated-with-visual-studio-2010-and-net-4/</guid>
		<description><![CDATA[.NET 4 core types that F# uses, such as Tuple, Lazy, and BigInteger, are now part of the .NET Framework and can be used across all .NET languages One ground-breaking feature of F# is Units of Measure, which allows you to annotate your floating point code with units, such as meters and seconds providing compile-time [...]]]></description>
				<content:encoded><![CDATA[<ul>
<li> .NET 4 core types that F# uses, such as <em>Tuple</em>, <em>Lazy</em>, and <em>BigInteger</em>, are now part of the .NET Framework and can be used across all .NET languages</li>
<li>One ground-breaking feature of F# is Units of Measure, which allows you to annotate your floating point code with units, such as meters and seconds providing compile-time checking</li>
<li>F# language features are designed to make parallel and asynchronous programming more intuitive</li>
<li>F# is a strongly-typed language like C#, but with a lightweight syntax often seen in a dynamic language like Python</li>
</ul>
<p>via <a href="http://blogs.msdn.com/somasegar/archive/2009/10/09/f-in-vs2010.aspx">F# in VS2010</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dougfinke.com/blog/index.php/2009/10/10/f-integrated-with-visual-studio-2010-and-net-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell and F#</title>
		<link>http://www.dougfinke.com/blog/index.php/2008/12/30/powershell-and-f/</link>
		<comments>http://www.dougfinke.com/blog/index.php/2008/12/30/powershell-and-f/#comments</comments>
		<pubDate>Wed, 31 Dec 2008 03:43:30 +0000</pubDate>
		<dc:creator>Doug Finke</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://dougfinke.com/blog/?p=525</guid>
		<description><![CDATA[Two great tastes that taste great together. Andy Schneider posts how to use PowerShell&#8217;s Add-Type cmdlet to get at the FSharp Code Provider and inline F# text in a PowerShell script and then access it from PoSh. Inline F# in PowerShell]]></description>
				<content:encoded><![CDATA[<p>Two great tastes that taste great together. Andy Schneider posts how to use PowerShell&rsquo;s <em><strong>Add-Type </strong></em>cmdlet to get at the FSharp Code Provider and inline F# text in a PowerShell script and then access it from PoSh.</p>
<p><a href="http://get-powershell.com/2008/12/30/inline-f-in-powershell/">Inline F# in PowerShell</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dougfinke.com/blog/index.php/2008/12/30/powershell-and-f/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
