Visual Studio 2008 で作成した VSTO 3 アプリケーション レベルの Word 2007 アドインを展開したいと考えています。WiX には WixOfficeExtension という名前の拡張機能があり、この機能を備えているようですが、ドキュメントが見つかりません。 、そしてソースコードからその目的を見分けることはできません。
以前にこれを試みた人はいますか? うまくやってのけることができましたか?
これは私が最終的に使用したコードです。基本的に、WiX を使用するためにMSDNから例を移植しました。
注:この特定のソリューションは Word 2007 アドインのみを対象としていますが、Excel の場合も非常に似ています。前述のMSDN Articleに従って、レジストリ/コンポーネント チェックとキー/値を変更するだけです。
完全な信頼でアドインを実行するには、現在のユーザーの包含リストにアドインを追加する必要があります。これを確実に行う唯一の方法は、カスタム アクションを使用することです。これは記事のカスタム アクションを WiX に含まれる新しいDeployment Tools Foundationに移植したものです。
これを使用するには、VSTOCustomAction という新しい DTF プロジェクトを作成し、CustomAction.cs を追加します。
CustomAction.csusing System;
using System.Security;
using System.Security.Permissions;
using Microsoft.Deployment.WindowsInstaller;
using Microsoft.VisualStudio.Tools.Office.Runtime.Security;
namespace VSTOCustomActions
{
public class CustomActions
{
private static string GetPublicKey(Session session)
{
return session["VSTOCustomAction_PublicKey"];
}
private static string GetManifestLocation(Session session)
{
return session["VSTOCustomAction_ManifestLocation"];
}
private static void ErrorMessage(string message, Session session)
{
using (Record r = new Record(message))
{
session.Message(InstallMessage.Error, r);
}
}
[CustomAction]
public static ActionResult AddToInclusionList(Session session)
{
try
{
SecurityPermission permission =
new SecurityPermission(PermissionState.Unrestricted);
permission.Demand();
}
catch (SecurityException)
{
ErrorMessage("You have insufficient privileges to " +
"register a trust relationship. Start Excel " +
"and confirm the trust dialog to run the addin.", session);
return ActionResult.Failure;
}
Uri deploymentManifestLocation = null;
if (Uri.TryCreate(GetManifestLocation(session),
UriKind.RelativeOrAbsolute, out deploymentManifestLocation) == false)
{
ErrorMessage("The location of the deployment manifest is missing or invalid.", session);
return ActionResult.Failure;
}
AddInSecurityEntry entry = new AddInSecurityEntry(deploymentManifestLocation, GetPublicKey(session));
UserInclusionList.Add(entry);
session.CustomActionData.Add("VSTOCustomAction_ManifestLocation", deploymentManifestLocation.ToString());
return ActionResult.Success;
}
[CustomAction]
public static ActionResult RemoveFromInclusionList(Session session)
{
string uriString = session.CustomActionData["VSTOCustomAction_ManifestLocation"];
if (!string.IsNullOrEmpty(uriString))
{
Uri deploymentManifestLocation = new Uri(uriString);
UserInclusionList.Remove(deploymentManifestLocation);
}
return ActionResult.Success;
}
}
}
アドインをインストールするには、明らかに実際の WiX ファイルが必要です。メインの .wcs ファイルから参照してください
<FeatureRef Id="MyAddinComponent"/>
Addin.wcs
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment Id="Word2007Fragment">
<!-- Include the VSTO Custom action -->
<Binary Id="VSTOCustomAction" SourceFile="path\to\VSTOCustomAction.dll"/>
<CustomAction Id="AddToInclusionList" BinaryKey="VSTOCustomAction" DllEntry="AddToInclusionList" Execute="immediate"/>
<CustomAction Id="RemoveFromInclusionList" BinaryKey="VSTOCustomAction" DllEntry="RemoveFromInclusionList" Execute="immediate"/>
<!-- Set the parameters read by the Custom action -->
<!--
The public key that you used to sign your dll, looks something like <RSAKeyValue><Modulus>...</Modulus><Exponent>...</Exponent></RSAKeyValue>
Take note: There should be no whitespace in the key!
-->
<Property Id="VSTOCustomAction_PublicKey"><![CDATA[Paste you public key here]]></Property>
<CustomAction Id="PropertyAssign_ManifestLocation" Property="VSTOCustomAction_ManifestLocation" Value="[INSTALLDIR]MyAddin.MyAddin.vsto" />
<!-- Properties to check prerequisites -->
<Property Id="VSTORUNTIME">
<RegistrySearch Id="RegistrySearchVsto"
Root="HKLM"
Key="SOFTWARE\Microsoft\vsto runtime Setup\v9.0.30729"
Name="SP"
Type="raw"/>
</Property>
<Property Id="HASWORDPIA">
<ComponentSearch Id="ComponentSearchWordPIA"
Guid="{816D4DFD-FF7B-4C16-8943-EEB07DF989CB}"/>
</Property>
<Property Id="HASSHAREDPIA">
<ComponentSearch Id="ComponentSearchSharedPIA"
Guid="{FAB10E66-B22C-4274-8647-7CA1BA5EF30F}"/>
</Property>
<!-- Feature and component to include the necessary files -->
<Feature Id="MyAddinComponent" Title ="Word 2007 Addin" Level="1" AllowAdvertise="no">
<ComponentRef Id="MyAddinComponent"/>
<Condition Level="0"><![CDATA[NOT ((VSTORUNTIME="#1") AND HASSHAREDPIA AND HASWORDPIA)]]></Condition>
</Feature>
<DirectoryRef Id="INSTALLDIR">
<Component Id="MyAddinComponent" Guid="your component guid here">
<File Name="MyAddin.dll" Source="path\to\MyAddin.dll" />
<File Name="MyAddin.dll.manifest" Source="path\to\MyAddin.dll.manifest" />
<File Name="MyAddin.vsto" Source="path\to\MyAddin.vsto" />
<RegistryKey Root="HKCU"
Key="Software\Microsoft\Office\Word\Addins\MyAddin"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Name="FriendlyName" Value="MyAddin Word 2007 Addin" />
<RegistryValue Type="string" Name="Description" Value="MyAddin Word 2007 Addin" />
<RegistryValue Type="string" Name="Manifest" Value="[INSTALLDIR]MyAddin.vsto|vstolocal" KeyPath="yes"/>
<RegistryValue Type="integer" Name="LoadBehavior" Value="3"/>
</RegistryKey>
</Component>
</DirectoryRef>
<!-- Modify the install sequence to call our custom action -->
<InstallExecuteSequence>
<Custom Action="AddToInclusionList" After="InstallFinalize"><![CDATA[(&MyAddinComponent = 3) AND NOT (!MyAddinComponent = 3)]]></Custom>
<Custom Action="PropertyAssign_ManifestLocation" Before="AddToInclusionList"><![CDATA[(&MyAddinComponent = 3) AND NOT (!MyAddinComponent = 3)]]></Custom>
<Custom Action="RemoveFromInclusionList" After="InstallFinalize"><![CDATA[(&MyAddinComponent = 2) AND NOT (!MyAddinComponent = 2)]]></Custom>
</InstallExecuteSequence>
</Fragment>
</Wix>
これにより、誰かが時間を節約できることを願っています。
誰もこれに答えていないことに驚いています...私はアドインを研究していたので、ここにいくつかのリンクをダンプします. あなたが探していたものの解決策をすでに見つけているかどうかはわかりませんが、これは私のように検索している他の人を助けることができます:
答えは、オフィス用のvsto 3.0アドインをインストールするとwixで機能しますが、このWixOfficeExtensionについて何も知りませんか? 私がそれを機能させるのは簡単な作業ではなく、これを正しく行うにはかなりのことが必要です。
ステップ 1. 本当に VSTO を使用しますか?
ステップ 2. OK VSTO はここで正しく読み取られます。
MS Misha Shneerson から -- 2007 年の VSTO の展開: http://blogs.msdn.com/mshneer/archive/2006/01/05/deployment-articles.aspx Microsoft の展開に関する情報: http://msdn.microsoft.com /en-us/library/bb386179.aspx#
ステップ 3. 一度に複数のアドインをインストールする必要がありますか? それとも WIX を使用したいのですか? 手順 4 に進みます。
Visual Studio でインストーラーを使用しない場合は、作業が簡単になります... Microsoft のセットアップ インストーラーが最も簡単な方法です: http://msdn.microsoft.com/en-us/library/cc563937.aspx
ここにアクセスして、ヒント/アイデアの優れた要約を見つけてください。ここでもヘルプを求めてフォーラムを参照しています。非常に優れたサイトです。
ステップ 4. Wix
A) 必要な内容について理解を深める:アプリケーション レベルのアドインのレジストリ エントリ http://msdn.microsoft.com/en-us/library/bb386106.aspx#
B) Visual Studio の Windows インストーラーに基づくセットアップ オブジェクトを使用して、MSI ファイルを生成します。
C) その msi をテストし、Microsoft MSI を使用してアドインが動作することを確認します。問題の多くは、ここで最も時間がかかると信じてください。
D) dark.exe (wix bin 内) を実行し、出力ファイル用に作成されたレジストリ設定を確認します。
E) これらのレジストリ設定を Wix ファイルに追加します。
-- このブログは少し役に立ちましたが、Excel 用の com アドオンに関するものでした: http://matthewrowan.spaces.live.com/blog/cns!CCB05A30BCA0FF01!143.entry
F) 実行して展開します。
注:ここでさらに見つけたら、ここに追加します。私はまだWixと、アドインなどに関してそれで何ができるかを学んでいます.Wixは素晴らしいです.Officeアドインの展開は王室の痛みです.