aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2022-02-03 04:51:38 -0800
committerRob Mensching <rob@firegiant.com>2022-02-03 05:41:33 -0800
commitdad29a9c5986fe30ae6992668019e5bbca446ed0 (patch)
tree2603860068e08fc4ec332d524dda6764c4a6f637
parent8402bf3d91d2931fce3016f23d473e8d544e18e0 (diff)
downloadwix-dad29a9c5986fe30ae6992668019e5bbca446ed0.tar.gz
wix-dad29a9c5986fe30ae6992668019e5bbca446ed0.tar.bz2
wix-dad29a9c5986fe30ae6992668019e5bbca446ed0.zip
Small bits of code clean-up
-rw-r--r--src/wix/WixToolset.BuildTasks/ResolveWixReferences.cs54
-rw-r--r--src/wix/WixToolset.Sdk/tools/wix.props2
-rw-r--r--src/wix/WixToolset.Sdk/tools/wix.targets19
3 files changed, 27 insertions, 48 deletions
diff --git a/src/wix/WixToolset.BuildTasks/ResolveWixReferences.cs b/src/wix/WixToolset.BuildTasks/ResolveWixReferences.cs
index 9b8cfe6f..8d8db428 100644
--- a/src/wix/WixToolset.BuildTasks/ResolveWixReferences.cs
+++ b/src/wix/WixToolset.BuildTasks/ResolveWixReferences.cs
@@ -31,11 +31,7 @@ namespace WixToolset.BuildTasks
31 /// The list of references to resolve. 31 /// The list of references to resolve.
32 /// </summary> 32 /// </summary>
33 [Required] 33 [Required]
34 public ITaskItem[] WixReferences 34 public ITaskItem[] WixReferences { get; set; }
35 {
36 get;
37 set;
38 }
39 35
40 /// <summary> 36 /// <summary>
41 /// The directories or special locations that are searched to find the files 37 /// The directories or special locations that are searched to find the files
@@ -57,30 +53,18 @@ namespace WixToolset.BuildTasks
57 /// {RawFileName}: Specifies the task will consider the Include value of the item to be 53 /// {RawFileName}: Specifies the task will consider the Include value of the item to be
58 /// an exact path and file name. 54 /// an exact path and file name.
59 /// </summary> 55 /// </summary>
60 public string[] SearchPaths 56 public string[] SearchPaths { get; set; }
61 {
62 get;
63 set;
64 }
65 57
66 /// <summary> 58 /// <summary>
67 /// The filename extension(s) to be checked when searching. 59 /// The filename extension(s) to be checked when searching.
68 /// </summary> 60 /// </summary>
69 public string[] SearchFilenameExtensions 61 public string[] SearchFilenameExtensions { get; set; }
70 {
71 get;
72 set;
73 }
74 62
75 /// <summary> 63 /// <summary>
76 /// Output items that contain the same metadata as input references and have been resolved to full paths. 64 /// Output items that contain the same metadata as input references and have been resolved to full paths.
77 /// </summary> 65 /// </summary>
78 [Output] 66 [Output]
79 public ITaskItem[] ResolvedWixReferences 67 public ITaskItem[] ResolvedWixReferences { get; private set; }
80 {
81 get;
82 private set;
83 }
84 68
85 /// <summary> 69 /// <summary>
86 /// Resolves reference paths by searching for referenced items using the specified SearchPaths. 70 /// Resolves reference paths by searching for referenced items using the specified SearchPaths.
@@ -88,14 +72,22 @@ namespace WixToolset.BuildTasks
88 /// <returns>True on success, or throws an exception on failure.</returns> 72 /// <returns>True on success, or throws an exception on failure.</returns>
89 public override bool Execute() 73 public override bool Execute()
90 { 74 {
91 List<ITaskItem> resolvedReferences = new List<ITaskItem>(); 75 var resolvedReferences = new List<ITaskItem>();
76 var uniqueReferences = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
92 77
93 foreach (ITaskItem reference in this.WixReferences) 78 foreach (var reference in this.WixReferences)
94 { 79 {
95 ITaskItem resolvedReference = ResolveWixReferences.ResolveReference(reference, this.SearchPaths, this.SearchFilenameExtensions, this.Log); 80 var resolvedReference = ResolveWixReferences.ResolveReference(reference, this.SearchPaths, this.SearchFilenameExtensions, this.Log);
96 81
97 this.Log.LogMessage(MessageImportance.Low, "Resolved path {0}", resolvedReference.ItemSpec); 82 if (uniqueReferences.Add(resolvedReference.ItemSpec))
98 resolvedReferences.Add(resolvedReference); 83 {
84 this.Log.LogMessage(MessageImportance.Low, "Resolved path {0}", resolvedReference.ItemSpec);
85 resolvedReferences.Add(resolvedReference);
86 }
87 else
88 {
89 this.Log.LogMessage(MessageImportance.Low, "Resolved duplicate path {0}, discarding it", resolvedReference.ItemSpec);
90 }
99 } 91 }
100 92
101 this.ResolvedWixReferences = resolvedReferences.ToArray(); 93 this.ResolvedWixReferences = resolvedReferences.ToArray();
@@ -130,16 +122,16 @@ namespace WixToolset.BuildTasks
130 } 122 }
131 123
132 // Copy all the metadata from the source 124 // Copy all the metadata from the source
133 TaskItem resolvedReference = new TaskItem(reference); 125 var resolvedReference = new TaskItem(reference);
134 log.LogMessage(MessageImportance.Low, "WixReference: {0}", reference.ItemSpec); 126 log.LogMessage(MessageImportance.Low, "WixReference: {0}", reference.ItemSpec);
135 127
136 // Now find the resolved path based on our order of precedence 128 // Now find the resolved path based on our order of precedence
137 foreach (string searchPath in searchPaths) 129 foreach (var searchPath in searchPaths)
138 { 130 {
139 log.LogMessage(MessageImportance.Low, "Trying {0}", searchPath); 131 log.LogMessage(MessageImportance.Low, "Trying {0}", searchPath);
140 if (searchPath.Equals(HintPathToken, StringComparison.Ordinal)) 132 if (searchPath.Equals(HintPathToken, StringComparison.Ordinal))
141 { 133 {
142 string path = reference.GetMetadata("HintPath"); 134 var path = reference.GetMetadata("HintPath");
143 log.LogMessage(MessageImportance.Low, "Trying path {0}", path); 135 log.LogMessage(MessageImportance.Low, "Trying path {0}", path);
144 if (File.Exists(path)) 136 if (File.Exists(path))
145 { 137 {
@@ -163,7 +155,7 @@ namespace WixToolset.BuildTasks
163 } 155 }
164 else 156 else
165 { 157 {
166 string path = Path.Combine(searchPath, Path.GetFileName(reference.ItemSpec)); 158 var path = Path.Combine(searchPath, Path.GetFileName(reference.ItemSpec));
167 log.LogMessage(MessageImportance.Low, "Trying path {0}", path); 159 log.LogMessage(MessageImportance.Low, "Trying path {0}", path);
168 if (File.Exists(path)) 160 if (File.Exists(path))
169 { 161 {
@@ -195,9 +187,9 @@ namespace WixToolset.BuildTasks
195 /// <returns>True if the item was resolved, else false.</returns> 187 /// <returns>True if the item was resolved, else false.</returns>
196 private static bool ResolveFilenameExtensions(ITaskItem reference, string basePath, string[] filenameExtensions, TaskLoggingHelper log) 188 private static bool ResolveFilenameExtensions(ITaskItem reference, string basePath, string[] filenameExtensions, TaskLoggingHelper log)
197 { 189 {
198 foreach (string filenameExtension in filenameExtensions) 190 foreach (var filenameExtension in filenameExtensions)
199 { 191 {
200 string path = basePath + filenameExtension; 192 var path = basePath + filenameExtension;
201 log.LogMessage(MessageImportance.Low, "Trying path {0}", path); 193 log.LogMessage(MessageImportance.Low, "Trying path {0}", path);
202 if (File.Exists(path)) 194 if (File.Exists(path))
203 { 195 {
diff --git a/src/wix/WixToolset.Sdk/tools/wix.props b/src/wix/WixToolset.Sdk/tools/wix.props
index 0f7cf469..6a7f353d 100644
--- a/src/wix/WixToolset.Sdk/tools/wix.props
+++ b/src/wix/WixToolset.Sdk/tools/wix.props
@@ -16,8 +16,6 @@
16 <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> 16 <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
17 17
18 <PropertyGroup> 18 <PropertyGroup>
19 <Configurations Condition=" '$(Configurations)' == '' ">Debug;Release</Configurations>
20 <Platforms Condition=" '$(Platforms)' == '' ">x86,x64,ARM64,AnyCPU</Platforms>
21 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 19 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
22 </PropertyGroup> 20 </PropertyGroup>
23 21
diff --git a/src/wix/WixToolset.Sdk/tools/wix.targets b/src/wix/WixToolset.Sdk/tools/wix.targets
index b9bacb42..a04c1ec9 100644
--- a/src/wix/WixToolset.Sdk/tools/wix.targets
+++ b/src/wix/WixToolset.Sdk/tools/wix.targets
@@ -70,7 +70,6 @@
70 70
71 <!-- Default OutputType to a known WiX Toolset type. --> 71 <!-- Default OutputType to a known WiX Toolset type. -->
72 <OutputType Condition=" '$(OutputType)' == '' ">Package</OutputType> 72 <OutputType Condition=" '$(OutputType)' == '' ">Package</OutputType>
73 <AvailablePlatforms>x86,x64,ARM64,AnyCPU</AvailablePlatforms>
74 73
75 <WixPdbType Condition=" '$(WixPdbType)' == '' ">full</WixPdbType> 74 <WixPdbType Condition=" '$(WixPdbType)' == '' ">full</WixPdbType>
76 </PropertyGroup> 75 </PropertyGroup>
@@ -377,12 +376,7 @@
377 DependsOnTargets="$(ResolveWixLibraryReferencesDependsOn)"> 376 DependsOnTargets="$(ResolveWixLibraryReferencesDependsOn)">
378 377
379 <PropertyGroup> 378 <PropertyGroup>
380 <WixLibrarySearchPaths Condition=" '$(WixLibrarySearchPaths)' == '' "> 379 <WixLibrarySearchPaths Condition=" '$(WixLibrarySearchPaths)' == '' ">$(ReferencePaths);{HintPathFromItem};{RawFileName};$(WixExtDir)</WixLibrarySearchPaths>
381 $(ReferencePaths);
382 {HintPathFromItem};
383 {RawFileName};
384 $(WixExtDir)
385 </WixLibrarySearchPaths>
386 </PropertyGroup> 380 </PropertyGroup>
387 381
388 <ResolveWixReferences 382 <ResolveWixReferences
@@ -428,14 +422,9 @@
428 DependsOnTargets="$(ResolveWixExtensionReferencesDependsOn)" 422 DependsOnTargets="$(ResolveWixExtensionReferencesDependsOn)"
429 Condition=" '@(WixExtension)' != ''"> 423 Condition=" '@(WixExtension)' != ''">
430 424
431 <CreateProperty Condition=" '$(WixExtensionSearchPaths)' == '' " Value=" 425 <PropertyGroup>
432 $(ReferencePaths); 426 <WixExtensionSearchPaths Condition=" '$(WixExtensionSearchPaths)' == '' ">$(ReferencePaths);{HintPathFromItem};{RawFileName};$(WixExtDir)</WixExtensionSearchPaths>
433 {HintPathFromItem}; 427 </PropertyGroup>
434 {RawFileName};
435 $(WixExtDir)
436 ">
437 <Output TaskParameter="Value" PropertyName="WixExtensionSearchPaths" />
438 </CreateProperty>
439 428
440 <ResolveWixReferences 429 <ResolveWixReferences
441 WixReferences="@(WixExtension)" 430 WixReferences="@(WixExtension)"