Following on from Doug Finke's ‘Embedding’ F# in PowerShell article, I wanted to load F# scripts within PowerShell.
Later, after a bit of Google-ing, I worked out that you don't need to use the fsc.exe compiler, because we can instead use Add-Type. However we need a "CodeDom" for the F#. I ended up installing The Old F# "PowerPack", which includes one in its FSharp.Compiler.CodeDom.dll DLL file.Here is the definition of my Add-FSharpType CmdLet:
Give either of these two parameters:
- Path - the path to the F# script file.
- TypeDefinition - a string containing the F# code.