Author Topic: Updating Add-ins from server  (Read 10598 times)

0 Members and 1 Guest are viewing this topic.

Jeff H

  • Needs a day job
  • Posts: 6150
Updating Add-ins from server
« on: March 31, 2017, 01:39:43 AM »
I will go more detail in later post if needed but attached is project that should work for 2016 and from description below and looking at code should be able to figure out how it works.

This has worked well for me for everyone getting the latest dlls, cuix, etc..  in an environment where there is a
  • local server
  • everyone has access to the server, and are mapped with same drive letter
  • for installation just sent out email with link to app.bundle folder to copy and paste into their %appdata%\Autodesk\ApplicationPlugins
  • a machine for development is connected to the server
The attachment contains the following folders with short description.
  • Server Folder - This is meant to mimic the server folder and there are few things you need to change to path of this folder
  • TheSwamp - This contains the Solution with 3 projects
    • TheSwampAddinLoader - This just opens the TheSwampAddinLoader.loadconfig file to get the "UpdateDirectory" value which should be the path of where the TheSwampAddInLoaderData.loadData file and all files that need to be copied or updated are located
    • TheSwampAddin1 - all files for this project are first copied and overwritten if newer then is loaded by TheSwampAddinLoader
    • TheSwampAddin2 - all files for this project are first copied and overwritten if newer then is loaded by TheSwampAddinLoader
  • TheSwamp.AddinLoader.bundle  This contains the app.bundle folder with TheSwampAddinLoader.loadconfig file
Here is how it works.
  • The TheSwamp.AddinLoader.bundle uses the AutoLoader functionality to load in TheSwampAddinLoader.dll.
  • It looks in same folder as TheSwampAddinLoader.dll for TheSwampAddinLoader.loadconfig file which is an xml file with "UpdateDirectory"with the location of TheSwampAddInLoaderData.loadData file. It will copy all files from "UpdateDirectory" into the TheSwamp.AddinLoader.bundle folder using the parameters set by .loadata file. In the attached project UpdateDirectory="%userprofile%\Documents\Visual Studio 2015\Projects\Server Folder\TheSwampApps\v20.1" which contains the TheSwampAddInLoaderData.loadData file and files to be copied
  • The TheSwampAddInLoaderData.loadData file tells what files type of files to copy, if it should copy sub-directories, and which files to Load into AutoCAD.


How to get it working after download and unziping.
  • Edit the ~\TheSwamp.AddinLoader.bundle\Contents\Windows\2016\TheSwampAddinLoader.loadconfig file by changing the value of "UpdateDirectory" to the location of ~\Server Folder\TheSwampApps\v20.1 where  where it resides on your computer now
  • Copy and paste the TheSwamp.AddinLoader.bundle folder to %appdata%\Autodesk\ApplicationPlugins folder
  • Start AutoCAD
  • Edit TheSwampAddin1 and/or TheSwampAddin2
  • Use the ServerRelease configuration to build project(The ServerRelease is just the Release build with output folder set to location of .loaddata file so it puts dll and any referenced dll into folder to be copied)
  • Close and Start AutoCAD


TheSwampAddinLoader.loadconfig
Code: [Select]
<?xml version="1.0" encoding="utf-8" ?>
<AddInLoaderUpdatePath
  UpdateDirectory="%userprofile%\Documents\Visual Studio 2015\Projects\Server Folder\TheSwampApps\v20.1">
</AddInLoaderUpdatePath>
TheSwampAddInLoaderData.loadData
Code: [Select]
<?xml version="1.0" encoding="utf-8" ?>
<AddInLoaderData CopySubDirectories ="false" ExtensionFilter =".dll|.cuix|.mnr">
  <LoadFiles>
     <LoadFile>TheSwampAddin1.dll</LoadFile>
    <LoadFile>TheSwampAddin2.dll</LoadFile>   
  </LoadFiles>
</AddInLoaderData>
« Last Edit: March 31, 2017, 01:44:27 AM by Jeff H »

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: Updating Add-ins from server
« Reply #1 on: March 31, 2017, 08:00:38 AM »
Nice work Jeff.  I've been working on something similar that uses FileSystemWatcher to look for folder changes then prompts the user. If the user chooses to update, it spins up the updater, and shuts down Autocad.  The updater waits for Autocad to shut down and copies over the files then fires up Autocad again and shuts down.
Revit 2019, AMEP 2019 64bit Win 10

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Updating Add-ins from server
« Reply #2 on: March 31, 2017, 09:39:40 AM »
Nice work Jeff.  I've been working on something similar that uses FileSystemWatcher to look for folder changes then prompts the user. If the user chooses to update, it spins up the updater, and shuts down Autocad.  The updater waits for Autocad to shut down and copies over the files then fires up Autocad again and shuts down.
Thanks,
If it was used for something main stream or commercially available app then would need something like you got.

Atook

  • Swamp Rat
  • Posts: 1029
  • AKA Tim
Re: Updating Add-ins from server
« Reply #3 on: March 31, 2017, 01:52:48 PM »
Great stuff Jeff, thanks for posting example code and an explanation.

pBe

  • Bull Frog
  • Posts: 402
Re: Updating Add-ins from server
« Reply #4 on: April 05, 2017, 11:21:28 AM »
Hi Jeff H,

Great code, one question though. I change  R20.1 to 19.0...

Code - C#: [Select]
  1. <RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD|AutoCAD*" SeriesMin="R19.0" SeriesMax="R21.0" />

It worked with versions 14,16 and 17 but not with Autocad 2015? Is it just me or there's something else that needs changing?

Thank you in advance.

pBe

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Updating Add-ins from server
« Reply #5 on: April 05, 2017, 12:06:17 PM »
Hi Jeff H,

Great code, one question though. I change  R20.1 to 19.0...

Code - C#: [Select]
  1. <RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD|AutoCAD*" SeriesMin="R19.0" SeriesMax="R21.0" />

It worked with versions 14,16 and 17 but not with Autocad 2015? Is it just me or there's something else that needs changing?

Thank you in advance.

pBe
Not sure I had mine broken out into separate folders for each year(also the builds had a separate "Update folder") and below is what I used unmodified. It worked for 2015 and I do not see anything that would need changing. I got 2015 and will try testing it here later today with the attached example.
Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<ApplicationPackage SchemaVersion="1.0" AutodeskProduct="AutoCAD" ProductType="Application" Name="HpadCad" AppVersion="1.0.0" Description="AutoCAD Plug-in" Author="Jeff H" ProductCode="{FF4A6B1C-33C3-7DM3-8F61-423D6048EFA8}">
<CompanyDetails Name="Hpad" Phone=" " Url=" " Email="" />
<Components>
<RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD|AutoCAD*" SeriesMin="R19.0" SeriesMax="R19.0" />
<ComponentEntry AppName="HpadCad.AddinLoader" ModuleName="./Contents/Windows/2013/HpadCad.AddinLoader.dll" LoadOnAutoCADStartup="true"/>
</Components>
<Components>
<RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD|AutoCAD*" SeriesMin="R20.0" SeriesMax="R20.0" />
<ComponentEntry AppName="HpadCad.AddinLoader" ModuleName="./Contents/Windows/2015/HpadCad.AddinLoader.dll" LoadOnAutoCADStartup="true"/>
</Components>
<Components>
<RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD|AutoCAD*" SeriesMin="R20.1" SeriesMax="R20.1" />
<SystemVariables>
<SystemVariable Name="LAYERMAPSTYLE" PrimaryType="String" StorageType="Database" Value="Standard" Flags="Create"/>
</SystemVariables>
<ComponentEntry AppName="HpadCad.AddinLoader" ModuleName="./Contents/Windows/2016/HpadCad.AddinLoader.dll" LoadOnAutoCADStartup="true"/>
</Components>
</ApplicationPackage>

pBe

  • Bull Frog
  • Posts: 402
Re: Updating Add-ins from server
« Reply #6 on: April 05, 2017, 12:13:10 PM »
Thank you for the quick reply Jeff H. I will try this as soon as i get back to the work.

It's beer time :)

pBe

  • Bull Frog
  • Posts: 402
Re: Updating Add-ins from server
« Reply #7 on: April 06, 2017, 06:00:33 AM »
I'm still not getting why plugins skips 2015, it reads the XML but doesn't load the DLL.

Can you give it a try with the attached test bundle from ADN DevBlog. It runs on all versions except 2015.

..
Command: RunMeFirst
Unknown command "RUNMEFIRST".  Press F1 for help.
..

while the rest has [ 14, 16 and 17 ]
..
Command: RunMeFirst
Hello World
..

Any ideas?

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Updating Add-ins from server
« Reply #8 on: April 06, 2017, 09:29:17 AM »
I thought I had 2015 installed but I must of un-installed it.
For 2015 I think it should be
Code: [Select]
SeriesMin="R20.0" SeriesMax="R20.0"

pBe

  • Bull Frog
  • Posts: 402
Re: Updating Add-ins from server
« Reply #9 on: April 06, 2017, 03:07:49 PM »
Jeff H,

I installed a fresh copy of Autocad 2015 on a my home computer , and what do you know, "THESWAMP" appeared on the on the Ribbon Panel. Close 2015 and restart 2015. Its still there.

I then launch Autocad 2017 and it works as expected. Yipee!!!

But wait..

Start Autocad 2015 again... gone... and the only hint i got is the "Beep" sound

Code - C#: [Select]
  1.         public void Initialize()
  2.         {
  3.             try
  4.             {
  5.                 Loader load = new Loader();
  6.                 load.Load();
  7.             }
  8.             catch (Exception)
  9.             {
  10.                 Console.Beep();  /// <--- This beep not the one on the ExtensionApplication Class
  11.                 throw;
  12.             }
  13.         }

What do you make of it?

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Updating Add-ins from server
« Reply #10 on: April 06, 2017, 03:52:39 PM »
Did you have 2017 and 2015 open at same time?
I have not had problems having multiple instances of acad open same or different year, but the versions had separate folders and addinloaders.
 

pBe

  • Bull Frog
  • Posts: 402
Re: Updating Add-ins from server
« Reply #11 on: April 07, 2017, 02:29:56 PM »
Not at the same time, I did create two sets of addinloaders [  2015/2017 ] but still no joy. still hearing the beep which means it recognize the xml.

It appears that both TheSwampAddinLoader.dll and TheSwampAddin1.dll did not finish its task. The cuix wasnt loaded and the files are not copied, also Unknown command "THESWAMP".  Press F1 for help.

The thing that gets me is it works on 14 , 16 and 17 using just one set of dlls. Were you able to test 2015 on your end?

Thanks
« Last Edit: April 07, 2017, 02:36:07 PM by pBe »

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Updating Add-ins from server
« Reply #12 on: April 10, 2017, 09:48:00 AM »
I did use it for 2015, but uninstalled it. I am confrused also why its not working.

pBe

  • Bull Frog
  • Posts: 402
Re: Updating Add-ins from server
« Reply #13 on: April 10, 2017, 01:14:36 PM »
I ended up using this for Autocad 20105
Code - Auto/Visual Lisp: [Select]
  1. <RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD|AutoCAD*" SeriesMin="R20.0" SeriesMax="R20.0" />
  2.     <ComponentEntry AppName="Appname" " ModuleName="./Contents/Resources/Company.lsp" PerDocument="True" LoadOnAutoCADStartup="true" LoadOnCommandInvocation="True"/>
  3.    <ComponentEntry AppName=""Appname"  ModuleName="./Contents/Resources/2015/Company.cuix" AppDescription="Company CuiX"  AppType="CuiX"/>  

But it does not copy/update files from the Server Folder like it does for 2017. I'm not even sure loading a partial cuix from XML is a good thing.

Sure hope you anyhone can come up with an answer on why TheSwamp Loader is not working om 2015.

Question for you: Can we call an EXE file from the PackageContents.xml?

BTW: Thank for all your help.

EDIT: Makes me wonder did it ever worked on 2015 as i mentioned on the other post. I wanted it to work so bad that i imagined it working the first time
« Last Edit: April 10, 2017, 01:17:50 PM by pBe »

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Updating Add-ins from server
« Reply #14 on: April 10, 2017, 02:17:45 PM »
I ended up using this for Autocad 20105
Code - Auto/Visual Lisp: [Select]
  1. <RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD|AutoCAD*" SeriesMin="R20.0" SeriesMax="R20.0" />
  2.     <ComponentEntry AppName="Appname" " ModuleName="./Contents/Resources/Company.lsp" PerDocument="True" LoadOnAutoCADStartup="true" LoadOnCommandInvocation="True"/>
  3.    <ComponentEntry AppName=""Appname"  ModuleName="./Contents/Resources/2015/Company.cuix" AppDescription="Company CuiX"  AppType="CuiX"/>  

But it does not copy/update files from the Server Folder like it does for 2017. I'm not even sure loading a partial cuix from XML is a good thing.

Sure hope you anyhone can come up with an answer on why TheSwamp Loader is not working om 2015.

Question for you: Can we call an EXE file from the PackageContents.xml?

BTW: Thank for all your help.

EDIT: Makes me wonder did it ever worked on 2015 as i mentioned on the other post. I wanted it to work so bad that i imagined it working the first time
I know I used it on 2015 for months. I will see if I can find a copy of 2015 to try it on.

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Updating Add-ins from server
« Reply #15 on: April 12, 2017, 03:00:42 PM »
Someone here has 2015 on their computer and will test it when they leave today.

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Updating Add-ins from server
« Reply #16 on: April 13, 2017, 01:15:05 PM »
I tested on two different Windows 7 machines with AutoCAD 2015 and worked fine.
Attached is zip file where Projects folder is in Documents folder of user.

You could also edit the catch block print out the exception message and see what it is.

pBe

  • Bull Frog
  • Posts: 402
Re: Updating Add-ins from server
« Reply #17 on: April 14, 2017, 04:20:49 AM »
... You could also edit the catch block print out the exception message and see what it is.

Now why didn't i think of that before. Using Windows 10 and Autocad 2015

Here is the error message Jeff_H, thank you for your patience.

Object reference not set to an instance of an object

Works on Autocad 2017 on the same machine.
« Last Edit: April 14, 2017, 11:45:07 AM by pBe »

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Updating Add-ins from server
« Reply #18 on: April 14, 2017, 10:55:36 AM »
... You could also edit the catch block print out the exception message and see what it is.

Now why didn't i think of that before. Using Windows 10 and Autocad 2015

Here is the error message Jeff_H, thank you for your patience.

Object reference not set to an instance of an object

Works on Autocad 2017 on the same machine.
I know I used on a machine with windows 10 for 2015 also.

Can you tell which object is null?
That will definitely narrow down and figure out what is going on.

pBe

  • Bull Frog
  • Posts: 402
Re: Updating Add-ins from server
« Reply #19 on: April 14, 2017, 11:44:43 AM »
Thank you Jeff H

Here's what i did

Code - C#: [Select]
  1.                 public Loader()
  2.         {
  3.                 _ed = Application.DocumentManager.MdiActiveDocument.Editor;
  4.                 _netLoaderDirectoryPath = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
  5.                 System.Windows.Forms.MessageBox.Show("Loader " + _netLoaderDirectoryPath.ToString());
  6.         }

Shows path on 2017
Shows error on 2015 and skipped the first MessageBox

Hope this makes sense.

Thank you for looking into this

EDIT: I think it never got passed _ed

Code - C#: [Select]
  1.             _ed = Application.DocumentManager.MdiActiveDocument.Editor;
  2.             System.Windows.Forms.MessageBox.Show(_ed.ToString());                      
  3.             _netLoaderDirectoryPath = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
« Last Edit: April 14, 2017, 01:18:02 PM by pBe »

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Updating Add-ins from server
« Reply #20 on: April 14, 2017, 08:58:37 PM »
Try this one on 2015 only and see what the messagebox displays


pBe

  • Bull Frog
  • Posts: 402
Re: Updating Add-ins from server
« Reply #21 on: April 15, 2017, 02:42:34 AM »
Jeff H

Good day to you.

I'm using Visual Studio 2015 / Windows 10 / Autocad 2015.

I copied the files/folders as shown on post #1. Launch Autocad 2015, no message box, no  beep but files were copied. 
Edit the TheSwampAddin1 and update, same result

I now rebuild the whole solution and replace files on the bundle folder, Launch Autocad 2015, It shows the same error as the previous post for 2015 and a beep.

Run Autocad 2017 the first time since i replaced the files from project.zip, the files were copied and cuix loaded.

I then edited the PackageContents.xml contents and replace TheSwampAddin1.dll with of TheSwampAddinLoader.dll. and manually copied the cuix files to .\Autodesk\ApplicationPlugins\TheSwamp.AddinLoader.bundle\Contents\Windows\2016

Code - Auto/Visual Lisp: [Select]
  1. <ComponentEntry LoadOnAutoCADStartup="true" ModuleName="./Contents/Windows/2016/TheSwampAddin1.dll" AppName="TheSwampAddinLoader"/>

The cuix loaded on 2015 and 2017. it appears the Loader class is having an issue with 2015 and/or Windows 10. Not really sure whats happening kind sir.

Thank you
« Last Edit: April 15, 2017, 02:45:59 AM by pBe »

pBe

  • Bull Frog
  • Posts: 402
Re: Updating Add-ins from server
« Reply #22 on: July 15, 2019, 03:25:28 PM »
Hi Jeff,

Is there a version of this for Revit?


Jeff H

  • Needs a day job
  • Posts: 6150
Re: Updating Add-ins from server
« Reply #23 on: July 15, 2019, 03:43:03 PM »
I never built one for Revit.


pBe

  • Bull Frog
  • Posts: 402
Re: Updating Add-ins from server
« Reply #24 on: July 19, 2019, 07:14:58 AM »
No worries Jeff H. I will try to configure it to work with Revit. Thanks for all your help .