First of all, sorry for my english :)
I have interface:
public interface IWorker { void DoWork(); }
Also I have dozens different components (custom nuget packages) which implement this interface. E,g:
//first nuget package
public SqlWorker : IWorker
{
void DoWork() { //do something sql related }
}
//second nuget package
public MongoWorker : IWorker
{
void DoWork() { //do something Mongo related }
}
//third nuget package
public FilesystemWorker : IWorker
{
void DoWork() { //do something physical files related}
}
//etc...
I need to run this workers in different order, for some cases I need to add or delete some workers and so on. So I have created a simple console application which at the start read the xml file where I specify which workers should be run.
static void Main(string[] args)
{
List<IWorker> workers = ParseWorkersFromXmlFile();
foreach (var worker in workers)
{
worker.DoWork();
}
}
Xml can look like:
<Workers>
<worker name="Sql" />
<worker name="FileSystem" />
</Workers>
<Workers>
<worker name="Mongo" />
</Workers>
So now when I have new business rules, I create new xml file and add one line into deployment script to copy the console application into one more folder but this time read my new configuration. Thus, from one console application I create 5 "different" applications.
BUT as this 5 "different" application are just copy of the same one console application, each and every application contains huge amount of nuget packages which are not necessary used by the particular console application. I mean, application can execute only one worker according to the xml file (let's sat SqlWorker), but still will have not needed packages for mongo.
And here is the questions:
May I during the building resolve on the fly which nuget packages I will need for the specified configuration. So if I specify only SqlWorker, download only SQL related nuget packages? If I specified SqlWorker and MongoWorker, download only Sql and Mongo related packages and so on.
Does my idea makes sense at all? Or I will make even bigger mess?