need to create folders within VSTO setup program

Started by perry59, November 22, 2020, 11:23:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

perry59

I am using Nikolay's excellent visual studio template to make addins for visio.
in the area where I publish my stencils and templates I would like it to create subfolders , i.e. "stencils" and place the stencils there.
I thought that by specifying a folder in the code (product.wxs) like so:

<Component>
        <File Name="Airframes.vss">
            <visio:PublishStencil MenuPath="VisioElectrical\Stencils\Airframes" />
        </File>
    </Component>

it would do as I wanted, but this does not seem to be the case. Does anyone know how to get the wix setup file to create the subfolders, then publish the files to them?

thankns!
what, me worry?

Nikolay

#1
The code you showed should actually creates a "fake folder" in Visio context menu, (where you choose the stencils), but not a physical folder in the file system:



If you want a physical folder (and you have a single stencil), you can do it like this:

    <Feature Id="ProductFeature" Title="Setup" Level="1">
      <ComponentGroupRef Id="AddinFiles"/>
      <ComponentRef Id="MyStencilComponentId" />                  <<<< add this, "MyStencilComponentId" is the id of the stencil component
    </Feature>


    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="APPLICATIONFOLDER" Name="<your name>">
       
          <Directory Id="MyStencilDirectoryId" Name="<your stencils folder>" />            <<< add this (your directory for stencils)
       
        </Directory>
      </Directory>
    </Directory>

    <Component Id="MyStencilComponentId" Directory="MyStencilDirectoryId">          <<< make sure you have "Directory" set to the directory id above.
        <File Name="Airframes.vssx">
            <visio:PublishStencil MenuPath="VisioElectrical\Stencils\Airframes" />
        </File>
    </Component>


If you have multiple stencils, you could do it like this:


    <Feature Id="ProductFeature" Title="Setup" Level="1">
      <ComponentGroupRef Id="AddinFiles"/>
      <ComponentGroupRef Id="MyStencilsCompoenntGroupId" />              <<<< include stencil components into installer
    </Feature>


    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="APPLICATIONFOLDER" Name="<your name>">

          <Directory Id="MyStencilsDirectoryId" Name="<your stencils folder>" />           <<<< your directory for stencils

        </Directory>
      </Directory>
    </Directory>


    <ComponentGroup Id="MyStencilsCompoenntGroupId" Directory="MyStencilsDirectoryId">     <<<< define stencil components

      <Component>
        <File Name="Airframes1.vss">
          <visio:PublishStencil MenuPath="VisioElectrical\Stencils\Airframes1" />
        </File>
      </Component>

      <Component>
        <File Name="Airframes2.vss">
          <visio:PublishStencil MenuPath="VisioElectrical\Stencils\Airframes2" />
        </File>
      </Component>

    </ComponentGroup>



Sorry for the complications, but I could say this is not exactly my fault :D
If something can be done in two easy and obvious ways, windows installer chooses the third one, which is neither obvious nor easy :D

The thing it windows installer allows you to install features separately (when you have "choices" window what to install).
By default, there is a single "feature" (called "ProductFeature"), but you could for example make stencil installation optional.

Check out WiX documentation also (it is used as a setup tool):
https://wixtoolset.org/documentation/

BTW, if you don't want your stencil to be available in the context menu, you can remove the <visio:PublishStencil /> thing altogether (but keep the <File ... /> item)

perry59

yay Nikolay your still here!
If anyone had the answer it would be you.
I'll try this out, thank you!
-Perry
what, me worry?

perry59

well, it was not a simple matter of cut&paste of your code example (even after filling in your "yourname" place holders)
had some missing ID stuff and some duplicate ID stuff (Directory:Applicationfolder)
I'll have to do a little more hacking and hopefully get it working.
Thanks Nikolay!
what, me worry?

Nikolay


perry59

Quote from: Nikolay on November 25, 2020, 02:06:43 PM
If any questions, don't hesitate to drop me email directly: support@unmanagedvisio.com

Thanks Nikolay, you da man!
I'll work on it over the long weekend
what, me worry?

perry59

what, me worry?

perry59

had a moment of panic while working on this.
addin would not register after compile. Swapped in my older version and it started registering again then began adding back in the new stuff. continued to register fine even though I ended up with the very same product.wxs file that had previously failed. Strange. While browsing the registry though I found entries for my addin's stencils that do not look right (see attached). has anyone else seen this kind of data in there addins?
Perry
what, me worry?

perry59

on a side note, had a helluva time trying to get my addin to use the config file (settings) I created for it, specifically it just remembers positions of dialog boxes.
it works just fine when running the addin from the compile directory but the config file would not be copied to the actual install directory via the MSI file so when running the installed adding (not from the compile directory) I would get a bunch of errors. I read in a couple places that .dll's can't use config files, but that cant be true because like I said it worked fine from the compile directory. tried all kinds of stuff. finally I just put this code into my product.wxs file like I was installing another file ...
<Component>
     <File Source="VisioElectrical.dll.config" ></File>
</Component>
and the MSI now copies it to the actual installation directory and the addin finds it just fine.
what a pain!
if a project contains a configuration file the compiler should include it in the installation by default!
-Perry
what, me worry?

Nikolay

This probably should be included by default, right - the template does not include the .dll.config file now.

Created a bug for this:
https://github.com/nbelyh/VisioPanelAddinVSTO/issues/11

perry59

cool!
I hope the way I did it is appropriate, seems to work ok!
Perry
what, me worry?