有没有一种简单的方法可以使用 F# 创建 Silverlight 3 应用程序(10 月 CTP)? 我见过F# for Silverlight ,但这仅适用于 5 月 CTP。
我正在使用 Visual Studio Integrated Shell 2008。
最佳答案
可以将 5 月 CTP 模板与 10 月 CTP 版本的 F# 一起使用
创建新项目,然后卸载它并编辑 FSharp.Core.dll 的提示路径以指向 October CTP,
<HintPath>$(ProgramFiles)\fsharp-1.9.7.8\Silverlight\2.0\bin\FSharp.Core.dll</HintPath>
然后重新加载项目并构建。
您必须手动打包 .xap 文件,例如使用 chiron
工具(或只是压缩和重命名)
AppManifest.xaml 文件看起来像
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
RuntimeVersion="3.0.40818.0"
EntryPointAssembly="astroclock-fs"
EntryPointType="astroclock.fs.MyApp">
<Deployment.Parts>
<AssemblyPart x:Name="astroclock-fs" Source="astroclock-fs.dll" />
<AssemblyPart x:Name="FSharp.Core" Source="FSharp.Core.dll" />
</Deployment.Parts>
</Deployment>
在其中填写您自己的程序集名称和入口点,而不是我的
在 $(ProjectDir) 中创建一个文件夹来保存所有要打包的文件,并将 C:\Program Files\FSharp-1.9.7.8\Silverlight\2.0\bin\FSharp.Core.dll 以及上面的 AppManifest.xaml
如果您使用该工具,请在文件夹中创建一个空文件 null.py 以保持 chiron 安静
添加以下构建后步骤
cd $(ProjectDir)
copy /y $(OutDir)$(TargetFileName) [your directory with all the output]
"C:\Program Files\IronPython 2.0\Silverlight\bin\chiron.exe" /d:[your directory with all the output] /z:app.xap
创建一个测试页面来加载app.xap
构建项目
在浏览器中加载页面并享受
已添加
您可以通过编辑 C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplatesCache\FSharp\Silverlight\SilverlightLibrary3.zip 中的模板来永久修复查找 FSharp.Core.dll 所需的提示路径\SilverlightLibrary.fsproj (为了确定,可能是 C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\FSharp\Silverlight\SilverlightLibrary3.zip 中的文件版本)。
以及一个可行的概念证明(源代码和捆绑到 xap 中的所有内容)here .
关于silverlight - 使用 F# 创建 Silverlight 3 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1775056/