private void CreateWixComponents(Wix model, List <string> filesTree) { try { model.Fragment.ComponentGroup = new ComponentGroupElement { Id = $"{ Working.RemoveIllegalCharacters(InstallDirPath.Substring(InstallDirPath.LastIndexOf('\\') + 1)) }FileComponents" }; model.Fragment.ComponentGroup.Components = new List <ComponentElement>(); var format = Working.GetToStringFormat(filesTree.Count); var components = model.Fragment.ComponentGroup.Components; foreach (var filePath in filesTree) { var i = components.Count + 1; var count = i.ToString(format); var fileName = Path.GetFileName(filePath); var componentDirectory = Working.GetSubDirPath(InstallDirPath, filePath); componentDirectory = componentDirectory.Substring(0, componentDirectory.Length - fileName.Length - 1).Replace('\\', '_'); var component = new ComponentElement { Id = Working.RemoveIllegalCharacters($"IDC_{ fileName }_{ count }"), Directory = Working.RemoveIllegalCharacters($"IDD_{ componentDirectory }"), Guid = ShouldGenerateGuids ? Guid.NewGuid().ToString().ToUpper() : "*", Win64 = ShouldPrepareX64Components ? "yes" : "no" }; var file = new FileElement { Id = Working.RemoveIllegalCharacters($"IDF_{ fileName }_{ count }"), Name = fileName, DiskId = "1", Source = $"$(var.SolutionDir){ Working.GetSubDirPath(InstallDirPath, filePath) }", KeyPath = "yes" }; component.File = file; components.Add(component); } } catch (Exception ex) { var message = "Exception thrown in CreateWixComponents()\n"; throw new Exception(message, ex); } }