Search code examples
c#visual-studiovstooffice-addinsexcel-addins

How to embed/include a file into a VSTO addin


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?


Solution

  • 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.