6 Replies Latest reply on Jan 5, 2018 10:34 AM by Matthew Cempa

    Visual Studio Installer TARGETDIR location

    Matthew Cempa

      I'm using a visual studio installer project to install my addin.  I've done this on a 32Bit version of SWX a few years back and I used as Custom Action to run a .bat file from a command window.  The custom action ran cmd.exe with an argument of /c "[TARGETDIR]\Register.bat" which worked fine.  However now with 64bit SWX 2017 it appears that the installation folder is C:\Program Files (x86)\... but I believe the TARGETDIR parameter is pointing to C: \Program Files and therefore my install fails on the commit step to run the custom action.  I have the project being compile for Any CPU.  I've tried messing around with setting it to x64 but I get compile errors with that setting.  Anyone have the magic incantation to make this work or a different way to register the add-in during install that would work better?

        • Re: Visual Studio Installer TARGETDIR location
          Jacob Corder

          post your .bat file text here.


          solidworks 64 bit 2017 should not be in C:\Program Files (x86)\SOLIDWORKS Corp.

          it sould be in

          C:\Program Files\SOLIDWORKS Corp\ Solidworks(Maybe a number)


          i dont fully understand why you are running a custom action that needs the solidworks directory.


          if you do use

          2017 SOLIDWORKS API Help - GetExecutablePath Method (ISldWorks)

          Dim Path as string

          Path = swapp.GetExecutablePath

          path = system.io.path.getdirectoryname(path)


          this is the directory to the current solidworks session.

          • Re: Visual Studio Installer TARGETDIR location
            Matthew Cempa

            Could this be the issue?  I'm using Visual Studio 2010 which the post seems to indicate that it will build a 32bit installer.  Could that be the reason it is installing the x86 program files folder?



            "Depending on the version of Visual Studio you are using, and the version of SOLIDWORKS you are targeting, you may have to handle registration yourself.  This is because in some versions of Visual Studio, the built in installer project produces a 32-bit installer binary, which will use the 32-bit .NET registration tools, which modify the 32-bit registry.  If you are targeting a 64-bit version of SOLIDWORKS, it will not be able to find your registry entries.  This issue popped up for me because I am using Visual Studio 2015 community edition with the Visual Studio 2015 Installer Projects pack installed, and I was targeting Solidworks 2014 64-bit edition and SOLIDWORKS 2016 (which is all 64 bit)."

              • Re: Visual Studio Installer TARGETDIR location
                Jacob Corder

                getting the installer to work properly is a pain in the butt.

                Make sure the installer program is set up to use X64 for TargetPlatform

                make sure the addin is set to use X64 for Target CPU.


                verify that multiple configurations of builds aren't your problem.

                make sure the primary output assembly is set to register vsdrpCOM


                right click Installer

                click on Registry


                Set your guid here


                i had to do this a while ago also

                  • Re: Visual Studio Installer TARGETDIR location
                    Matthew Cempa

                    Ok so I was able to get it to install to Program Files rather than Program Files (x86) with making those changes.  (I needed to re-reference the SolidWorksTools library to get it to compile for x64)  However my commit action still failed.  I tried specifying an absolute path instead of using TARGETDIR and that failed as well.  After some surfing the net I found an article that said the way I'm trying will not work if you compile on a Windows 10 platform and try to install on a Windows 7 platform.  Thus I believe this to be my issue.  I will try the methods that were suggested on that site and post my results.  Thanks for getting me this for though!