Vicenç Gascó
Vicenç Gascó

Reputation: 1346

ASP MVC 4 Split in several projects

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.

Upvotes: 1

Views: 1933

Answers (2)

Mike Koder
Mike Koder

Reputation: 1928

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.

Upvotes: 2

volpav
volpav

Reputation: 5128

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.

Upvotes: 2

Related Questions