This project has moved. For the latest updates, please go here.
1
Vote

Build failed due to bad project references (MVC 5 etc)

description

I just cloned, accepted the package restore and built the solution in VS2013 Update 3.

LiveScore-ES - Builds OK.

Debug in IE 11 (Win8.1)

Error:
Server Error in '/' Application.

There is no build provider registered for the extension '.cshtml'. You can register one in the <compilation <buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.
I guessed something in web.config to do with version of WebPages or MVC but the version numbers seemeds to align OK with the version of packages in package.config (and the packages that got downloaded.

I changed Copy Local to 'True' on references:
  • System.Web.Mvc
  • System.Web.Webpages
  • System.Web.Webpages.Razor
Then got this:
Server Error in '/' Application.

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: An error occurred creating the configuration section handler for system.web.webPages.razor/host: Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Looking at the properties window of each they all seem to be wrong:
  • System.Web.Mvc - 4.0.0.0 (Not 5.0.0.0 as expected)
  • System.Web.Webpages - 2.0.0.0 not 3.0.0.0
  • System.Web.Webpages.Razor - 2.0.0.0 not 3.0.0.0
So I deleted references and re-added packages:
  • Uninstall-Package Microsoft.AspNet.Mvc -Version 5.0.0.0 -Force
  • Uninstall-Package Microsoft.AspNet.Razor -Version 3.0.0.0 -Force
  • Uninstall-Package Microsoft.AspNet.Webpages -Version 3.0.0.0 -Force
  • Install-Package Microsoft.AspNet.Mvc -Version 5.0.0.0
That seems to fix it.

I could send a pull request - can CodePlex do that?!

The resultant change in files is:

packages.config:
Add -   <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
LiveScore-ES.csproj:
A number of lines get changed, some new references, some changes to HintPaths.

comments

rohancragg wrote Oct 9, 2014 at 9:53 AM

I also get similar issues with IBuyStuff-cqrs only a bit worse. Again the project IBuyStuff.Server seems to need MVC5 but references MVC4. The packages.config does not even reference it so I had to add it. I have so far not been able to resolve this.

rohancragg wrote Nov 28, 2014 at 1:05 PM

I just checked out commit 6c2d1674afeb and it all now builds fine - thanks!

I will try the other solutions in due course.

rohancragg wrote Nov 28, 2014 at 3:32 PM

I just tried the other solutions.

Here are my findings at the moment:
  • Merp - restored packages and built OK first time
  • IBuySpy - CQRS and DM - restored packages but failed to build due to version of MVC.
I applied the same fix as I'd applied above (i.e. I ran Install-Package Microsoft.AspNet.Mvc -Version 5.0.0.0)

This fixed the solutions and enabled me to build them.

I've not tried running them yet though ;-)

tdavisjr wrote Jan 4, 2015 at 12:25 AM

If you are trying to run the project and get an Entity Framework error about Model validation and migrations, you have to delete the .mdf file in the App_Data folder and run the program again so it can auto create the database file again. IMHO, this database file should be removed from source control if the default is to auto-create the DB on startup.

Craigmaddie wrote May 11, 2015 at 9:10 AM

I applied the same fix as I'd applied above (i.e. I ran Install-Package Microsoft.AspNet.Mvc -Version 5.0.0.0)

Thanks for that Robin. I was getting error messages about Route and RouteProvider after having cloned the repository. But by installing MVC 5 I was able to fix them.