0

I have a regular VSTO addin for excel(not the web addin). I have an excel file that I have included into my project, but fiddled with the file type and build properties.

The addin uses worksheets in this workbook as templates to create new worksheets.

I've set the file to copy always and that just copies it to the bin folder and not embed it into the VSTO installer when publishing.

When I publish the VSTO addin, how can I embed this workbook so that it is also installed/copied when the VSTO addin is installed? Also, how can I access this file in its installed location?

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
GisMofx
  • 982
  • 9
  • 27

1 Answers1

1

It depends on the installer chosen for publishing the add-in. Basically you have two possible ways:

  1. ClickOnce - see How to: Specify which files are published by ClickOnce and How to: Include a data file in a ClickOnce application.
  2. MSI - if you set the Built Action property to the Content value the file should be added automatically to the installer. Of course, that is possible only if the project output was chosen as the base for the installer. Otherwise, you need to add a file to the installer manually. For more precise actions need to know what installer is used for building the MSI file. See Deploying a VSTO Solution Using Windows Installer for more information.

You can treat your VSTO add-in as a regular .net based application when you are dealing with installers.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • `ClickOnce`. I'm using VS2022 and looking at the publish tab for my project's properties. I don't see an `Application Files` button...Know where that is? looking into the app manifest, but looks like a VSTO project doesn't create one by default.. – GisMofx May 25 '23 at 13:17
  • I have just tried to create a sample VSTO add-in with an XML file added as a content (see the `Build Action` property of the file) and then deploy it using ClickOnce. The target machine had the file deployed correctly. – Eugene Astafiev May 25 '23 at 15:28
  • I have that too.. after installing, how do you access that file at runtime? – GisMofx May 25 '23 at 20:00
  • What was the original question? How to include file to the installer? – Eugene Astafiev May 25 '23 at 20:01
  • Both; how to ensure the file is installed and then how to access it from the addin at runtime – GisMofx May 25 '23 at 20:04
  • At runtime you need to get the assembly's location and read the file content from that folder. – Eugene Astafiev May 25 '23 at 20:44
  • Using this to get the install location: `System.Reflection.Assembly.GetAssembly(typeof(ThisAddIn)).Location;` and the file is not in this folder. Build Action is set to "Content" on my added file. – GisMofx May 26 '23 at 15:20
  • 1
    See [How do I get the path of the assembly the code is in?](https://stackoverflow.com/questions/52797/how-do-i-get-the-path-of-the-assembly-the-code-is-in) – Eugene Astafiev May 26 '23 at 15:26