Ideas for setting out an MVC 4 template for future projects with shared views and code

StackOverflow https://stackoverflow.com/questions/15087199

  •  11-03-2022
  •  | 
  •  

Pergunta

I'm trying to setup a mvc template/framework for future development work. What I want to do is have a way of using shared resources such as the layout and common nuget packages so that starting new sites use our branding and such without to much hassle.

In web forms we used to just share the master page around between applications using source control but it ends up being a hastle. What I'd like to do is

  1. Create a basic mvc 4 project
  2. Share core project that contains common code (security, db) and views (layouts)
  3. Install nuget package that sets up the new project with basic settings and packages

I'm not sure that this is the best way to go about it however and if it's even possible to share views in such a way. I've looked at portable areas from MvcContrib but it looks overkill for what we need.

Any suggestions

Foi útil?

Solução

Not sure if this is the "best" way but the way we do it is

  1. Common Code (security,db) in it's own source controlled project/s, i.e. StackOverFlow.Common, StackOverflow.Data etc.
  2. Common MVC Code (C#) (Validation Annotations, Html Helpers etc) in it's own source controlled project/s, i.e. StackOverFlow.Mvc.Common etc.
  3. Common MVC4 project - jQuery, NuGet librarys, Views, Twitter Bootstrap, Less etc. in it's own source controlled project i.e. StackOverFlow.Mvc.

we use TeamCity to provide Continuous Integration and also take advantage of Team City 7.x as an internal NuGet server.

When we start a new mvc project, we create an empty MVC4 projects, set up a basic structure and run two NuGet commands.

Another way would be to create a vstemplate from the Common MVC4 project. That way you could integrate it into the File --> New Project process.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top