New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another F# Issue: Cannot build ASP.NET Web API Project in F# #633

Closed
SirEel opened this Issue May 26, 2013 · 9 comments

Comments

Projects
None yet
2 participants
@SirEel

SirEel commented May 26, 2013

This issue is a follow-up to the recently-closed issue #137, #137.

On May 24,2013 kudu became capable of building F# projects. Microsoft posted a sample solution here: https://github.com/KuduApps/WebAppWithFSharpLibrary

However, the sample only uses a bare-bones F# project containing no non-default library references. Kudu still cannot build the much more complete F# / C# MVC 4 template currently available on Nuget (see http://visualstudiogallery.msdn.microsoft.com/3d2bf938-fc9e-403c-90b3-8de27dc23095)

The reason appears to be that kudu cannot build an F# project that implements controllers for ASP.NET Web API. Specifically, kudu cannot build an F# project that depends on the System.Web.Http, which is required to write an ApiController class in F#

Steps to reproduce:

  1. Download the sample solution from https://github.com/KuduApps/WebAppWithFSharpLibrary and store it in a local git repository.
  2. Create an Azure web site and publish the sample solution to it from the local git repository. Kudu successfully builds and deploys the solution.
  3. Modify SomeFSharpLibary.fsproj be adding references to the assemblies System.Net.Http, System.Web.Http and System.Web.Http.WebHost (all located under Assemblies -- Extensions).
  4. Add the following code to the end of library1.fs:

type MyWebApiController() =
inherit System.Web.Http.ApiController()

  1. Push the sample solution to Azure again. This time the deployment fails with the following errors:

D:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3267: The primary reference "System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", which is a framework assembly, could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" or retarget your application to a framework version which contains "System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". [C:\DWASFiles\Sites\VirtualDirectory0\site\repository\SomeFSharpLibrary\SomeFSharpLibrary.fsproj]

D:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [C:\DWASFiles\Sites\VirtualDirectory0\site\repository\SomeFSharpLibrary\SomeFSharpLibrary.fsproj]

D:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [C:\DWASFiles\Sites\VirtualDirectory0\site\repository\SomeFSharpLibrary\SomeFSharpLibrary.fsproj]

So, although the resolution of issue #137 enables some F# projects to be deployed from git, it is still not possible if the F# project implements a Web API controller.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost May 26, 2013

I believe the issue is the template targets framework version 4.0 but the library in question needs 4.5. Can you try changing the framework version of the project to 4.5.

ghost commented May 26, 2013

I believe the issue is the template targets framework version 4.0 but the library in question needs 4.5. Can you try changing the framework version of the project to 4.5.

@SirEel

This comment has been minimized.

Show comment
Hide comment
@SirEel

SirEel May 27, 2013

Changing both the C# and F# projects to .NET 4.5 in WebAppWithFSharpLibrary produced exactly the same kudu errors as previously reported. (BTW I had to first fix 8 EntityFramework errors heaved up by the C# project when it changed to 4.5.)

Taking the extra step of changing the F# project to use System.Net.Http 4.0.0.0 instead of 2.0.0.0 (only possible once it targeted 4.5) eliminated the first of the three kudu errors, i.e. the one pertaining to System.Net.Http; but I still got the remaining two errors, concerning System.Web.Http and System.Web.Http.WebHost, exactly as before.

And I got the same results from doing these same things with the F# / C# MVC 4.0 template.

So targeting .NET 4.5 is not the answer.

SirEel commented May 27, 2013

Changing both the C# and F# projects to .NET 4.5 in WebAppWithFSharpLibrary produced exactly the same kudu errors as previously reported. (BTW I had to first fix 8 EntityFramework errors heaved up by the C# project when it changed to 4.5.)

Taking the extra step of changing the F# project to use System.Net.Http 4.0.0.0 instead of 2.0.0.0 (only possible once it targeted 4.5) eliminated the first of the three kudu errors, i.e. the one pertaining to System.Net.Http; but I still got the remaining two errors, concerning System.Web.Http and System.Web.Http.WebHost, exactly as before.

And I got the same results from doing these same things with the F# / C# MVC 4.0 template.

So targeting .NET 4.5 is not the answer.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost May 27, 2013

Did you target the 4.5 client profile or full 4.5 profile? If that's not the issue we have to investigate a bit more to get to the bottom of things.

ghost commented May 27, 2013

Did you target the 4.5 client profile or full 4.5 profile? If that's not the issue we have to investigate a bit more to get to the bottom of things.

@SirEel

This comment has been minimized.

Show comment
Hide comment
@SirEel

SirEel May 27, 2013

There is no distinction between "client" and "full" profile in .NET 4.5 AFAIK. I targeted 4.5, period.

SirEel commented May 27, 2013

There is no distinction between "client" and "full" profile in .NET 4.5 AFAIK. I targeted 4.5, period.

@SirEel

This comment has been minimized.

Show comment
Hide comment
@SirEel

SirEel May 27, 2013

However, there might be a distinction between assemblies that are part of "Framework" vs "Framework Extensiions". System.Net.Http 2.0.0.0 is in "Framework Extensions", but System.Net.Http 4.0.0.0 is in plain "Framework". Kudu can compile F# projects that reference the latter but not the former, suggesting that it has a problem with F# projects referencing Framework Extensions.

SirEel commented May 27, 2013

However, there might be a distinction between assemblies that are part of "Framework" vs "Framework Extensiions". System.Net.Http 2.0.0.0 is in "Framework Extensions", but System.Net.Http 4.0.0.0 is in plain "Framework". Kudu can compile F# projects that reference the latter but not the former, suggesting that it has a problem with F# projects referencing Framework Extensions.

@davidebbo

This comment has been minimized.

Show comment
Hide comment
@davidebbo

davidebbo May 27, 2013

Member

Could you share a repository that demonstrates the issue (e.g. a modified fork of the KuduApps test repo)? This way we can easily see exactly what you're seeing and investigate from there. Thanks!

Member

davidebbo commented May 27, 2013

Could you share a repository that demonstrates the issue (e.g. a modified fork of the KuduApps test repo)? This way we can easily see exactly what you're seeing and investigate from there. Thanks!

@davidebbo

This comment has been minimized.

Show comment
Hide comment
@davidebbo

davidebbo May 27, 2013

Member

I got this working and updated the test project, though it was a bit tricky. Seems the F# project system behaves in quirky ways that makes normally simple things harder. See the history of my changes in the test project to see what steps I went through.

Member

davidebbo commented May 27, 2013

I got this working and updated the test project, though it was a bit tricky. Seems the F# project system behaves in quirky ways that makes normally simple things harder. See the history of my changes in the test project to see what steps I went through.

@SirEel

This comment has been minimized.

Show comment
Hide comment
@SirEel

SirEel May 27, 2013

David,

I got my project working too, after I studied the updates you made. The key seems to be that the F# project must reference the Web API assemblies from the Nuget \packages folder, not from Assemblies -- Extensions. I'm not sure if the problem is with the F# project system, the relationship between Nuget packages and the regular .NET framework, or a bug in kudu. But I can now build my F# / C# template project in kudu. I have blogged about it here: http://sireel-world.azurewebsites.net/sir-eel-visions/WATK-FS-Pt2

Thanks for following through again.

SirEel commented May 27, 2013

David,

I got my project working too, after I studied the updates you made. The key seems to be that the F# project must reference the Web API assemblies from the Nuget \packages folder, not from Assemblies -- Extensions. I'm not sure if the problem is with the F# project system, the relationship between Nuget packages and the regular .NET framework, or a bug in kudu. But I can now build my F# / C# template project in kudu. I have blogged about it here: http://sireel-world.azurewebsites.net/sir-eel-visions/WATK-FS-Pt2

Thanks for following through again.

@davidebbo

This comment has been minimized.

Show comment
Hide comment
@davidebbo

davidebbo May 28, 2013

Member

Glad you got it working, And nice post!

Member

davidebbo commented May 28, 2013

Glad you got it working, And nice post!

@davidebbo davidebbo closed this May 28, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment