我正在将 C# 网站从 GitHub 存储库部署到 Azure。这个网站引用了几个 F# 库,它们在我的机器上编译得很好,但在 Azure 中构建失败并出现许多编译错误。

这是构建日志的片段:

FS0001: A generic construct requires that the type 'Company' have a public default constructor [C:\DWASFiles\Sites\eureka-servicestack-poc\VirtualDirectory0\site\repository\Eureka.ServiceStack.FSharp.Poc\Services\Services.fsproj]
C:\DWASFiles\Sites\eureka-servicestack-poc\VirtualDirectory0\site\repository\Eureka.ServiceStack.FSharp.Poc\Services\CompaniesService.fs(28,17): error FS0039: The field, constructor or member 'PopulateWith' is not defined [C:\DWASFiles\Sites\eureka-servicestack-poc\VirtualDirectory0\site\repository\Eureka.ServiceStack.FSharp.Poc\Services\Services.fsproj]
C:\DWASFiles\Sites\eureka-servicestack-poc\VirtualDirectory0\site\repository\Eureka.ServiceStack.FSharp.Poc\Services\AppHost.fs(17,55): error FS0072: Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved. [C:\DWASFiles\Sites\eureka-servicestack-poc\VirtualDirectory0\site\repository\Eureka.ServiceStack.FSharp.Poc\Services\Services.fsproj]
An error has occurred during web site deployment.

在我将 CLIMutable 属性放在有问题的记录类型上后,第一个错误应该已经修复,而第二个错误应该在包含正确的命名空间后修复。我不知道第三个错误到底是什么,特别是因为它们都没有发生在本地。

为了确保我在两个地方都有相同版本的 F#,我在解决方案中包含了 FSharp.Core dll 并引用了本地版本。这并没有帮助,但它删除了一个警告,提示它找不到文件的 4.3.1 版。

我是否可能正在运行另一个版本的 F# 编译器,我该如何检查?到目前为止,它一直运行良好,这让我怀疑某些版本的版本略有不同。不幸的是,似乎很难深入了解构建环境中实际发生的情况。这是一个免费的 Azure 网站,您似乎无法直接访问它。

我现在可能可以解决个别问题,但这里似乎有一个更深层次的问题在起作用。

最佳答案

结果证明这是使用不同版本的 F# 编译器的问题。使用 Visual Studio 2013 RC,我使用的是 3.1 版本,它有一些 improvements 导致我的特定问题没有出现。

这个问题很难识别,因为将我的 F# 项目更改为在 Visual Studio 中使用 3.0 编译器没有任何效果(它仍然编译得很好)。我什至在 Visual Studio 2012 中打开了该解决方案,并且编译得很好。只有当我在 VS 2012 中从头开始创建一个新项目时,我才开始遇到与服务器上相同的编译错误。所以我猜这一定是创建的项目文件中的一个错误(或者至少不是非常理想的功能)。我不确定这是否应该归类为 VS 2013 的错误,尤其是因为我不知道究竟是什么导致了错误。

因此,在 Azure(或者这是 Kudu 的东西?)支持 3.1 编译器之前,简单的解决方案是在 VS 2012 中重新创建项目文件,或者将无法编译的代码复制到可以测试修复的测试解决方案中。

关于azure - 仅当从 GitHub 部署时,Azure 中的 F# 编译错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18947202/

10-14 16:25
查看更多