Specifying a Product Name, Publisher Name and other properties for VSTO solutions (Saurabh Bhatia)

  • Comments 21

 

Many customers have requested how to specify options like a Product or Publisher Name for Office 2007 VSTO solutions deployed from Visual Studio 2008. However, you cannot specify these properties in the Visual Studio IDE. In this post, I will describe the various other options you have to specify these properties.

Specifically we will be looking at the following properties:

Product Name – This is what the VSTO solution will be called in the Programs and Features (Add Remove Programs Entry)

Publisher Name – The name of the Publisher as displayed in Programs and Features

clip_image002[11]

Figure 1 : Programs and Features Dialog in Vista showing Product Name and Publisher Name

Friendly Name – This is the name of the VSTO solution as it is displayed in the Office Add-ins dialog, the same value is also used in the VSTO trust prompt. Usually this value should be the same as the Product Name.

Office Application Description – The description of the Office Add-in.

clip_image004[9]

Figure 2 : Excel Add-ins Dialog showing Friendly Name and Office Application Description

SupportURL - End Users can click on the product name on the Trust Prompt dialog and visit a custom website related to the Solution.

clip_image006[12]

Figure 3 : VSTO Trust Prompt with Friendly Name and link to SupporURL

The easiest way to specify these properties is to modify the Deployment and Application manifests for the VSTO solution (.vsto and .dll.manifest files).

To specify the Product, Publisher and SupportURL properties

The product name, publisher name and support url properties can all be specified in the deployment manifest, the .vsto file that is generated after publishing the solution. You can open the deployment manifest in a text editor and change the <description> tag to include the properties you want to specify.

<description asmv2:publisher="Visual Studio (BizApps)" asmv2:product="My VSTO Solution" asmv2:supportUrl="http://www.microsoft.com/" xmlns="urn:schemas-microsoft-com:asm.v1" />

Once you have modified the deployment manifest you need to resign it. This can be done using the Manifest Generation and Editing Tool (mage.exe) in the .NET Framework SDK, Windows SDK, or Visual Studio 2008.

Start the Visual Studio command prompt and use mage.exe to resign the deployment manifest:

mage –sign deploymentmanifest.vsto –Certfile Certificate.pfx

Example:

mage –sign MyExcelAddin.vsto –CertFile MyCert.pfx

To specify Friendly Name and Office Application Description:

The Friendly Name and Office Application Description properties can be found in the application manifest under the VSTOV3 namespace.

The application manifest (the MySolution.dll.manifest file) will typically be found under the Application Files\MySolution_X_X_X_X\ folder where the X’s describe the latest published version of the solution.

You can open the application manifest and change these properties:

<vstov3:customization xmlns:vstov3="urn:schemas-microsoft-com:vsto.v3">
<vstov3:appAddIn application="Excel" loadBehavior="3" keyName="ExcelAddIn9">
<vstov3:friendlyName>My VSTO Solution</vstov3:friendlyName>
<vstov3:description>A Sample Add-in created to show the add-in properties work</vstov3:description>
</vstov3:appAddIn>
</vstov3:customization>

After you have changed the application manifest, you need to re-sign the application manifest itself. In addition you will also need to refresh the deployment manifest so that it has the new hash for the application manifest. Lastly you need to re-sign the deployment manifest.

The three steps after editing the application manifest can be performed using mage:

Resign application manifest:

Mage –sign applicationmanifest.dll.manifest –Certfile certfile.pfx
Example:
Mage –sign “Application Files\MyVsto_1_0_0_0\myvsto.dll.manifest” –Certfile ..\myvsto.pfx

Update deployment manifest:

Mage –update deploymentmanifest.vsto -AppManifest applicationmanifest.manifest
Example:
Mage –update myvsto.vsto -AppManifest “Application Files\MyVsto_1_0_0_0\myvsto.dll.manifest”

Resign deployment manifest:

Mage –sign deploymentmanifest.vsto –Certfile Certificate.pfx
Example:
Mage –sign MyExcelAddin.vsto –CertFile MyCert.pfx

Your VSTO solution will now have these properties. The downside of this approach is that you will have to perform these manual steps after every publish. If you want to avoid these manual steps, you can make some changes to the VSTO build targets such that these properties are picked up by Visual Studio during publish. The general idea is that you can specify these properties in your Visual Studio project file (the .vbproj or .csproj) which will in turn be picked up by the build tasks so that they are automatically inserted into the manifest for every publish.

Changing your targets file is a risky scenario; if you change something incorrectly, none of your projects will build. So to be safe, the first thing you should do is make backups of the files that you are going to change.

Also to be safe, we will not be editing the main target file but a copy of it. Any VSTO project that you want to specify the publish properties for will use this new modified targets file.

One more thing to consider before modifying the targets file is that your project may not build correctly if you use the modified targets file and later update the Visual Studio version. If you update Visual Studio, you will have to make the corresponding changes in the new Visual Studio targets file.

Creating a backup and modifying the targets file

The file we will be modifying is: Microsoft.VisualStudio.Tools.Office.Office2007.targets,which can be found in the following directory: %ProgramFiles%\MSBuild\Microsoft\VisualStudio\v9.0\OfficeTools

To open the targets file

  1. Create a backup. Copy the file to a safe location (cannot emphasize this enough).
  2. Create another copy that you will be editing.
    • Create a copy of the file and save it to your Visual Studio 2008 folder under Documents. On Vista : C:\Users\username\Documents\Visual Studio 2008
      On XP: C:\My Documents\Visual Studio 2008
    • Rename the filename to : Microsoft.VisualStudio.Tools.Office.Office2007_Properties.targets
    • You will be modifying this file for the remaining steps.

3. Open the Microsoft.VisualStudio.Tools.Office.Office2007_Properties.targets file in your favorite text editor.

To change the targets file to support Product Name

In this example, we treat Friendly Name to be the same as Product Name.

  1. Find the comment for Add-in Options section: <!-- Add-In options -->
    The comment is usually followed by the LoadBehavior tag: <LoadBehavior>3</LoadBehavior>
  2. In the Add-in Options section before the LoadBehavior tag add the following line:
    <ProductName Condition=" '$(ProductName)' == '' ">$(TargetName)</ProductName>
    Quote sequence:
    Condition = <doublequote><singlequote> $(ProductName) <singlequote> == <singlequote><singlequote><doublequote>
  3. Find all instances of FriendlyName. Usually the FriendlyName is assigned to $TargetName: FriendlyName="$(TargetName)"
    Change all instances to: FriendlyName = “$(ProductName)”
    There will be three places in all where you need to update FriendlyName.
  4. Search for Target GenerateDeploymentManifestForPublishing:
    <Target Name="GenerateDeploymentManifestForPublishing">
  5. Inside this target there is a GenerateDeploymentManifest task:
    <GenerateDeploymentManifest
    EntryPoint="@(ApplicationManifestWithPathForPublishingCollection)"
    AssemblyName="$(DeploymentManifestFileName)"
    AssemblyVersion="$(PublishVersion)"
    MapFileExtensions="$(MapFileExtensions)"
    OutputManifest="@(DeploymentManifestWithPathForPublishingCollection)"
    Platform="$(PlatformTarget)"
    Install="false"
    />
  6. Add a Product attribute to this task:
    <GenerateDeploymentManifest
    EntryPoint="@(ApplicationManifestWithPathForPublishingCollection)"
    AssemblyName="$(DeploymentManifestFileName)"
    AssemblyVersion="$(PublishVersion)"
    Product="$(ProductName)"
    MapFileExtensions="$(MapFileExtensions)"
    OutputManifest="@(DeploymentManifestWithPathForPublishingCollection)"
    Platform="$(PlatformTarget)"
    Install="false"
    />

To change the targets file to support Publisher Name

  1. Search for Target GenerateDeploymentManifestForPublishing:
    <Target Name="GenerateDeploymentManifestForPublishing">
  2. Inside this target there is a GenerateDeploymentManifest task:
    <GenerateDeploymentManifest
    EntryPoint="@(ApplicationManifestWithPathForPublishingCollection)"
    AssemblyName="$(DeploymentManifestFileName)"
    AssemblyVersion="$(PublishVersion)"
    Product="$(ProductName)"
    MapFileExtensions="$(MapFileExtensions)"
    OutputManifest="@(DeploymentManifestWithPathForPublishingCollection)"
    Platform="$(PlatformTarget)"
    Install="false"
    />
  3. Add a Publisher attribute to this task:
    <GenerateDeploymentManifest
    EntryPoint="@(ApplicationManifestWithPathForPublishingCollection)"
    AssemblyName="$(DeploymentManifestFileName)"
    AssemblyVersion="$(PublishVersion)"
    Product="$(ProductName)"
    Publisher="$(PublisherName)"
    MapFileExtensions="$(MapFileExtensions)"
    OutputManifest="@(DeploymentManifestWithPathForPublishingCollection)"
    Platform="$(PlatformTarget)"
    Install="false"
    />

To changing the targets file to support SupportURL

  1. Search for Target InitializePublishProperties :
    <Target Name="InitializePublishProperties">
    It is followed by a CreateProperty task:
    <CreateProperty Value="Application Files">
         <Output PropertyName="ApplicationFilesFolderName" TaskParameter="Value"/>
    </CreateProperty>
  2. After the CreateProperty task add the following:
    <FormatUrl InputUrl="$(SupportUrl)"> 
    <Output TaskParameter="OutputUrl" PropertyName = "_DeploymentFormattedSupportUrl"/>
    </FormatUrl>
  3. Search for Target GenerateDeploymentManifestForPublishing:
    <Target Name="GenerateDeploymentManifestForPublishing">
  4. Inside this target there is a GenerateDeploymentManifest task:
    <GenerateDeploymentManifest
    EntryPoint="@(ApplicationManifestWithPathForPublishingCollection)"
    AssemblyName="$(DeploymentManifestFileName)"
    AssemblyVersion="$(PublishVersion)"
    Product="$(ProductName)"
    Publisher="$(PublisherName)"
    MapFileExtensions="$(MapFileExtensions)"
    OutputManifest="@(DeploymentManifestWithPathForPublishingCollection)"
    Platform="$(PlatformTarget)"
    Install="false"
    />
  5. Add a Publisher attribute to this task:
    <GenerateDeploymentManifest
    EntryPoint="@(ApplicationManifestWithPathForPublishingCollection)"
    AssemblyName="$(DeploymentManifestFileName)"
    AssemblyVersion="$(PublishVersion)"
    Product="$(ProductName)"
    Publisher="$(PublisherName)"
    SupportUrl="$(_DeploymentFormattedSupportUrl)"
    MapFileExtensions="$(MapFileExtensions)"
    OutputManifest="@(DeploymentManifestWithPathForPublishingCollection)"
    Platform="$(PlatformTarget)"
    Install="false"
    />

To change the targets file to support Office application description

  1. Search the text file for “OfficeApplicationDescription”
  2. You will find a line as follows:
    <OfficeApplicationDescription Condition="'$(VSTO_ProjectType)' == 'Application'">$(TargetName) - $(OfficeApplication) add-in created with Visual Studio Tools for Office</OfficeApplicationDescription>
  3. Modify it to:
    <OfficeApplicationDescription Condition="'$(OfficeApplicationDescription)' == '' and '$(VSTO_ProjectType)' == 'Application'">$(TargetName) - $(OfficeApplication) add-in created with Visual Studio Tools for Office</OfficeApplicationDescription>
    Note the correct quotes are as follows:
    Condition = <doublequote> <singlequote> $(OfficeApplicationDescription) <singlequote> == <singlequote><singlequote>
  4. The very next line after this also needs to be modified:
    <OfficeApplicationDescription Condition="'$(VSTO_ProjectType)' == 'Document'">$(TargetName) - $(OfficeApplication) document created with Visual Studio Tools for Office</OfficeApplicationDescription>
  5. Modify it to:
    <OfficeApplicationDescription Condition="'$(OfficeApplicationDescription)' == '' and '$(VSTO_ProjectType)' == 'Document'">$(TargetName) - $(OfficeApplication) document created with Visual Studio Tools for Office</OfficeApplicationDescription>
    Note the correct quotes are as follows:
    Condition = <doublequote> <singlequote> $(OfficeApplicationDescription) <singlequote> == <singlequote><singlequote>

You are done modifying the targets file. The next step is to modify your project file and specify values for these properties. You will have to modify any project that you want to specify these properties for. The Visual Studio projects file is the .vbproj or .csproj file associated with your project. You can open up this file in a text editor.

You will have to modify the project so that it starts using the new targets file which you have created:

Modify project to use new target file

  1. Find the following comment in the projects file:
    <!-- Include additional build rules for an Office application add-in. -->
  2. Replace the existing pointer to the targets file:
    <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.Office2007.targets" />
    With the path to the new targets file:
    <Import Project="c:\users\username\documents\Visual Studio 2008\ Microsoft.VisualStudio.Tools.Office.Office2007_Properties.targets" />

Specify Properties in project file

Inside the first <PropertyGroup> tag you can add the following properties:

<ProductName>My VSTO Solution</ProductName>

<PublisherName>Visual Studio (BizApps)</PublisherName>

<OfficeApplicationDescription>A Sample Add-in created to show the add-in properties work</OfficeApplicationDescription>

<SupportUrl>http://www.microsoft.com</SupportUrl>

Once you have added these properties to the project file you can save the project and open it in Visual Studio. When you open this project you will get a warning stating that the project has been modified to use custom build steps. Choose the option to Load the project normally and proceed. From now onwards, these properties will be automatically be inserted into the manifest during publish. Any updates you make to these properties will also automatically be picked up by the publish system.

Modifying the targets file is a rather long and elaborate procedure, but once you complete it successfully you have the benefit of being able to specify these properties easily for any project.

Hope you find this post useful. Please let us know your comments.

Saurabh Bhatia, Program Manager

Leave a Comment
  • Please add 8 and 2 and type the answer here:
  • Post
  • This is helpful but I seem to be missing something. I can use this tip to set the Publisher in Programs and Features, but how do I set the Publisher so that it appears in the Excel add-ins dialog? Even in the second screenshot above the Publisher shows <None> in the add-ins dialog.

  • Unfortunately specifying a Publisher Name that appears in the Office Add-ins dialog is currently not possible. Office does not examine the VSTO manifests for signature information and so that field does not work for VSTO add-ins.

    Thanks

    Saurabh

  • Excellent post, I just followed the steps to modify the targets file. I made the same steps except that I put the targets file into my ProjectDir and changed the .csproj file to:

    <Import Project="$(ProjectDir)\Microsoft.VisualStudio.Tools.Office.Office2007.targets" />

    This way I can check the targets file into my source control system and build the project on different machines as needed..

    Really helpful stuff, thank you!

  • Hi Saurabh,

    I have image and icon file in my outlook 2007 vsto addins project. I have  manage to publish the  application on my local Internet. Also It installed on other client system. But the image and Icon file is missing from my application .

    Also i have created the windows Installer setup and build project it work fine for me.

    Please Guide me where i am mising.

    Thanks

    Umesh

  • I am not sure which Image and Icon file you are referring to. Also I am not sure which version of VS you are using which makes it harder to answer your question.

    For 2005 there is a deployment whitepaper which explains deploying vsto solutions through setup projects :

    http://go.microsoft.com/fwlink/?LinkID=57779

    For 2008 there is another whitepaper:http://msdn.microsoft.com/en-us/library/cc563937.aspx

    If you are using 2008 is there a particular reason you would want to use Windows Installer setup ? Does ClickOnce not work for you?

    Thanks

    Saurabh

  • Hi Saurabh

    Please help i am getting the following error while publising the outlook addin 2007 with vs2008  on iis6 2003 server.  

    Failed to copy file 'C:\TestApp2\TestOutlookAddin2007\TestOutlookAddin2007\bin\Debug\app.publish\Application Files\TestOutlookAddin2007_1_0_0_0\TestOutlookAddin2007.vsto' to 'ftp://192.168.1.151/TestOutlookAddin2007/Application Files/TestOutlookAddin2007_1_0_0_0/TestOutlookAddin2007.vsto'.

    Unable to add 'Application Files/TestOutlookAddin2007_1_0_0_0/TestOutlookAddin2007.vsto' to the Web site.

    Could not find a Web server at '192.168.1.151' on port 21.

    Please check to make sure that the Web server name is valid and your proxy settings are set correctly. If you are sure that everything is correct, the Web server may be temporarily out of service.

    Thanks

    Umesh

  • Looks like you are having trouble connecting to the FTP server from VS.

    Make sure the FTP server is up and running and you have the right access permissions to put files on it. You could also try publishing it locally first and then uploading it to the server using a FTP client.

    Hope that helps

    Thanks

    Saurabh

  • 原文地址:OfficeDevelopmentwithVisualStudio:SpecifyingaProductName,PublisherNameandotherpro...

  • How do I set the Publisher so that it appears in the Outlook add-ins dialog? Even in the second screenshot above the Publisher shows <None> in the add-ins dialog.

    For the same kind of query you replied by saying "Currently not possible". Can you tell me, now is it possible?

  • Displaying the publisher name in the Office add-ins dialog is certainly a common request and on our radar for feature requests. But as now the Publisher in the Office add-ins dialog will continue to show <none> for all VSTO solutions.

  • Thanks for the reply Saurabh !

  • That does the job nicely. I actually wanted to do an Installer package rather than publish so I applied the change to the GenerateDeploymentManifest section under the VisualStudioApplicationsBuild target instead but that seesm to work. Thanks.

  • I use the 'mage' solution you described with success in deploying a Word add-in. But is there a way to change the .config file of my word add-in? If I first build my solution, than replace the config file (in the \bin\release\ dir) and than:

    - Specify the Product, Publisher and SupportURL properties

    - Specify Friendly Name and Office Application Description:

    - Sign deployment manifest

    - Resign application manifest

    - Update deployment manifest

    - Resign deployment manifest

    (as you described)

    And then try to install the add-in, I'm getting the error:

    File, XXXWordAddIn.dll.config, has a different computed hash than specified in manifest.

    Am I doing something wrong?

  • Nice write up on this. However i would like to ask how could us change the icon that appears in the "Program and Features" which relates to our AddIns.

    Currently it is by default showing the application icon. I would like to change it to my own custom icon. How could this be done?

    Thanks

  • Why on earth does this not seem to have been "fixed" for VS 2010?

    If the workaround was known back in VS2008 days, surely it would have been a simple thing to add into VS 2010.

    Or better still, give us a way to modifiy the friendly name from within VS itself.

Page 1 of 2 (21 items) 12

Specifying a Product Name, Publisher Name and other properties for VSTO solutions (Saurabh Bhatia)