0

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:

  1. 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.

  2. Does my idea makes sense at all? Or I will make even bigger mess?

qwestcl
  • 1
  • 2
  • I'm maybe misunderstanding (Friday afternoon...), couldn't you just ensure your directory structure/nuget setup ensures only one instance of the packages exists? Then you probably don't care about the overhead. There's an answer here which may be of help - https://stackoverflow.com/questions/18376313/setting-up-a-common-nuget-packages-folder-for-all-solutions-when-some-projects-a – NDJ Feb 21 '20 at 16:51
  • I do have only one instance of the package, and it's completely okay. The question is different: my console application contains all nuget packages (sql, mongo db, amazon, kafka, etc.) but based on my xml configuration file it can work only with one package and i don't want to store all the other as current instance don't use them. For example, i've created another xml file and for work it needed only 2 nuget packages and i don't need store the rest packages. So i try to find a way how to deploy console application with nuget packages that needed exactly for this xml configuration file. – qwestcl Feb 21 '20 at 20:03

0 Answers0