Hi everyone,
I wonder, is it possible to implement an auto-update functionality into the Revit add-in? I understand that the external application can run the code only when called from Revit, but if I place a button "Update add-in" on a ribbon, is there a way to implement it (download and rewrite itself)? If so, has anyone tried this successfully? Is there any code sample?
Thank you in advance,
Martin
Hi @Anonymous
I think that your code needs to copy/paste the new .dll file to the correct location (something like Appdata\Roaming\Autodesk\Revit\Addin\XXXX) to do it. It should work with that.
Regards,
GM
Hi Guillaume,
thank you for the response, yes, this is what I am thinking about. The questions is, is the plugin itself allowed to do that, or shall we implement an external updater application that takes care of the file replacement. I would like to check, if someone has ever faced this question and advice the right path to approach it.
Thank you,
Martin
If you are using Revit to trigger the addin update, and the addin you intend replacing is already loaded, I don't believe that there is a way to unload any loaded addins. You will get a file-in-use error if attempting to overwrite the .addin or .dll files. You could maybe write a trigger file to be used after Revit is closed. For what it may be worth, I use the following to run a batch file, and then copy/overwrite the same batch file when it finishes running. Maybe this could be incorporated. I would be very interested in your (or other) solution. Dale
// start process Process process = new Process(); ProcessStartInfo startInfo = process.StartInfo; startInfo.FileName = lstrBatFileNameFull; startInfo.Arguments = args; // to copy batch file after it has closed process = System.Diagnostics.Process.Start(startInfo); process.WaitForExit(); if (process.HasExited) { File.Copy(lstrBatFileNameFullSource, lstrBatFileNameFullTarget, true); }
I have a separate exe file that I start from my addin while in Revit. The exe watches the process list for Revit.exe. Once Revit.exe isn't in the list of processes (it closed), then I do the file copy/overwrite.
Hi Troy, Now that sounds like a good idea, thanks. Dale
For what it's worth, this is the approach I've used to allow enable our in-house addins to auto-update while they're still loaded:
Create a single 'addin loader' addin / class whose sole purpose is to load other addins (using Assembly.LoadFrom and reflection to instantiate and invoke the IExternalApplication methods and add the IExternalCommand implementors,etc.).
This addin loader scans a predefined folder for any addin files and copies the associated files to a temporary 'shadow' folder where the addins are then loaded. This way the original addin files can be overwritten / updated because they're not locked down.
Of course, you still have to restart Revit for the changes to take effect.
It is possible to do so. I use a "bridge" dll file witch loads and execute the final one. Revit blocks the first one but I can overwrite the real one. I save the final one datetime of creation in a static variable to compare with the date of the assembly to check if it is a new one, to know if I have to load it again. Otherwise, you always load the assembly again and loose the static variables between executions.
This is the code to force Revit to load again the assembly (finalAssemblyFile is the assembly path):
I feel like everyone is making this a much more difficult process then it needs to be.
I've been developing a few Revit add-in's for my company over the past two years. The process we developed is simple.
We have a shared network here, where all our work files are stored and everyone has access. This allows us to share large files. Most firms have this. I have a "Revit Add-in" folder within my own folder, this "Revit Add-in" folder contains a folder for each add-in I am developing. In these individual Add-in folders I have the most updated ".dll" file and the manifest file that points to what ever folder it is in. Ie - just pointing to the ".dll" itself. (<Assembly>AddIn.dll</Assembly>) Also within these individual Add-in folder I also have a short cut to both the Revit 2021 and 2023 folder found at:
c:\user\(user name)\AppData\Roaming\Autodesk\Revit\Addins\2021
The folders are set up so that no matter who clicks the folder it will take them to their individual computers Addins folder. Thus when they drag the ".dll" file and manifest file to that folder it automatically places it into the correct folder for their system. It asks them if they would like to replace the older version and boom, Add-in updated or install complete.
Now that I have that set up, all I do is After I have updated the ".dll" file, I send out a mass email letting everyone know a new version is ready for use. They go into my folder, move the file to their folder short cut and boom.
This has worked flawlessly for us over the past year and a half. It doesn't require IT's help and take minimal time for our users.
In my plugin, each time Revit starts up, it checks if there is any new Release on my private Github, and if true, then a popup ask the user if they want to update, or skip. if they click update, it download the latest release and start the .exe.
Stumbled upon this tread and sharing my twist on this. OnStartup my add-in checks for an updated .dll on a shared drive, if needed it does all the file transfers to "Update" the add-in.
The catch here is that the original .dll is locked from being deleted right?
Well you can actually MOVE or RENAME the locked .dll.
I chose to rename mine DeleteMe.dll and then move the new ones over. The DeleteMe.dll is cleaned up next application startup.
Can't find what you're looking for? Ask the community or share your knowledge.