diff options
Diffstat (limited to '')
-rw-r--r-- | src/tools/WixToolset.HeatTasks/RefreshBundleGeneratedFile.cs (renamed from src/wix/WixToolset.BuildTasks/RefreshBundleGeneratedFile.cs) | 57 |
1 files changed, 22 insertions, 35 deletions
diff --git a/src/wix/WixToolset.BuildTasks/RefreshBundleGeneratedFile.cs b/src/tools/WixToolset.HeatTasks/RefreshBundleGeneratedFile.cs index 983695c9..8f1ad167 100644 --- a/src/wix/WixToolset.BuildTasks/RefreshBundleGeneratedFile.cs +++ b/src/tools/WixToolset.HeatTasks/RefreshBundleGeneratedFile.cs | |||
@@ -1,6 +1,6 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
2 | 2 | ||
3 | namespace WixToolset.BuildTasks | 3 | namespace WixToolset.HeatTasks |
4 | { | 4 | { |
5 | using System; | 5 | using System; |
6 | using System.Collections; | 6 | using System.Collections; |
@@ -8,48 +8,35 @@ namespace WixToolset.BuildTasks | |||
8 | using System.IO; | 8 | using System.IO; |
9 | using System.Xml; | 9 | using System.Xml; |
10 | using Microsoft.Build.Framework; | 10 | using Microsoft.Build.Framework; |
11 | using Microsoft.Build.Utilities; | ||
12 | 11 | ||
13 | /// <summary> | 12 | /// <summary> |
14 | /// This task refreshes the generated file for bundle projects. | 13 | /// This task refreshes the generated file for bundle projects. |
15 | /// </summary> | 14 | /// </summary> |
16 | public class RefreshBundleGeneratedFile : Task | 15 | public class RefreshBundleGeneratedFile : RefreshTask |
17 | { | 16 | { |
18 | /// <summary> | 17 | /// <summary> |
19 | /// The list of files to generate. | ||
20 | /// </summary> | ||
21 | [Required] | ||
22 | public ITaskItem[] GeneratedFiles { get; set; } | ||
23 | |||
24 | /// <summary> | ||
25 | /// All the project references in the project. | ||
26 | /// </summary> | ||
27 | [Required] | ||
28 | public ITaskItem[] ProjectReferencePaths { get; set; } | ||
29 | |||
30 | /// <summary> | ||
31 | /// Gets a complete list of external cabs referenced by the given installer database file. | 18 | /// Gets a complete list of external cabs referenced by the given installer database file. |
32 | /// </summary> | 19 | /// </summary> |
33 | /// <returns>True upon completion of the task execution.</returns> | 20 | /// <returns>True upon completion of the task execution.</returns> |
34 | public override bool Execute() | 21 | public override bool Execute() |
35 | { | 22 | { |
36 | ArrayList payloadGroupRefs = new ArrayList(); | 23 | var payloadGroupRefs = new ArrayList(); |
37 | ArrayList packageGroupRefs = new ArrayList(); | 24 | var packageGroupRefs = new ArrayList(); |
38 | for (int i = 0; i < this.ProjectReferencePaths.Length; i++) | 25 | for (var i = 0; i < this.ProjectReferencePaths.Length; i++) |
39 | { | 26 | { |
40 | ITaskItem item = this.ProjectReferencePaths[i]; | 27 | var item = this.ProjectReferencePaths[i]; |
41 | 28 | ||
42 | if (!String.IsNullOrEmpty(item.GetMetadata(ToolsCommon.DoNotHarvest))) | 29 | if (!String.IsNullOrEmpty(item.GetMetadata(DoNotHarvest))) |
43 | { | 30 | { |
44 | continue; | 31 | continue; |
45 | } | 32 | } |
46 | 33 | ||
47 | string projectPath = item.GetMetadata("MSBuildSourceProjectFile"); | 34 | var projectPath = item.GetMetadata("MSBuildSourceProjectFile"); |
48 | string projectName = Path.GetFileNameWithoutExtension(projectPath); | 35 | var projectName = Path.GetFileNameWithoutExtension(projectPath); |
49 | string referenceName = ToolsCommon.GetIdentifierFromName(ToolsCommon.GetMetadataOrDefault(item, "Name", projectName)); | 36 | var referenceName = GetIdentifierFromName(GetMetadataOrDefault(item, "Name", projectName)); |
50 | 37 | ||
51 | string[] pogs = item.GetMetadata("RefProjectOutputGroups").Split(';'); | 38 | var pogs = item.GetMetadata("RefProjectOutputGroups").Split(';'); |
52 | foreach (string pog in pogs) | 39 | foreach (var pog in pogs) |
53 | { | 40 | { |
54 | if (!String.IsNullOrEmpty(pog)) | 41 | if (!String.IsNullOrEmpty(pog)) |
55 | { | 42 | { |
@@ -60,43 +47,43 @@ namespace WixToolset.BuildTasks | |||
60 | } | 47 | } |
61 | } | 48 | } |
62 | 49 | ||
63 | XmlDocument doc = new XmlDocument(); | 50 | var doc = new XmlDocument(); |
64 | 51 | ||
65 | XmlProcessingInstruction head = doc.CreateProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); | 52 | var head = doc.CreateProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); |
66 | doc.AppendChild(head); | 53 | doc.AppendChild(head); |
67 | 54 | ||
68 | XmlElement rootElement = doc.CreateElement("Wix"); | 55 | var rootElement = doc.CreateElement("Wix"); |
69 | rootElement.SetAttribute("xmlns", "http://wixtoolset.org/schemas/v4/wxs"); | 56 | rootElement.SetAttribute("xmlns", "http://wixtoolset.org/schemas/v4/wxs"); |
70 | doc.AppendChild(rootElement); | 57 | doc.AppendChild(rootElement); |
71 | 58 | ||
72 | XmlElement fragment = doc.CreateElement("Fragment"); | 59 | var fragment = doc.CreateElement("Fragment"); |
73 | rootElement.AppendChild(fragment); | 60 | rootElement.AppendChild(fragment); |
74 | 61 | ||
75 | XmlElement payloadGroup = doc.CreateElement("PayloadGroup"); | 62 | var payloadGroup = doc.CreateElement("PayloadGroup"); |
76 | payloadGroup.SetAttribute("Id", "Bundle.Generated.Payloads"); | 63 | payloadGroup.SetAttribute("Id", "Bundle.Generated.Payloads"); |
77 | fragment.AppendChild(payloadGroup); | 64 | fragment.AppendChild(payloadGroup); |
78 | 65 | ||
79 | XmlElement packageGroup = doc.CreateElement("PackageGroup"); | 66 | var packageGroup = doc.CreateElement("PackageGroup"); |
80 | packageGroup.SetAttribute("Id", "Bundle.Generated.Packages"); | 67 | packageGroup.SetAttribute("Id", "Bundle.Generated.Packages"); |
81 | fragment.AppendChild(packageGroup); | 68 | fragment.AppendChild(packageGroup); |
82 | 69 | ||
83 | foreach (string payloadGroupRef in payloadGroupRefs) | 70 | foreach (string payloadGroupRef in payloadGroupRefs) |
84 | { | 71 | { |
85 | XmlElement payloadGroupRefElement = doc.CreateElement("PayloadGroupRef"); | 72 | var payloadGroupRefElement = doc.CreateElement("PayloadGroupRef"); |
86 | payloadGroupRefElement.SetAttribute("Id", payloadGroupRef); | 73 | payloadGroupRefElement.SetAttribute("Id", payloadGroupRef); |
87 | payloadGroup.AppendChild(payloadGroupRefElement); | 74 | payloadGroup.AppendChild(payloadGroupRefElement); |
88 | } | 75 | } |
89 | 76 | ||
90 | foreach (string packageGroupRef in packageGroupRefs) | 77 | foreach (string packageGroupRef in packageGroupRefs) |
91 | { | 78 | { |
92 | XmlElement packageGroupRefElement = doc.CreateElement("PackageGroupRef"); | 79 | var packageGroupRefElement = doc.CreateElement("PackageGroupRef"); |
93 | packageGroupRefElement.SetAttribute("Id", packageGroupRef); | 80 | packageGroupRefElement.SetAttribute("Id", packageGroupRef); |
94 | packageGroup.AppendChild(packageGroupRefElement); | 81 | packageGroup.AppendChild(packageGroupRefElement); |
95 | } | 82 | } |
96 | 83 | ||
97 | foreach (ITaskItem item in this.GeneratedFiles) | 84 | foreach (var item in this.GeneratedFiles) |
98 | { | 85 | { |
99 | string fullPath = item.GetMetadata("FullPath"); | 86 | var fullPath = item.GetMetadata("FullPath"); |
100 | 87 | ||
101 | payloadGroup.SetAttribute("Id", Path.GetFileNameWithoutExtension(fullPath) + ".Payloads"); | 88 | payloadGroup.SetAttribute("Id", Path.GetFileNameWithoutExtension(fullPath) + ".Payloads"); |
102 | packageGroup.SetAttribute("Id", Path.GetFileNameWithoutExtension(fullPath) + ".Packages"); | 89 | packageGroup.SetAttribute("Id", Path.GetFileNameWithoutExtension(fullPath) + ".Packages"); |