BHoM / Speckle_Toolkit

GNU Lesser General Public License v3.0
10 stars 2 forks source link

Copy Speckle references only if Speckle is not installed #93

Open alelom opened 4 years ago

alelom commented 4 years ago

Description:

Speckle_Toolkits references the nuget of SpeckleCore to work. BHoM therefore need to have SpeckleCore loaded in the UI when using the Speckle_Toolkit (e.g. Grasshopper has to load it).

For this to happen, we need to make sure that the SpeckleCore.dll will be loaded from the UI, so it should be placed in the BHoM folder where it can be loaded from.

However, if Speckle is installed, the UI (e.g. Grasshopper) will try to load another SpeckleCore.dll from the Speckle installation folder. This creates a conflicting reference.

When Speckle is not installed, this problem does not exist; additionally, it is desirable for the Speckle_Toolkit to work without requiring the user to install Speckle separately, as the Toolkit will now include all that is needed for operating Speckle.

This can be solved by selectively copying the dlls from the Speckle_Toolkit to the BHoM Assembly folder. We need to check if Speckle is installed; if it is, SpeckleCore.dll should not be copied.

After https://github.com/BHoM/admin/issues/5 and #92 , this will be possible.

The same for SpeckleCoreGeometry.dll.

alelom commented 4 years ago

Added question in Speckle forum to understand best way to check if speckle is installed: https://discourse.speckle.works/t/check-if-speckle-is-installed/611

alelom commented 4 years ago

The answer seems to be to check at least one of the following:

  1. If %localappdata%\Speckle and its contents exist - after uninstalling Speckle this actually disapperars, so this is a valid option.
  2. If there is a registry key in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall\{BA3A01AA-F70D-4747-AA0E-E93F38C793C8}_is1 – did not check its validity after uninstall.
  3. If SpeckleCache.db exists in %localappdata%\SpeckleSettings --> after uninstalling Speckle this persists - no good.
alelom commented 4 years ago

In #91 I implemented the option number 1.

  1. If %localappdata%\Speckle and its contents exist - after uninstalling Speckle this actually disapperars, so this is a valid option.