weikio / PluginFramework

Everything is a Plugin in .NET
MIT License
557 stars 106 forks source link

NugetPackagePluginCatalog should download the package only once #59

Closed mikoskinen closed 2 years ago

mikoskinen commented 2 years ago

PluginFramework supports installing plugins using Nuget. This is implemented in NugetPackagePluginCatalog.

If NugetPackagePluginCatalog's packagesFolder is set, the Nuget package gets always installed into the same path. Still, NugetCatalog always tries to download the Nuget package.

Change

We want to download the package only once. When NugetPackagePluginCatalog is initialized, it should check if the package has been previously installed and if so, it should use that instead of trying to download the package again.

Implementation idea

When first initializing the catalog, can we serialize and save nugetDownloadResult into some fixed location (based on the packages folder & package identifier (name.version)) in NugetPackagePluginCatalog.Initialize? Before calling nuGetDownloader.DownloadAsync we could check if the file already exists and deserialize the result instead of using NugetDownloader.

Note

Behind the scenes NugetPackagePluginCatalog uses NugetDownloader. NugetDownloader takes care of installing the correct version of the package (x86 vs x64 vs arm vs Win10 vs Win11 etc). NugetDownloader passes NugetDownloadResult to PluginFramework and PF uses that info when initializing the catalog.

NugetDownloader can be found from https://github.com/weikio/nugetdownloader but we shouldn't need to modify it.

Testing

New unit test should be created to test this functionality by cloning the NugetPackagePluginCatalogTests.CanInstallPackageWithNativeDepencencies. This is a good test case as it uses the native dlls etc. which are provided by the NugetDownloader.

franklupo commented 2 years ago

News?