我也曾有過類似的問題,解決它以同樣的方式由克里斯托弗描述的,我也想知道是否有這樣做的任何其他方法,但如果你沒有找到任何東西在這裏是一個例子
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)在安裝項目創建安裝自定義操作,它指向安裝目錄的關鍵:
如果您需要更多的信息或想下載源碼看看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