1

I'm working with the following projects:

  • MyFramework.csproj (class library)

  • MyCustomerApp.csproj (class library)

    References MyFramework

  • MyLauncher.csproj (Executable program)

    references MyLauncherDependency.nupkg

MyCustomerApp.csproj is the 'runnable' project which works like so:

  1. MyLauncher.exe is copied from the MyLauncher project to the output of MyCustomerApp
  2. When running MyLauncher.exe, this uses Assembly.Load(..) to load the MyCystomerApp.dll

There's a specific reason as to why we have this mechanism which I won't get into - consider it out of scope for now.

Now here's the problem; MyLauncherDependency is a dependency of MyLauncher, but its not a dependency of MyCustomerApp. Therefore MyLauncherDependency is not a compile time dependency of MyCustomerApp - but it is a runtime dependency - because it needs MyLauncherDependency.dll at runtime.

I don't want to add MyLauncherDependency.nupkg to MyCustomerApp because I don't want to give engineers access to classes from MyLauncherDependency in MyCustomerApp.

So my question is: How can I add MyLauncherDependency.nupkg (or MyLauncherDependency.nupkg) to MyCustomerApp as a runtime only dependency?

sommmen
  • 6,570
  • 2
  • 30
  • 51
  • MyCustomerApp depends on MyLauncher ? no? then there is no dependency at all ... it's more likely publishing problem – Selvin Oct 22 '20 at 12:52
  • MyCustomApp does not depend on MyLauncherDependency at all. It is MyLauncher that has the dependency, so when copying MyLauncher.exe you would need to copy all dependencies. Or make MyLauncher fetch all dependencies it needs, or package MyLauncher as a single exe. – JonasH Oct 22 '20 at 12:54
  • @Selvin I'm using `` tags to copy the MyLauncher.exe straight into the bin/debug so there's not reference – sommmen Oct 22 '20 at 12:58
  • @JonasH you're right i think. There a quite a few dependencies however - and i'd like to be able to say 'hey, just copy all dlls from this nuget package to the output and generate the right binding redirects if you can (in case of version conflicts)' instead of having to manually copy and match dlls. I feel like this is not really easy to do, impossible even, but i'm really just fishing for solutions. – sommmen Oct 22 '20 at 13:03
  • @sommen will the user copy MyLauncher manually? if so, perhaps package it as a zip-file? Or will it be a nuget reference? In that case there should not be a problem? – JonasH Oct 22 '20 at 13:47

1 Answers1

0

Do you have to use Nuget?

MEF (Managed Extensibility Framework) is great for loading plug-ins at runtime.

https://learn.microsoft.com/en-us/dotnet/framework/mef/

Colin
  • 4,025
  • 21
  • 40