diff options
Diffstat (limited to '')
-rw-r--r-- | src/tools/WixToolset.HeatTasks/RefreshGeneratedFile.cs (renamed from src/wix/WixToolset.BuildTasks/RefreshGeneratedFile.cs) | 52 |
1 files changed, 20 insertions, 32 deletions
diff --git a/src/wix/WixToolset.BuildTasks/RefreshGeneratedFile.cs b/src/tools/WixToolset.HeatTasks/RefreshGeneratedFile.cs index e18ae222..1e43cc1f 100644 --- a/src/wix/WixToolset.BuildTasks/RefreshGeneratedFile.cs +++ b/src/tools/WixToolset.HeatTasks/RefreshGeneratedFile.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,36 @@ 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 that contains ComponentGroupRefs | 13 | /// This task refreshes the generated file that contains ComponentGroupRefs |
15 | /// to harvested output. | 14 | /// to harvested output. |
16 | /// </summary> | 15 | /// </summary> |
17 | public class RefreshGeneratedFile : Task | 16 | public class RefreshGeneratedFile : RefreshTask |
18 | { | 17 | { |
19 | /// <summary> | 18 | /// <summary> |
20 | /// The list of files to generate. | ||
21 | /// </summary> | ||
22 | [Required] | ||
23 | public ITaskItem[] GeneratedFiles { get; set; } | ||
24 | |||
25 | /// <summary> | ||
26 | /// All the project references in the project. | ||
27 | /// </summary> | ||
28 | [Required] | ||
29 | public ITaskItem[] ProjectReferencePaths { get; set; } | ||
30 | |||
31 | /// <summary> | ||
32 | /// Gets a complete list of external cabs referenced by the given installer database file. | 19 | /// Gets a complete list of external cabs referenced by the given installer database file. |
33 | /// </summary> | 20 | /// </summary> |
34 | /// <returns>True upon completion of the task execution.</returns> | 21 | /// <returns>True upon completion of the task execution.</returns> |
35 | public override bool Execute() | 22 | public override bool Execute() |
36 | { | 23 | { |
37 | ArrayList componentGroupRefs = new ArrayList(); | 24 | var componentGroupRefs = new ArrayList(); |
38 | for (int i = 0; i < this.ProjectReferencePaths.Length; i++) | 25 | |
26 | for (var i = 0; i < this.ProjectReferencePaths.Length; i++) | ||
39 | { | 27 | { |
40 | ITaskItem item = this.ProjectReferencePaths[i]; | 28 | var item = this.ProjectReferencePaths[i]; |
41 | 29 | ||
42 | if (!String.IsNullOrEmpty(item.GetMetadata(ToolsCommon.DoNotHarvest))) | 30 | if (!String.IsNullOrEmpty(item.GetMetadata(DoNotHarvest))) |
43 | { | 31 | { |
44 | continue; | 32 | continue; |
45 | } | 33 | } |
46 | 34 | ||
47 | string projectPath = item.GetMetadata("MSBuildSourceProjectFile"); | 35 | var projectPath = item.GetMetadata("MSBuildSourceProjectFile"); |
48 | string projectName = Path.GetFileNameWithoutExtension(projectPath); | 36 | var projectName = Path.GetFileNameWithoutExtension(projectPath); |
49 | string referenceName = ToolsCommon.GetIdentifierFromName(ToolsCommon.GetMetadataOrDefault(item, "Name", projectName)); | 37 | var referenceName = GetIdentifierFromName(GetMetadataOrDefault(item, "Name", projectName)); |
50 | 38 | ||
51 | string[] pogs = item.GetMetadata("RefProjectOutputGroups").Split(';'); | 39 | var pogs = item.GetMetadata("RefProjectOutputGroups").Split(';'); |
52 | foreach (string pog in pogs) | 40 | foreach (var pog in pogs) |
53 | { | 41 | { |
54 | if (!String.IsNullOrEmpty(pog)) | 42 | if (!String.IsNullOrEmpty(pog)) |
55 | { | 43 | { |
@@ -58,32 +46,32 @@ namespace WixToolset.BuildTasks | |||
58 | } | 46 | } |
59 | } | 47 | } |
60 | 48 | ||
61 | XmlDocument doc = new XmlDocument(); | 49 | var doc = new XmlDocument(); |
62 | 50 | ||
63 | XmlProcessingInstruction head = doc.CreateProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); | 51 | var head = doc.CreateProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); |
64 | doc.AppendChild(head); | 52 | doc.AppendChild(head); |
65 | 53 | ||
66 | XmlElement rootElement = doc.CreateElement("Wix"); | 54 | var rootElement = doc.CreateElement("Wix"); |
67 | rootElement.SetAttribute("xmlns", "http://wixtoolset.org/schemas/v4/wxs"); | 55 | rootElement.SetAttribute("xmlns", "http://wixtoolset.org/schemas/v4/wxs"); |
68 | doc.AppendChild(rootElement); | 56 | doc.AppendChild(rootElement); |
69 | 57 | ||
70 | XmlElement fragment = doc.CreateElement("Fragment"); | 58 | var fragment = doc.CreateElement("Fragment"); |
71 | rootElement.AppendChild(fragment); | 59 | rootElement.AppendChild(fragment); |
72 | 60 | ||
73 | XmlElement componentGroup = doc.CreateElement("ComponentGroup"); | 61 | var componentGroup = doc.CreateElement("ComponentGroup"); |
74 | componentGroup.SetAttribute("Id", "Product.Generated"); | 62 | componentGroup.SetAttribute("Id", "Product.Generated"); |
75 | fragment.AppendChild(componentGroup); | 63 | fragment.AppendChild(componentGroup); |
76 | 64 | ||
77 | foreach (string componentGroupRef in componentGroupRefs) | 65 | foreach (string componentGroupRef in componentGroupRefs) |
78 | { | 66 | { |
79 | XmlElement componentGroupRefElement = doc.CreateElement("ComponentGroupRef"); | 67 | var componentGroupRefElement = doc.CreateElement("ComponentGroupRef"); |
80 | componentGroupRefElement.SetAttribute("Id", componentGroupRef); | 68 | componentGroupRefElement.SetAttribute("Id", componentGroupRef); |
81 | componentGroup.AppendChild(componentGroupRefElement); | 69 | componentGroup.AppendChild(componentGroupRefElement); |
82 | } | 70 | } |
83 | 71 | ||
84 | foreach (ITaskItem item in this.GeneratedFiles) | 72 | foreach (var item in this.GeneratedFiles) |
85 | { | 73 | { |
86 | string fullPath = item.GetMetadata("FullPath"); | 74 | var fullPath = item.GetMetadata("FullPath"); |
87 | 75 | ||
88 | componentGroup.SetAttribute("Id", Path.GetFileNameWithoutExtension(fullPath)); | 76 | componentGroup.SetAttribute("Id", Path.GetFileNameWithoutExtension(fullPath)); |
89 | try | 77 | try |