WixBundleLog 是指定日志文件的刻录变量。 无法在包中覆盖它, 因为您无法在包含“ Wix” 前缀的包中设置变量。 套件应用程序中的覆盖也不管用, 因为靴子继续登录到默认值 。
燃烧的靴子trapper 设置了套件日志和安装日志的字符串变量。 我在一个列表中跟踪这些变量。 所以在我的构建器里, 我有一些类似的东西 :
this.LogsDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments), @"Company_NameLogsInstaller", DateTime.Now.ToString("yyyyMMdd_hhmmss"));
_logVariables = new List<string>();
_logVariables.Add("WixBundleLog");
Burn sets string variables for the log files in the format [WixBundleLog]_PackageId.
In my bootstrapper application when the PlanPackageComplete event is fired, I have an event handler that includes the following code to add the variables to my list.
//set *possible* log variables for a given package
_logVariables.Add("WixBundleLog_" + e.PackageId);
_logVariables.Add("WixBundleRollbackLog_" + e.PackageId);
安装结束时,或如果我的靴子遇到错误,我称之为以下方法:
private void CopyLogs()
{
if (!Directory.Exists(this.LogsDirectory))
Directory.CreateDirectory(this.LogsDirectory);
foreach (string logVariable in _logVariables)
{
if (this.Bootstrapper.Engine.StringVariables.Contains(logVariable))
{
string file = this.Bootstrapper.Engine.StringVariables[logVariable];
if (File.Exists(file))
{
FileInfo fileInfo = new FileInfo(file);
fileInfo.CopyTo(Path.Combine(this.LogsDirectory, fileInfo.Name), false);
}
}
}
}