Can I create a basic project for use across multiple ASP.NET MVC projects?

My team brought me this one and I'm a bit stumped. We've just started using ASP.NET MVC for web development in our store, and there is a general design and functionality that we would like to use across multiple sites.

So far, I've considered creating a custom template with common elements, but the downside to this is that template updates (as far as I can tell) are not automatically pushed to projects created using that template. Since auto-update changes are required for consuming projects, custom templates won't work for me.

My question is, is it possible to create a base project for use in multiple ASP.NET MVC projects where base updates will be pushed to consuming projects? If you have any experience in this area, I would certainly appreciate some direction. My apologies if this question seems elementary to you, but this is my first real foray into ASP.NET MVC.

+3


source to share


3 answers


I've found that the best way to share resources between disparate projects is to create your own Nuget packages. They can contain everything in a class library with reusable classes, enums, extension methods, etc. For all web applications, complete with controllers, views, JavaScript, CSS, etc. The scope entirely depends on how generic you can abstract away from your projects.You can then set up your own Nuget repository to store them, so you don't have to publish them globally. (Though, if you're building something that will benefit others, be sure to share it on the official Nuget repository.)

Configuring all settings is pretty trivial. I learned how to create Nuget packages and set up a private repo in a day. Here are some resources to help you get started:



SymbolSource also offers private repositories, remote on their servers, for free. Some enterprise environments may not like having their code in the cloud, but if you can handle it, this is by far the easiest way to succeed.

+3


source


From experience, the company I am working on has found that while our project has common design and functionality elements, the unusual elements can be too broad, which outweighs, then some basic design is necessary. Using custom project templates also becomes a maintenance nightmare, so avoid it.

Instead, we decided to document how the project should be set up for specific projects, and before the team leadership to keep track of what bits are needed for the specific project they are working on.



If there is a functional overlap that we looked at (but haven't done yet), create a shared library (s) that has its own development lifecycle, and then set up your own NuGet Server to distribute the shared library to your other projects. We haven't done that yet, but mainly because the differences between the projects we've worked on tend to be large enough to fail.

But due to what you are describing, NuGet packages or something similar might be in your case.

0


source


While I don't think there is a way to create a base project that everyone else inherits, you could easily create a generic library project that everyone else links to. It can include base classes for all the common things you will use (for example ControllerBase

).

Thus, updating the library project will add new functionality to all other projects. You can customize templates so that common base classes are used by default when adding new items.

Depending on how you link to the shared library (compiled dll link / linked project link), you either get a stable link to a specific version or instant updates for all projects. I personally prefer to reference the shared dll rather than the project, as this allows project A

for an older version than project B

. Upgrading A to a new version is trivial, but it gives you a level of separation, so if it B

requires breaking, you don't have to waste resources to maintain A

.

Another added bonus is that checking the old version from the original control will be guaranteed as it will be tied to the version of the library that will be in use at the time it is created.

0


source







All Articles