This project is read-only.
1
Vote

FontAwesome keeps breaking my MVC solution with various DLL mismatches

description

Hi!

Can you help me please? I've tried three times to install and use FontAwesome in my Visual Studio MVC Project. I installed it using Nuget and then I added it to my project by running this command at the Nuget command line:

Install-Package FontAwesome.MVC

Then I added one of the demonstration lines to my Index.cshtml file:

@Html.FontAwesome(FontAwesomeIconSet.Star)

It normally underlines in it red and says that the type or namespace cannot be found. I have tried it with and without a "using" declaration at the top of the page like this:

using Mvc.RazorTools.FontAwesome;

Right now, it doesn't have that error message. But when I try to build the project, it gives me this error:

Error 2 Assembly 'Mvc.RazorTools, Version=1.0.5.0, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Optimization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' c:\Users\ben.charlton\Documents\Visual Studio 2013\Projects\Sunify\packages\Mvc.RazorTools.Base.1.0.5\lib\net45\Mvc.RazorTools.dll Sunify

And these two warnings:

Warning 1 Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. Sunify

Warning 3 Reference to type 'System.Web.Optimization.IItemTransform' claims it is defined in 'c:\Users\ben.charlton\Documents\Visual Studio 2013\Projects\Sunify\packages\Microsoft.AspNet.Web.Optimization.1.0.0\lib\net40\System.Web.Optimization.dll', but it could not be found c:\Users\ben.charlton\Documents\Visual Studio 2013\Projects\Sunify\packages\Mvc.RazorTools.Base.1.0.5\lib\net45\Mvc.RazorTools.dll Sunify

Last night I spent all night debugging these errors, changing values in various configuration files but went round and round in circles so this morning I just gave up and reinstalled .NET, reinstalled, Visual Studio, reinstalled FontAwesome and started again on a blank MVC project.

But it's happening again now.
Before I try fixing it again and risk making it worse, can anybody tell me what I should do please?

Many thanks

Benjamin

comments

benjaminjcharlton wrote Apr 27, 2015 at 2:25 PM

Ok, an update for you. I've finally managed to get the solution to build. For anybody facing similar issues, there were loads of other Nuget packages that were necessary to get before it would build properly. Do NOT mess with your config files as Visual Studio will tell you to. Instead, just download the following extra packages:

PM> Install-Package Microsoft.AspNet.Web.Optimization
PM> Install-Package -Id Microsoft.AspNet.WebHelpers
PM> Install-Package Microsoft.AspNet.WebPages.Data


However, now that my solution builds and the home page loads correctly, I still can't see any icons. I tried the following examples:

@Html.FontAwesome(FontAwesomeIconSet.Star, FontAwesomeStyles.Large5x)
@Html.FontAwesome(FontAwesomeIconSet.Cog, FontAwesomeStyles.Large5x)

These render HTML to the page like this:
<i class="fa fa-star fa-5x"></i>
<i class="fa fa-cog fa-5x"></i>

But in the browser, I see nothing. Is it supposed to inject some reference to a stylesheet and/or font somewhere? Or am I supposed to do that? I read the documentation here:

https://fontawesome.codeplex.com/documentation

But there is nothing at all about including extra files or setting it up, so I assumed it was plug-in-and-play.

Can anybody help please?

porrey wrote Apr 27, 2015 at 11:39 PM

Try adding ____@Mvc.RazorTools.BundleManager.Styles.Render()__ to the scripts section of your _Styles.cshtml page or at the top of any other page if you do not use _Styles.cshtml.

As an example:
<head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>@ViewBag.Title - My ASP.NET Application</title> @Styles.Render("~/Content/css") @Scripts.Render("~/bundles/modernizr") @Mvc.RazorTools.BundleManager.Styles.Render() </head>

porrey wrote Apr 27, 2015 at 11:58 PM

The above response did not show up properly:

The package is not 100% plug and play because it would require modifications to your source code which most people do not like, nor does everyone implement in exactly the same manner. If I can find a way to do this with the package without being intrusive to the source I will update the package.

Here are my recommendations when using this package in Visual Studio 2013:
  • Before adding the package update ALL of your NuGet packages especially if you started with a new MVC project
  • Next add the NuGet package Mvc.RazorTools.Fontawesome
  • Add the statement below to your layout page or directly to your pages
@Mvc.RazorTools.BundleManager.Styles.Render()
  • Add the namespace Mvc.RazorTools.FontAwesome to your views web.config
I apologize for the trouble. I will update the documentation to provide these details.

benjaminjcharlton wrote Apr 28, 2015 at 9:51 AM

That worked like a charm!
Thank you so much for your help. It's fixed.