As discussed in the previous post we are working to get VSLab back on the September CTP because the VS project system has completely changed. The core mechanism used to build Viewlets do not depend on this integration, they rather rely on deeper mechanisms available on Windows. The only feature the VSLab addin used of the project system was the ability to send F# code to the F# interactive toolwindow. In the former implementation F# interactive was essentially a user control, now the system provides support for F# as a VS package, thus the toolwindow has a completely different implementation.
Although I'm talking with the F# product team I continued to look for a hack to quickly update VSLab because many people have downloaded it and I know how hateful is when a tool ceases working. Yesterday evening mostly by accident I found the solution that I quickly describe here to those interested in sending F# code to fsi.exe from VS addins. The first step is to obtain a reference to DTE2 object available from the VS automation model and here referred as appObj.
To show the F# interactive toolwindow you can simply trigger the menu command as follows:
The toolwindow should be loaded before you can get a reference to it:
let tw = (appObj.ToolWindows).GetToolWindow("F# Interactive") :?> Microsoft.FSharp.VisualStudio.Session.FsiToolWindow
It is interesting to have a look to the cast, the object you are getting from GetToolWindow is not a COM wrapper but the .NET object of a type defined in the FSharp.VS.FSI.dll assembly. Now after a little bit of use of Reflector I found that the method I was interested in was executeNoHistory@182 that is clearly an inner function object and cannot be invoked directly. While I'm waiting for a public method I resorted to reflection to invoke it:
let mi = (tw.GetType()).GetMethod("executeTextNoHistory@182")
mi.Invoke(tw, [| ("2+2;;" :> obj) |]) |> ignore
And this is the only true dependency VSLab has from the F# VS integration. Now I'm working to port project templates, but these are minor things. Hope to release the new version VSLab by wednesday.