Quantcast
Channel: Category Name
Viewing all articles
Browse latest Browse all 10804

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

$
0
0

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:

xmlversion="1.0"encoding="utf-8" ?>

 

<Product

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

  ProductCode="Microsoft.VSTORuntime.4.0">

  <RelatedProducts>

    <EitherProducts>

      <DependsOnProductCode="Microsoft.Net.Client.3.5" />

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

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

    EitherProducts>

  RelatedProducts>

 

  <PackageFilesCopyAllPackageFiles="false">

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

  PackageFiles>

 

  <InstallChecks>

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

  InstallChecks>

 

 

  <CommandsReboot="Defer">

    <Command

      PackageFile="vstor_redist.exe"

      Arguments=" /q /norestart"

      EstimatedInstalledBytes="2600000"

      EstimatedTempBytes="4500000"

      EstimatedInstallSeconds="60">

      <InstallConditions>

        <BypassIfProperty="VSTORuntimeVersionInstalled"Compare="VersionGreaterThanOrEqualTo"Value="10.0.40303"/>

 

       

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

      InstallConditions>

      <ExitCodes>

        <ExitCodeValue="0"Result="Success"/>

        <ExitCodeValue="1641"Result="SuccessReboot"/>

        <ExitCodeValue="3010"Result="SuccessReboot"/>

        <DefaultExitCodeResult="Fail"FormatMessageFromSystem="true"String="GeneralFailure" />

      ExitCodes>

    Command>

  Commands>

Product>

 

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

xmlversion="1.0"encoding="utf-8" ?>

<Package

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

  Name="DisplayName"

  Culture="Culture"

  LicenseAgreement="eula.1033.txt">

  <PackageFiles>

    <PackageFileName="eula.1033.txt"/>

  PackageFiles>

 

 

  <Strings>

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

    <StringName="Culture">enString>

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

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

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

  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


Viewing all articles
Browse latest Browse all 10804

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>