Launching an F# web application inside VS2010 as if it were C#
This is a follow-up to my comments on VS launcher for F# web apps, where I can put an example of the changed markup to the F# class library project to make it act like a web project and launch a browser with your Default.aspx page when you hit F5.
First, add the highlighted element to the topmost <PropertyGroup>
clause in the .fsproj file thus:
<PropertyGroup> | |
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |
<ProductVersion>8.0.30703</ProductVersion> | |
<SchemaVersion>2.0</SchemaVersion> | |
<ProjectGuid>{cd87f694-a133-42b1-a328-72f7f56e95c3}</ProjectGuid> | |
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{F2A71F9B-5D33-465A-A702-920D77279786}</ProjectTypeGuids> | |
<OutputType>Library</OutputType> | |
<RootNamespace>Library1</RootNamespace> | |
<AssemblyName>Library1</AssemblyName> | |
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | |
<Name>Library1</Name> | |
</PropertyGroup> |
where the first GUID is for web app, and the second for F# (as you can see by looking for the project in the solution file).
At the bottom of a C# web application .csproj you will find a block of code like
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" /> | |
<ProjectExtensions> | |
<VisualStudio> | |
... | |
</VisualStudio> | |
</ProjectExtensions> |
which you just want to copy and paste into your F# project following the
<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets" Condition=" Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" /> |
or equivalent line.
Now adding a trivial Default.aspx file containing
Welcome to ASP.NET on F#!
and the default web.config from a C# web project to the F# library, and running the project launches me that trivial web page into Firefox.
Actually getting F# to play nice with ASP.Net, I leave to those more versed in the latter.
No comments :
Post a Comment