Domanda

I'm deploying a C# website to Azure from a GitHub repository. This website references a couple of F# libraries and they compile just fine on my machine, but in Azure the build fails with a number of compilation errors.

Here is a snippet of the build log:

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.

The first error should have been fixed after I put the CLIMutable attribute on the offending record type and the second error should have been fixed after including the proper namespace. I don't know what exactly the third error is about, especially since none of them happen locally.

To make sure I had the same version of F# in both places I've included the FSharp.Core dll in the solution and refer to the local version. This did not help but it removed a warning that it could not find version 4.3.1 of the file.

Is it possible that I'm running another version of the F# compiler and how do I check that? It has worked fine until now, which makes me suspect some slight difference in versioning of something. Unfortunately it seems quite hard to get insight into what actually happens in the build environment. It is a free website Azure website and it does not seem like you cen get direct access to it.

I could probably work around the individual issues for now but there seems to be a deeper issue at work here.

È stato utile?

Soluzione

This turned out to be an issue with different versions of the F# compiler being used. Using Visual Studio 2013 RC, I was using the 3.1 version, which has had some improvements causing my specific issues to not appear.

The problem was made difficult to identify because changing my F# project to use the 3.0 compiler in Visual Studio did not have any effect (it still compiled just fine). I even opened the solution up in Visual Studio 2012, and it all compiled well enough. It was only when I created a new project from scratch in VS 2012 that I began to get the same compilation errors as on the server. So I guess that this must be an error (or at least not very desirable feature) in the project file that was created. I'm not sure if this should be classified as a bug with VS 2013, especially since I don't know exactly what causes the error.

So the simple solution until Azure (or is this a Kudu thing?) supports the 3.1 compiler is to either recreate the project file in VS 2012 or to copy code which does not compile over to a test solution where fixes can be tested.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top