Creating F# TypeProviders with VS Experimental Instance

Blogging after a long time now! So after a big break I started to look at F# TypeProviders for the first time, the samples from were good enough to get me started. So as soon as I wrote the Hello world kind of code and executed thru the interactive window I wanted to try out some changes and see the updated types. Now I was trying to compile the source and it wasn’t allowing me to do it, the dll was getting referenced by Visual Studio. I had to close the VS instance and then open again to re-work with it, this is quite annoying as I’m a newbie and I would like to explore the TypeProviders slowly to understand how it works. I asked around in Twitter to see if someone had a better solution to this, and I got a reply from @sforkmann

@sforkmann: @fahadsuhaib I’m always using two VS instances. Having a fast SSD helps a lot.

Now opening up 2 VS instances rang some bells, I thought to use the VS experimental instance to fire up when I need to check the TypeProvider and then close it to ensure that I don’t need to close all the VS instances. It just gives a simpler way to do “debug” like execution and then go back to make some changes in my TypeProvider. Below are the steps to enable VS Experimental Instance,

  • Right-Click the TypeProvider project and goto its properties window
  • Navigate to the “Debug” tab and set the following,
    • Start external program: c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe
    • Command line arguments: /RootSuffix Exp


Note: I haven’t upgraded to VS2012 yet (on vacation still Smile) but it should work the same way.

Now that we have the VS setup to use Experimental instance, we hit the “Play” button to start the instance (this will fire off another VS instance one that is used for testing with VS addins). We need to create another test F# project that will use the TypeProvider library. Below are the steps,

  1. Run the TypeProvider library project
  2. Create a new F# console app to test the TP
  3. Add reference to the TP library in the F# application project, this will ensure that the dll is copied to the bin\debug location. It helps a bit in copying the dll out of the original location and not locking the original dll to VS instance
  4. Build the project
  5. Add a new F# script file for testing in interactive mode
  6. Add references to the TP library in the F# script file
  7. This will popup a dialog asking you to enable/disable the plugin to load. Click “disable” for now as we will enable it in the next step
  8. Once everything is setup, you can navigate to Tools –> Options –> F# Tools –> Type Providers and select the checkbox to enable it
  9. Check out your TP in this step
  10. When you are done, close the Experimental VS and navigate to Tools –> Options –> F# Tools –> Type Providers in the TP library project. Uncheck the TP that you had used before, this will ensure that VS is no longer holding on to that instance.
  11. Make changes to your TP library and repeat the steps if you want to test again.

There are couple of manual steps which are really painful to repeat, but it is far better than having 2 VS instances side-by-side and closing/opening them often! So a final treat, as there are lots of steps above, I recorded a simple video,

Note: Don’t ask me what I was working on, it was just a simple experiment with Zackbray’s GUI framework. It dint work because generic types are not supported in TP’s yet. Hopefully once it gets added, I’ll work on it again!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: