我也曾有过类似的问题,解决它以同样的方式由克里斯托弗描述的,我也想知道是否有这样做的任何其他方法,但如果你没有找到任何东西在这里是一个例子
1)创建一个自定义操作库,具有以下InstallerClass
using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration.Install;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using Microsoft.VisualStudio.Tools.Applications;
using Microsoft.Win32;
namespace Setup.CustomActions
{
[RunInstaller(true)]
public partial class AddCustomization : Installer
{
static readonly Guid solutionID = new Guid("d6680661-c31e-4c24-9492-5919dc0uagt5");
public override void Install(IDictionary stateSaver)
{
string installPath = Context.Parameters["installPath"];
if(!String.IsNullOrEmpty(installPath))
{
AddTemplateToAvailableTemplates(installPath);
}
base.Install(stateSaver);
}
public override void Rollback(IDictionary savedState)
{
}
public override void Uninstall(IDictionary savedState)
{
}
private void AddTemplateToAvailableTemplates(string installPath)
{
//The example below is very basic, put in checks to see whether the registry key already exists and so on
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Office\14.0\Common", true);
RegistryKey acturisKey = key.CreateSubKey(@"Spotlight\MyAppInstallPath");
acturisKey.SetValue("InstallPath", installPath);h);
}
}
}
2)在安装项目创建安装自定义操作,它指向安装目录的关键: ![Install custom action](https://i.stack.imgur.com/lzwsR.jpg)
如果您需要更多的信息或想下载源码看看this msdn发布的Open Xml MVP Wouter Van Wugt标题为“使用Windows安装程序部署Office解决方案的Visual Studio 2010工具”
这可能是最后的手段...看看是否有人带有一个更好的主意一起。 – Jake 2012-03-27 10:51:22
那么,我尝试了各种反射的东西。事实是,程序集被复制到一个随机的位置,因此找不到它带来的任何文件。如果你不想写入注册表,你可以...搜索?但这可能会让您搜索所有驱动器。 – 2012-03-27 12:26:35