/// <summary> /// Add a file to a information file, using the specified build profile. /// </summary> /// <param name="inf">The information file to add the directory to.</param> /// <param name="profile">The build profile used.</param> /// <param name="file">The file to add.</param> /// <remarks> /// <para> /// The file will not be added to the information file if /// 1. <paramref name="profile"/> is null, and <see cref="OutputFileInfo.SourceFile"/> /// is excluded by the project's global exclude list or it's current selected build profile. /// 2. or, <paramref name="profile"/> is not null and <see cref="OutputFileInfo.SourceFile"/> /// is excluded by <paramref name="profile"/>. /// </para> /// </remarks> private void AddToCabwiz(Cabwiz.InformationFile inf, BuildProfile profile, OutputFileInfo file) { if (!this.ProjectInfo.IsExcluded(file.SourceFile, profile)) { var sourceFile = file.SourceFile; if (file.IncludeRule != null) { if (file.IncludeRule.XmlReplacementRules.Count > 0) { var tempFile = this.GetObjFileName(file, profile); var rewriter = new XmlFileRewriter(); foreach (var replacement in file.IncludeRule.XmlReplacementRules) { rewriter.AddTextPath(replacement.Tag, this.ProjectInfo.ParseVariables(profile, replacement.Value)); } rewriter.Rewrite(sourceFile, tempFile); sourceFile = tempFile; } else if (!string.IsNullOrWhiteSpace(file.IncludeRule.FileName)) { var tempFile = this.GetObjFileName(file, profile); System.IO.File.Copy(file.SourceFile, tempFile, true); sourceFile = tempFile; } if (!string.IsNullOrEmpty(file.IncludeRule.StartMenuShortcut)) { inf.AddStartMenuShortcutToFile( file.Name, System.IO.Path.GetFileName(file.IncludeRule.StartMenuShortcut), System.IO.Path.GetDirectoryName(file.IncludeRule.StartMenuShortcut)); } } inf.AddFile(sourceFile, file.Directory.FullName, file.Name); } }