views:

132

answers:

2

I have a "white labelled" application that is installed onto multiple customers' servers. On any given installation the differences will include content, style sheets and graphics but also some actual code / business logic. I want my TFS Server to build all flavours of my application automatically. What are my options for doing this? e.g. should I be using Themes? What about #if conditional compilation flags.

P.S. The question is not about how to setup the Build Server - I've done that already.

+1  A: 

For the business logic I would abstract the differences into a separate libraries, and then you can use an IoC / DI pattern or provider pattern to resolve the correct business logic at runtime.

As for the content I would look into themes. Essentially you could have your build server build all the code once, then when you package the code you choose which assemblies you need and use the appropriate configuration, and choose the appropiate theme folder for the client at hand.

I don't like using # directives in this case. If you think about it your unit tests would have to run for each conditional you have. If you remove the conditionals and abstract the differences your unit tests can just run on all the pluggable assemblies at once.

JoshBerke
A: 
  1. Content/image - you can make your own HtmlHelper/UrlHelper extension to do Html\Url.Content() to pickup right things for right customers, in addition to copying needed files from right folders (which is simple, /Content + /ContentCustomer1, 2, ...).
  2. There's no single answer, I suppose. One easy answer would be to move your Order.Calculate() method to a partial class, so that you have
    • OrderPartsForCustomer1.cs
    • OrderPartsForCustomer2.cs

where you'll have

public partial class Order
{
   public Money Calculate()
   {
   }
}

You'll just include needed .cs classes then, and don't clutter your code with #ifs.

If you want common code for all, and overrides just for specific customers, you can have OrderPartsCommon.cs, which you will copy/use if there's not customer-specific overide.

queen3