AppHarbour and Nuget and F#

While deploying an app to AppHarbour today (which I think is fantastic btw.) I came across some problems so I thought I’d document them.

1. Assembly References
with using NuGet and assembly redirects to newer versions. Basically, I had drawn a NuGet dependency on SignalR 0.4, MVC4 Beta and Json.NET 4.5.3

(Note: The assembly version is actually 4.5.0 you can read more about why the versions aren’t in sync on James Newton-Kings blog here)

This all worked fine on my machine, SignalR was happy with the using Json.NET 4.5.0 version despite it being built against 4.0.7 the problems however came when I tried to deploy to AppHarbour, my build started failing with the following messages.

ResolveAssemblyReferences:
  Unified primary reference "Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed".
      Using this version instead of original version "4.0.7.0" in "D:\temp\zm5ue1lf.ozz\input\packages\SignalR.Server.0.4.0.0\lib\net40\SignalR.dll" because AutoUnify is 'true'.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. 

It turns out that NuGet doesn’t seems to always add HintPath property to the Reference node in the project file; I have to admit that this only seems to be a problem with F# I haven’t had to do this with any C# projects yet. To fix this simply add the hint path to point to the correct path.

To do this, unload the project file and right click, and select ‘Edit project file’ then change each of the problematic references as follows

Before:

<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
      <Private>True</Private>
    </Reference>

After:

<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
<HintPath>..\packages\Newtonsoft.Json.4.5.3\lib\net40\Newtonsoft.Json.dll</HintPath>
      <Private>True</Private>
    </Reference>

2. F# 3.0 isn’t on AppHarbour

O.K I already knew this, but I have been developing this app in the visual studio 11 beta. When you create an F# project in VS11 it targets the F# 3.0 MSBuild targets file.

To fix this edit the desired project file, and find the following line

<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets" Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')" />

after this line add the following

  <Import Project="$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets" Condition="(!Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')) And (Exists('$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets'))" />
  <Import Project="$(MSBuildExtensionsPath32)\FSharp\1.0\Microsoft.FSharp.Targets" Condition="(!Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')) And (!Exists('$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets')) And (Exists('$(MSBuildExtensionsPath32)\FSharp\1.0\Microsoft.FSharp.Targets'))" />

Hope this helps!!

Advertisements
This entry was posted in Development and tagged , , , . Bookmark the permalink.

One Response to AppHarbour and Nuget and F#

  1. Pingback: NuGet Causes Needless Headaches With RavenDB, RestSharp and Json.Net « ActiveEngine

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s