1

I have a common "kernel" to all my projects in MVC 4, which contains Styles bundles, Scripts, a users control system (fine tuned to my needs), etc.

I'd like to use this as "Template" to all my new projects, but at the same time I want it to be update across all the projects.

So imagine I have 5 projects, and I am using Bootstrap 2, now Bootstrap 3 came out and I want just to update it in my base ("kernel") project, and see that change in all the projects that were using it.

How should I do that?

Right now, the only idea that comes to my mind is to have a base project, and open it for each new project and Save As... new, but that won't accomplish the "update" part.

Vicenç Gascó
  • 1,326
  • 2
  • 13
  • 21
  • See [sharing views, css, javascript between multiple asp.net mvc 3 projects](http://stackoverflow.com/questions/15506811/sharing-views-css-javascript-between-multiple-asp-net-mvc-3-projects), [Sharing views between ASP.NET MVC 3 Web application projects](http://stackoverflow.com/questions/6430571/sharing-views-between-asp-net-mvc-3-web-application-projects), [MVC4 hosting views from other MVC project](http://stackoverflow.com/questions/16241039/mvc4-hosting-views-from-other-mvc-project) or just search the web for "asp.net mvc shared project". – CodeCaster Jan 07 '14 at 10:35

2 Answers2

2

Instead of having 5 separate projects, you could have just one with multiple areas (including the one for your "kernel"). This way it's going to be much easier to reuse the functionality from your "kernel" area and, at the same time, maintain only one instance of it. More on areas: Walkthrough: Organizing an ASP.NET MVC Application using Areas.

As an alternative, take a loot at this answer where the author mentions MVCContrib Portable areas as a possible solution.

Hope this helps.

Community
  • 1
  • 1
volpav
  • 5,090
  • 19
  • 27
  • Thanks, but... I have different collaborators in each project, that I don't want to share the rest of code with them (only the kernel)... and every project is very different... so I'd like to have it divided, is it possible? – Vicenç Gascó Jan 07 '14 at 10:50
  • 1
    @VicençGascó Maybe then the viable solution for you could be to make a NuGet package out of the "kernel" project. This way the collaborators can simply update the package whenever your make changes (you can host the package on your own NuGet package repository if you don't want to expose it to the public). Another option (from the related SO question) is to use [MVCContrib Portable areas](http://lostechies.com/erichexter/2009/11/01/asp-net-mvc-portable-areas-via-mvccontrib/). – volpav Jan 07 '14 at 11:26
2

Create your own nuget repository and put the common bits there. Nuget packages don't need to be *.dlls, they can contain any files and powershell scripts. Updating a package could mean updating ~/Views/Shared/_Layout.cshtml.

If you create a lot of new projects with the same structure, you could create a custom Visual Studio project template.

I wouldn't go too far when trying to get that "update one dll to go from bootstrap 2 to 3", because you can't predict how the code/markup of external libraries change (e.g. css classes from icon* to glyphicon*). You would have to create HtmlHelpers for all the Bootstrap components to prevent them from breaking with the next release.

Mike Koder
  • 1,898
  • 1
  • 17
  • 27