Here are my own steps to get an f# silverlight application working. You can get the code here. Thanks to Michael Giagnocavo and John Liao for most of this information.
UPDATE: I forgot to add the part about the references earlier, but had added it now.
- Create an f# library project.
- On the project settings "Build" tab, add the compiler flags "--standalone --noframework"
- Create an Application and a Page class, or whatever Silverlight classes you want.
- Add an AppManifest file like this (stolen from a c# silverlight apllication):
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Deployment.Parts>
</Deployment.Parts>
</Deployment> - Unload the project and edit the .fsproj file
- Add the following options to the first PropertyGroup at the top of the file (the one that has property groups for all configurations:
<SilverlightApplication>true</SilverlightApplication>
<XapOutputs>true</XapOutputs>
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
<XapFilename>__Your_App_Name__.xap</XapFilename>
<SilverlightManifestTemplate>AppManifest.xml</SilverlightManifestTemplate>
<SilverlightAppEntry>__Your_App_Class_Full_Typename__</SilverlightAppEntry>
<TestPageFileName>TestPage.html</TestPageFileName>
<CreateTestPage>true</CreateTestPage>
<ValidateXaml>true</ValidateXaml>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation> - Replace the references section with the following (note: you could do this without unloading the project, but doing it in the text editor seems way easier.):
<Reference Include="mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e">
<Name>mscorlib</Name>
<AssemblyName>mscorlib.dll</AssemblyName>
<HintPath>..\..\..\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\mscorlib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e">
<Name>System</Name>
<AssemblyName>system.dll</AssemblyName>
<HintPath>..\..\..\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\system.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e">
<Name>System.Core</Name>
<AssemblyName>System.Core.dll</AssemblyName>
<HintPath>..\..\..\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\System.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Net, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e">
<Name>System.Net</Name>
<AssemblyName>System.Net.dll</AssemblyName>
<HintPath>..\..\..\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\System.Net.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e">
<Name>System.Runtime.Serialization</Name>
<AssemblyName>System.Runtime.Serialization.dll</AssemblyName>
</Reference>
<Reference Include="System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e">
<Name>System.Windows</Name>
<AssemblyName>System.Windows.dll</AssemblyName>
<HintPath>..\..\..\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\System.Windows.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Windows.Browser, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e">
<Name>System.Windows.Browser</Name>
<AssemblyName>System.Windows.Browser.dll</AssemblyName>
<HintPath>..\..\..\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\System.Windows.Browser.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e">
<Name>System.Xml</Name>
<AssemblyName>System.Xml.dll</AssemblyName>
<HintPath>..\..\..\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\System.Xml.dll</HintPath>
<Private>False</Private>
</Reference> - Add this line:
just _after_ the FSharp Targets line:
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight\v2.0\Microsoft.Silverlight.Common.targets" />
<Import Project="$(MSBuildExtensionsPath)\FSharp\1.0\Microsoft.FSharp.Targets" /> - Reload the project, build, and load the TestPage.html page in a browser to verify it works.