Skip to content

Commit

Permalink
Add all unknown elements verbatim, null check
Browse files Browse the repository at this point in the history
Fixes #72
  • Loading branch information
mlorbetske committed Dec 28, 2013
1 parent 982482a commit c024a07
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/LigerShark.TemplateBuilder.Tasks/CreateTemplateTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,13 @@ public override bool Execute() {

}

// This is a temporary fix to preserve WizardExtension/WizardData elements
// in the .vstemplate file. We need a more generic method to preserve
// elements like these.
XNamespace vsTemplateNs = VsTemplateSchema;
var wizExt = vstemplate.Root.Element(vsTemplateNs + "WizardExtension");
var wizData = vstemplate.Root.Element(vsTemplateNs + "WizardData");

if (wizExt != null) {
workingTemplate.Root.Add(wizExt);
}
if (wizData != null) {
workingTemplate.Root.Add(wizData);
//Copy all non-mutated sections
var mutatedTemplateSections = new[] {"TemplateContent", "TemplateData"};
var elementsToCopyDirectly = vstemplate.Root.Elements().Where(x => !mutatedTemplateSections.Contains(x.Name.LocalName));

foreach (var element in elementsToCopyDirectly) {
var clonedElement = XElement.Parse(element.ToString());
workingTemplate.Add(clonedElement);
}

Merge(projectElement, itemsToMerge);
Expand All @@ -160,12 +155,16 @@ public override bool Execute() {
}
private List<string> GetFilesToExlucudeAsList() {
List<string> filesToExclude = new List<string>();
foreach (var item in FilesExclude) {
if (item == null || string.IsNullOrEmpty(item.ItemSpec)) {
continue;

if (FilesExclude != null) {
foreach (var item in FilesExclude) {
if (item == null || string.IsNullOrEmpty(item.ItemSpec)) {
continue;
}
filesToExclude.Add(item.ItemSpec.ToLower());
}
filesToExclude.Add(item.ItemSpec.ToLower());
}

return filesToExclude;
}
private static void MergeTemplateData(XElement target, XElement source, string childName, object defaultValue) {
Expand Down

0 comments on commit c024a07

Please sign in to comment.