【发布时间】:2020-01-31 02:14:35
【问题描述】:
我正在尝试使用 f# 和 Visual Studio 2019 设置一个 xamarin android 项目,但我似乎无法达到“Hello world!”的地步。会显示在我的设备上!
模板项目构建成功,我的设备连接成功。但是,尝试部署项目失败,错误告诉我无法解析对 FSharp.Core 的引用。如果有人对此问题有更多了解,或者可以推测正在发生的事情以及可以采取哪些措施来解决它,我们将不胜感激。
在创建一个空白的 android 应用程序时,我偶然发现了 this thread 中解释的错误:
Xamarin.Android.FSharp.ResourceProvider 似乎不见了,并且没有引用 FSharp.Core。我通过 Nuget 安装解决了这个问题。但是,查看我的智能感知和控制台错误,FSharp.Core 仍未正确加载。
在阅读this article 之后,我通过将 FSharp.Core 的 fsproj 文件引用从“包含”编辑为“更新”,设法让智能感知感到满意并成功构建。
<PackageReference Update="FSharp.Core" Version="4.7.0" />
但是,这一次我在尝试将项目部署到我的 android 设备时遇到参考错误。
XA2002: Can not resolve reference: `FSharp.Core`, referenced by `Xamarin.Android.FSharp.ResourceProvider.Runtime`. Please add a NuGet package or assembly reference for `FSharp.Core`, or remove the reference to `Xamarin.Android.FSharp.ResourceProvider.Runtime`.
XA2002: Can not resolve reference: `FSharp.Core`, referenced by `Playground`. Please add a NuGet package or assembly reference for `FSharp.Core`, or remove the reference to `Playground`.
(Playground 是项目名称)
我正在部署到相对较旧的设备(android 4.3,api 级别 18),但查看错误似乎与失败无关。我一定错过了一些简单的东西,比如构建或参考设置。
【问题讨论】:
-
尽管 F# 核心页面上说了什么,但可能值得添加一个参考(通过参考/框架)而不是 Nuget 包。此 Microsoft 页面提到 F# Core:docs.microsoft.com/en-us/xamarin/cross-platform/internals/…
-
@GregHNZ 感谢您的建议! FSharp.Core 似乎没有在可用的框架参考中列出。将我从 nuget 包中获得的 dll 手动复制到该文件夹似乎已经成功了,尽管我仍在引用 nuget 包。我还在我的 fsproj 文件中的引用中添加了
<Private>true</Private>,以确保 dll 包含在构建中。必须有一个更合适的方法来设置它,但它现在似乎工作!再次感谢您的意见。 -
似乎我只是将错误推到了更远的一步。部署成功,但现在运行应用程序时找不到 FSharp.Core.dll。
The assembly was not found in the Global Assembly Cache, a path listed in the MONO_PATH environment variable, or in the location of the executing assembly (/storage/sdcard0/Android/data/Playground.Playground/files/.__override__/). -
对于它的价值(可能“不多”),空白的 Android Mobile F# 应用程序在 VS2017 中首次运行。我什至无法在 VS2019 中创建没有错误的项目。
标签: visual-studio xamarin.android f#