Given multiple websites all running the same sourcecode, what's the 开发者_JS百科best/most maintainable way to organise these into projects within visual studio?
For example, say we have websites Red
, Blue
, and Green
(etc). Their HTML may be different, but they are a functionally the same.
Previously in one solution we have created one project Colour
, which contains a generic version of the project. Red
, Blue
, and Green
get their own project, and each technical page is set to use the C# in Colour
. (That is, there's no unique C# for the individual implementations - all code files get removed).
However, this approach leads us to ending up with multiple individual implementation dll's that do next to nothing, and also Other Stuff like javascript, css, and common images get duplicated accross projects.
Ideally we'd like to be able to run each project in isolation, and sourcesafe sharing always seems like a terrible idea.
Is there a Better Way?
edit: forgot to mention, all business logic / data access is handled by a shared Business Layer project, so all the code for that is separate and shared.
Pack the shared code into a class library. That'll take care of the data layer, business logic and some other auxiliary routines. My experience is that it helps a great deal with projects having the same foundation.
Your projects Red, Green and Blue, if they are different then they have to be kept apart. You can't really circumvent that. My personal approach is to immediately introduce a change made in one into all others before you forget it. That has worked fine for me.
I would recommend you using the MVP pattern with ASP.NET. This way you could have a single class library project containing the models and the presenters which would be referenced by multiple ASP.NET applications containing the views and of course static resources such as JS, CSS, images which could be specific to each site. Of course if you want to share static resources between web applications you could put them into a common location so that they are referenced from there (like SO does with sstatic.net).
So your solution could look like this:
NameOfProject.sln
|
|-- NameOfProject.Presenters
|
|-- Web Application 1
|
|-- Web Application 2
.....
|-- Web Application n
精彩评论