fbpx
Skip to content

Update RevitAddin

    Imagine the files below as a bundle for a plugin RevitAddin:

    I have been using the technique below for years.

    RevitAddin.bundle
      |- PackageContents.xml
      |- Contents
        |- RevitAddin.Loader.addin
        |- RevitAddin.Loader.dll
        |- RevitAddin
          |- 1.2.0
            |- RevitAddin.addin
            |- RevitAddin.dll

    The PackageContents.xml only gonna load the RevitAddin.Loader.addin that loads an Application in RevitAddin.Loader.dll.

    The only responsibility of the RevitAddin.Loader.dll is to find the last version of RevitAddin based on the folder/version name and delete the old folder/version name.

    In this case, only gonna load the version/file .\RevitAddin.bundle\Contents\RevitAddin\1.2.0\RevitAddin.addin that load a Application in the RevitAddin.dll file in the same folder.

    So if I create a new folder with version 1.3.0 with .addin and .dll, the next time Revit opens the Loader gonna load that version and gonna delete version 1.2.0 if version 1.3.0 loads successfully.

    The plugin RevitAddin.dll has the ability to download a new version, by looking on a server or something, creating the files in this format with $ADDINNAME$/$ADDINVERSION$/$ADDINNAME$.addin.

    Another thing that I implemented is the Revit Version case adding an extra folder after the plugin version.

    Like this $ADDINNAME$/$ADDINVERSION$/$REVITVERSION$/$ADDINNAME$.addin.

    In this case, RevitAddin.Loader.dll checks if the Revit version is the same in the folder name before loading, to make sure to load the last version of the plugin in the right Revit version.

    And the PackageContents.xml is configured to load the RevitAddin.Loader.addin for basically all available Revit versions, so this is possible that RevitAddin.Loader.dll does not use any deprecative methods in RevitApi.

    In the end, a multi-version plugin would have a bundle something like this:

    RevitAddin.bundle
      |- PackageContents.xml
      |- Contents
        |- RevitAddin.Loader.addin
        |- RevitAddin.Loader.dll
        |- RevitAddin
          |- 1.3.0
            |- 2021
              |- RevitAddin.addin
              |- RevitAddin.dll
            |- 2022
              |- RevitAddin.addin
              |- RevitAddin.dll
            |- 2023
              |- RevitAddin.addin
              |- RevitAddin.dll

    This technique I created in 2020 and I never had a big issue with that, the only problem is the RevitAddin.Loader.dll file is kinda impossible to update, after Revit load the assembly is not possible to delete or change to another.

    Another issue is that each RevitAddin I create with the update feature needs to have this Loader.dll with the same code in each project, and is kinda annoying to set up the bundle with the loader file and the plugin files.

    So I’m creating a new way of using the PackageBuilder approach. Instead of having a Loader.dll file to find the last version I’m using the PackageContents.xml to do that.

    Imagine that I have one bundle with the PackageContents.xml configured with each .addin file in the right Revit version, something like this:

    RevitAddin.bundle
      |- PackageContents.xml
      |- Contents
        |- RevitAddin
          |- 1.3.0
            |- 2021
              |- RevitAddin.addin
              |- RevitAddin.dll
            |- 2022
              |- RevitAddin.addin
              |- RevitAddin.dll
            |- 2023
              |- RevitAddin.addin
              |- RevitAddin.dll

    In Revit 2021 gonna load the file .\RevitAddin.bundle\Contents\RevitAddin\1.3.0\2021\RevitAddin.addin, Revit 2022 the file .\RevitAddin.bundle\Contents\RevitAddin\1.3.0\2022\RevitAddin.addin and so on.

    And imagine I have another bundle with the same approach but with version 1.4.0 instead and I unzip the files in the same folder and replace the files that have the same name, the result gonna be something like:

    RevitAddin.bundle
      |- PackageContents.xml
      |- Contents
        |- RevitAddin
          |- 1.3.0
            |- 2021
              |- RevitAddin.addin
              |- RevitAddin.dll
            |- 2022
              |- RevitAddin.addin
              |- RevitAddin.dll
            |- 2023
              |- RevitAddin.addin
              |- RevitAddin.dll
          |- 1.4.0
            |- 2021
              |- RevitAddin.addin
              |- RevitAddin.dll
            |- 2022
              |- RevitAddin.addin
              |- RevitAddin.dll
            |- 2023
              |- RevitAddin.addin
              |- RevitAddin.dll

    I successfully update the plugin just by changing the content of the PackageContents.xml to another file, and the best part is possible to replace the PackageContents.xml file when Revit is running, PackageContents is only read with Revit starts.

    The RevitAddin.dll file gonna be responsible to download the last version of the bundle and unzip and replace the files with the same name, and of course, if I don’t want this update feature just remove the implementation/package.

    Now how could I create this bundle in an easy way?

    I have been developing a package to create the RevitAddin.bundle.zip and the RevitAddin.exe in the easiest way possible.

    The package name is ricaun.Nuke.PackageBuilder uses the Nuke build automation to generate all the files in the RevitAddin project and create the bundle folder in the format described in this article.

    And I have a plugin ricaun.AppLoader that I used to create the visual studio solution with all the files ready to create the bundle and the exe, now I only need to create a packege to make the download and replate of the files in an easy way!

    I started ricaun.Revit.Github package this year that the idea is to use the github releases to store the bundle.zip files (ricaun.Nuke.PackageBuilder already does this) and download and replace them in the bundle folder.

    Stay tuned on the Youtube channel for news.

    References