如何使用WiX将VSTO部署到3.0加载项?
我想部署我用VisualStudio2008编写的VSTO 3应用程序级Word 2007加载项。我看到WiX有一个名为WixOfficeExtension的扩展,看起来它可能有这个功能,但是我找不到任何关于它的文档,从源代码中我也看不出它的用途如何使用WiX将VSTO部署到3.0加载项?,wix,vsto,ms-office,add-in,wix3,Wix,Vsto,Ms Office,Add In,Wix3,我想部署我用VisualStudio2008编写的VSTO 3应用程序级Word 2007加载项。我看到WiX有一个名为WixOfficeExtension的扩展,看起来它可能有这个功能,但是我找不到任何关于它的文档,从源代码中我也看不出它的用途 以前有人尝试过这个,你能成功完成吗?我很惊讶没有人回答这个问题。。。我一直在研究插件,所以我只想在这里转储一些链接。我不确定您是否已经找到了您所寻找的解决方案,但这可以帮助其他人像我一样搜索: 答案是为office安装vsto 3.0加载项确实适用于w
以前有人尝试过这个,你能成功完成吗?我很惊讶没有人回答这个问题。。。我一直在研究插件,所以我只想在这里转储一些链接。我不确定您是否已经找到了您所寻找的解决方案,但这可以帮助其他人像我一样搜索: 答案是为office安装vsto 3.0加载项确实适用于wix,但我对WixOffice扩展一无所知?对我来说,让它工作并不是一项简单的任务,你需要做很多事情才能正确完成这项任务: 第1步。我真的想使用VSTO吗? 请看这里: 第2步。Ok VSTO正确,请阅读此处: 来自Misha Shneerson女士——2007年部署VSTO: Microsoft部署信息在此: 第3步。我是否需要一次安装多个加载项,还是因为需要而使用WIX?转到步骤4 如果您不使用visual studio中的安装程序并使您的生活变得轻松。。。 这是Microsofts安装程序,最简单的方法: 到这里找到一个很好的提示/想法摘要。我也在这里浏览论坛寻求帮助,这是一个非常好的网站。(总结得很好,适用于outlook,但适用于office): 第4步。Wix A) 熟悉您需要的:应用程序级加载项的注册表项 B) 使用visual studio中windows installer中基于的安装程序对象生成MSI文件 C) 测试该msi并确保加载项使用microsoft msi工作。相信我,很多问题让你在这里花的时间最多 D) 运行dark.exe(在wix bin中)并查看为输出文件创建的注册表设置 E) 将这些注册表设置添加到wix文件中。
--我确实觉得这个博客有点帮助,但它是针对Excel的com插件: F) 运行并部署
注意:当我在这里找到更多信息时,我会在这里添加更多信息。我仍在学习Wix,以及我可以用它在插件等方面做些什么。Wix很棒,Office插件部署是一个巨大的难题。这是我最终使用的代码。我基本上是将示例从移植到使用WiX 注意:此特定解决方案仅适用于Word 2007插件,但Excel的情况非常类似。只需根据上述内容修改注册表/组件检查和键/值 包含列表自定义操作 为了以完全信任的方式运行加载项,必须将其添加到当前用户的包含列表中。唯一可靠地做到这一点的方法是使用自定义操作。这是WiX中新包含的自定义操作的端口 要使用它,请创建一个名为VSTOCustomAction的新DTF项目并添加CustomAction.cs
using 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;
}
}
}
CustomAction.cs
using 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片段
我们显然需要实际的WiX文件来安装插件。使用从主.wcs文件引用它
<FeatureRef Id="MyAddinComponent"/>
Addin.wcs
希望这能为其他人节省一些时间。我确实成功地完成了这项工作,将在时间允许的情况下尽快发布答案……非常好。我希望这能帮助其他人,因为wix不是最容易与addins合作的。事实上,我在COM加载项上做了很多工作,但也测试了VSTO.PropertyAssign_ManifestLocation,也应该在“RemoveFromInclusionList”之前进行评估,否则主要升级将失败。值得注意的是,成功构建加载项项目后,可以在.dll.manifest文件中找到RSAKeyValue块。我花了很长时间才弄清楚那是在哪里。