Creating a Bootstrapper package for an Office 2013 VSTO Add-in with Visual Studio 2012

UPDATE from July 2014:  INSTRUCTIONS FOR UPDATING AN EXISTING BOOTSTRAPPER:

On the build machine (which might be the same as your development machine), open the “product.xml” file under

C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\Bootstrapper\Packages\VSTOR40

For “Program Files (x86)”, substitute “Program Files" in you’re on a 32-bit operating system.

For “v8.1A” (which is the location used by VS 2013), substitute:

  • “v8.0A” for Visual Studio 2012
  • “v7.0A” for Visual Studio 2010

 

Once you have found the file, replace the existing version number with the desired version in the following properties:

<BypassIf Property="VSTORuntimeVersionInstalled" Compare="VersionGreaterThanOrEqualTo" Value="10.0.50701"/>

<BypassIf Property="VSTORuntimeVersionOfficeInstalled" Compare="VersionGreaterThanOrEqualTo" Value="10.0.50701"/>

 

(Be sure to substitute the latest version number, based on the file information available at http://go.microsoft.com/fwlink/?LinkId=140384).

image

==============================================

UPDATE FROM MARCH 06, 2013:

We heard your feedback! With the latest release of the Office Developer Tools for Visual Studio 2012 (and subsequently in Visual Studio 2013), you no longer need to manually create a bootstrapper package.

Just make sure to enable the bootstrapper under the "Publish" dialog’s "Prerequisites" settings:

VSTOR Bootstrapper

 

============ Original Post from December 2012 ============

At the SharePoint Conference last month, Preview 2 of the Office Developer Tools for Visual Studio 2012 was announced. The release offers a number of enhancements for VSTO developers: in particular, design-time support for Office 2013, and the ability to develop Add-Ins that target the .NET 4.5 Framework. Preview 2 also includes tooling for the new Apps for Office and Apps for SharePoint projects, Workflow enhancements, VSTA improvements, and much more. See the official announcement to share in the exciting news, or skip straight to downloading the tools.

Here is just a snippet of the VSTO portion of the announcement:

New in this release, Visual Studio Tools for Office (a.k.a. VSTO add-ins) now have design time and runtime support that target Office 2013 and .NET Framework 4.5. This has been a much-requested feature. We also fixed the top customer reported issues in the VSTO runtime for Office 2013. We’re looking forward to hearing your feedback!

Out of the box, Office 2010 SP1 and Office 2013 include a VSTO Runtime version that’s sufficient to run .NET 4.0 add-ins. Thus, if you’re targeting .NET 4.0 – whether or not you install Preview 2 on top of Visual Studio 2012 – customers with Office 2010 SP1 and higher will be able to run your add-ins without any additional installation. If you want to leverage the new .NET 4.5 support and/or ensure that your customers have the latest runtime (which includes some cumulative bug fixes), you will need to follow the steps below to create a Bootstrapper package.

First, create a folder in a convenient location, and name it “VSTOR40”. Eventually, you’ll move this folder to a particular location under “Program Files”, but you may want to place it on your Desktop or “My Documents” for now. That way, you won’t be required to run everything as administrator in order to create or edit files.

As you step through this process, it may help to keep a high-level overview of the end-result in mind. As shown in the image below, you’ll end up with a “VSTOR40” folder that contains “product.xml” and an “en” sub-folder, which in turn contains “eula.1033.txt” and “package.xml”.

image

Let’s start with product.xml. Create a new file, and copy-paste the following contents into it:

<?xml version="1.0" encoding="utf-8" ?>

 

<Product

  xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"

  ProductCode="Microsoft.VSTORuntime.4.0">

  <RelatedProducts>

    <EitherProducts>

      <DependsOnProduct Code="Microsoft.Net.Client.3.5" />

      <DependsOnProduct Code=".NETFramework,Version=v4.0,Profile=Client" />

      <DependsOnProduct Code=".NETFramework,Version=v4.5,Profile=Client" />

    </EitherProducts>

  </RelatedProducts>

  <!– Defines the list of files to be copied on build. –>

  <PackageFiles CopyAllPackageFiles="false">

    <PackageFile Name="vstor_redist.exe" HomeSite="VSTORRedist" PublicKey="3082010a0282010100baa4496c10fb229c65a216983bcb6162fa7429ad8d0619d27158198a5e570d69626e36a04efd2279e01dc71a618efafca3112516c8c0582c318a88ae321e88db7f3e7457f785a43653ca41ef69b8699e6d56eb6ee4b2264d73d16471b41fd66184880021ef6858835b498fb4dfd335d6cbd9309f53fc7a6b9a842bb7216774d4f678b6618798947c2acf67e919bed9ba63ed3c4e3e7d02ebf37fafcf0fb7817ef4fbe8f79148bb8f3d8cc807931cf3bd75e4fc6320299f39f34154381e546440b484aa37aef3008ce20dfaa1b20f22b5a7a9aed617b930f002232010fa6b590fe0ad9f9e608193034c0d9b6219b3bb96bc915aa67886769b6ccd4cec12b538470203010001"/>

  </PackageFiles>

 

  <InstallChecks>

    <RegistryCheck Property="VSTORuntimeVersionOfficeInstalled" Key="HKLM\SOFTWARE\Microsoft\VSTO Runtime Setup\v4" Value="Version"/>

    <RegistryCheck Property="VSTORuntimeVersionInstalled" Key="HKLM\SOFTWARE\Microsoft\VSTO Runtime Setup\v4R" Value="Version"/>

  </InstallChecks>

 

  <!– Defines how to run the Setup package. –>

  <Commands Reboot="Defer">

    <Command

      PackageFile="vstor_redist.exe"

      Arguments=" /q /norestart"

      EstimatedInstalledBytes="2600000"

      EstimatedTempBytes="4500000"

      EstimatedInstallSeconds="60">

      <InstallConditions>

        <BypassIf Property="VSTORuntimeVersionInstalled" Compare="VersionGreaterThanOrEqualTo" Value="10.0.50701"/>

        <BypassIf Property="VSTORuntimeVersionOfficeInstalled" Compare="VersionGreaterThanOrEqualTo" Value="10.0.50701"/>

 

        <!– Requires the user to be an admin user when installing the prerequisite –>

        <FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/>

      </InstallConditions>

      <ExitCodes>

        <ExitCode Value="0" Result="Success"/>

        <ExitCode Value="1641" Result="SuccessReboot"/>

        <ExitCode Value="3010" Result="SuccessReboot"/>

        <DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />

      </ExitCodes>

    </Command>

  </Commands>

</Product>

 

(Be sure to substitute the latest version number, based on the version information available at http://go.microsoft.com/fwlink/?LinkId=140384).

 

Now create an “en” folder, and a file named “package.xml” within it. Into that file, copy-paste the following text:

<?xml version="1.0" encoding="utf-8" ?>

<Package

  xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"

  Name="DisplayName"

  Culture="Culture"

  LicenseAgreement="eula.1033.txt">

  <PackageFiles>

    <PackageFile Name="eula.1033.txt"/>

  </PackageFiles>

 

  <!– Defines a localizable string table for error messages. –>

  <Strings>

    <String Name="DisplayName">Microsoft Visual Studio 2010 Tools for Office Runtime (x86 and x64)</String>

    <String Name="Culture">en</String>

    <String Name="AdminRequired">Administrator permissions are required to install the Microsoft Visual Studio 2010 Tools for Office Runtime (x86 and x64). Contact your administrator.</String>

    <String Name="GeneralFailure">A failure occurred attempting to install the Microsoft Visual Studio 2010 Tools for Office Runtime (x86 and x64).</String>

    <String Name="VSTORRedist">http://go.microsoft.com/fwlink/?LinkId=158918</String>

  </Strings>

</Package>

 

 

Finally, for “eula.1033.txt” (the end-user license agreement for the VSTO Runtime), you can simply re-use the same Eula that shipped with the VSTO Runtime (and which you got on your machine when you installed “Preview 2” of the office tools).

To find that file, simply navigate to one of the following locations:

x64 versions of Windows:

  • C:\Program Files\Common Files\microsoft shared\VSTO\10.0\Microsoft Visual Studio 2010 Tools for Office Runtime (x64)

X86 versions of Windows:

  • C:\Program Files\Common Files\microsoft shared\VSTO\10.0\Microsoft Visual Studio 2010 Tools for Office Runtime (x86)

And copy the “eula.1033.txt” file from there into your “VSTOR40\en” folder.

Almost there! Now all that remains is to copy the folder into the appropriate location on your machine (the same machine you’ll be using to publish the project). To do this:

1) Locate the Bootstrapper packages folder. On a machine where you’ve installed Visual Studio 2012, the default installation locations should be:

x64 version of Windows:

  • C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\Bootstrapper\Packages

x86 version of Windows:

  • C:\Program Files\Microsoft SDKs\Windows\v8.0A\Bootstrapper\Packages

If the folder is not there, you can determine the location by looking it up in the registry – see http://msdn.microsoft.com/en-us/library/ms165429.aspx for more information.

2) Move your VSTOR40 folder into the Bootstrapper packages folder that you’ve identified above. In the end, your path and folder structure should look like this:

VSTOR40

You’re done! After you close and re-open Visual Studio, you should be able to activate the VSTO Runtime Bootstrapper prerequisite. To do this, open your project, go to the project’s properties, and then navigate to the “Publish” tab. Under the “Install Settings” group, click on the “Prerequisites…” button. In the window that opens, set the checkmark next to

“Microsoft Visual Studio 2010 Tools for Office Runtime (x86 and x64)”.

Publish

That’s it! After you publish your solution, end-users who don’t have the VSTO Runtime will automatically get the latest version of the runtime from the web.

Questions? Comments? Don’t hesitate to ask.

~ Michael Zlatkovsky | Program Manager, Visual Studio Tools for Office & Apps for Office