Saturday, November 30, 2013

Adding New Items to a Pure F# ASP.NET MVC/Web API Project

UPDATE 12/15/2013:
-----------------------

The F# community has been working hard on ways to make this process easier. To that end, here are the new and improved instructions:

Option 1: Visual Studio Project Template Option:

The easiest option is to simply install the latest version of either the F# MVC 5 template or the F# Nancy template. These templates now include a custom NuGet package that contains an Install.ps1 file that will automatically add the needed registry entries.

Option 2: PowerShell Option:

If you prefer to run the PowerShell file manually, you can do the following:

1. Launch PowerShell (you may need to run PowerShell as administrator).
2. Download the AddRegistryEntries.ps1 file and execute it with the command ./AddRegstryEntries.ps1

Option 3: Batch File Option:

If you don't want to use PowerShell, there is also a batch file option.

1. Download the AddRegistryEntries.bat file.
2. Run the batch file as administrator.

You should now be able to see the items shown in step #5 of the original post. Don't forget to checkout the F# Web Item Templates as well.

-----------------------

A few months ago Mark Seemann put together a great post on how to create a pure F# ASP.NET Web API project. One of the biggest disadvantages mentioned in that post is that once the necessary changes are made to the ProjectTypeGuids element in the fsproj file, the Add New Item wizard no longer displays items. After much trial and error, I've found a fix for this issue.

Note: While the change mentioned here is pretty mild, the standard registry edit disclaimer still applies. It's recommended that you backup your registry before making changes as incorrect changes/additions/deletions can have serious and unexpected consequences.

Here are the steps for VS2013 (for VS2012 the steps should be similar, but with a slightly different registry path).

1. Edit the registry (e.g. run regedit.exe).

2. Locate HKEY_LOCAL_MACHINE or HKEY_LOCAL_USER then \SOFTWARE\Microsoft\VisualStudio\ then 12.0 or 12.0_Config then \Projects\

3. Find {349C5851-65DF-11DA-9384-00065B846F21}. If there is more than one, find the one with LanguageTemplates as the child. 

4. Add a new String Value entry to the LanguageTemplates node with a key and value of {F2A71F9B-5D33-465A-A702-920D77279786}.


5. Test it out by closing all instances of VS, creating a pure F# ASP.NET MVC or Web API project, and trying to add a new item. You should now see all of the usual F# item templates.


If you want to try this out without having to manually create a pure F# ASP.NET MVC or Web API project, here's a sneak peak of one of the F# Nancy templates that Ryan Riley and I are working on. Look for the full collection of F# Nancy templates in the next few weeks. You can get involved with the Nancy templates by contributing to https://github.com/fsharp/FSharpCommunityTemplates/tree/master/VisualStudio/Nancy.Templates.

Monday, November 18, 2013

Announcing FogJS for Windows Azure with Node.js

About a year and a half ago I announced a library named Fog (for F#) that had the goal of making it very easy to use F# to work with the Windows Azure API for .NET. Today, I'm proud to announce the release of FogJS, which has a similar goal for JavaScript/Node.js development.

FogJS:

FogJS currently supports 3 of the more popular Azure services: Blob Storage, Table Storage, and Service Bus. One of the most broad features in FogJS is that of support for promises. In fact, almost every function provided by the Azure SDK for Node.js has been replicated in Fog with the results returned as a promise (with the help of Q.js).

The second big feature is related to making it as easy as possible to interact with Azure. This is primarily accomplished with "simplified functions" that follow a convention over configuration approach.

Example: 

Here's a quick example of one option for how to use Blob Storage with FogJS:

You can find examples for Table Storage and Service Bus interaction on the main FogJS site: http://fogjs.azurewebsites.net/.

As usual, the code and tests can be found on my GitHub.

Monday, November 11, 2013

A Few Changes to the F#/C# MVC 4 Project Template

There is a new version (v1.21) of the F#/C# MVC 4 project template. There are two new features worth noting in this release:

1. The AutoGenerateBindingRedirects attribute has been added to all of the project files. This attribute (that is newly available in .NET 4.5.1/VS2013) removes the need to constantly add or update binding redirects in your web.config or app.config files. This eliminates the errors that you often see when the binding redirect elements were missing in config files such as "System.MissingMethodException : Method not found...".

2. The project creation wizard now has an option to include FsUnit for NUnit or xUnit within the Test project. We plan to include MS Test as well as options without FsUnit in a future release.


Wednesday, November 6, 2013

A New Home for the F# Community Project Templates


While at the Progressive F# Tutorials last week Don Syme and I worked together to create a new home for the community F# project templates. They can now be found under the F# Open Source Community GitHub org at https://github.com/fsharp/FSharpCommunityTemplates.

We would love to have you add to these templates. Simply follow the instructions in the readme file and submit a pull request.

Tuesday, November 5, 2013

F# Web Programming Session (slides and examples) at Progressive F# Tutorials 2013

Thanks to all who came out to the web programming session that Zach Bray and I led at Progressive F# Tutorials 2013. You can find the slides and examples from the session at https://github.com/dmohl/FsOnTheWeb-Workshop.

Additionally, you can find the FunScript and HashBang presentation at http://funscript.info/presentations/progf/slides.html#1 and a working example of the associated chat client/server app at https://github.com/ZachBray/HashBang.