Thursday, May 22, 2014

Deploy Mono MVC4 to AppHarbor

After upgrading to MonoDevelop 5,  (see my previous blog: Upgrading to MonoDevelop 5.1 in Linux Mint 16) you'll want to create an mvc4 app. But MD5 only comes with mvc3 templates. No problem. Chris F Carroll has published just the template you'll need. Clone this github project: Asp.Net MVC4 C# Razor Template for Mono on Mac and Linux

This template worked for me right out of the box. But when I deployed it to AppHarbor, it failed. The log shows this error:

error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

I actually got the same error using the mvc3 templates that ship with MonoDevelop. This is due to some missing tags in the Web.config file. Find this section:

   <compilation debug="false" targetFramework="4.0">
      <assemblies>


You'll need to add these tags:

        <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />


Now re-deploy your site. You'll find that these tags will disappear any time you modify your project references. I keep a copy inside a comment tag inside the web.config file, so I don't have to go looking for them every time I update my project.

3 comments:

  1. about the version of these assemblies. Should they match with the ones provided in dependent assembly tags or just use same as given

    ReplyDelete
    Replies
    1. For now, I'm staying with those version numbers. I realize they are behind the latest Microsoft versions for ASP.NET, but they were the latest I could find at the time for Mono. I'm hoping that this will all change, as Microsoft has started open sourcing more of the framework.

      Delete
  2. This comment has been removed by the author.

    ReplyDelete