aboutsummaryrefslogtreecommitdiff
path: root/src/internal
diff options
context:
space:
mode:
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/WixToolset.BaseBuildTasks.Sources/FileSearchHelperMethods.cs57
-rw-r--r--src/internal/WixToolset.BaseBuildTasks.Sources/WixCommandLineBuilder.cs73
2 files changed, 0 insertions, 130 deletions
diff --git a/src/internal/WixToolset.BaseBuildTasks.Sources/FileSearchHelperMethods.cs b/src/internal/WixToolset.BaseBuildTasks.Sources/FileSearchHelperMethods.cs
deleted file mode 100644
index 442fedd6..00000000
--- a/src/internal/WixToolset.BaseBuildTasks.Sources/FileSearchHelperMethods.cs
+++ /dev/null
@@ -1,57 +0,0 @@
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
3namespace WixToolset.BaseBuildTasks
4{
5 using System;
6 using System.IO;
7
8 /// <summary>
9 /// Contains helper methods on searching for files
10 /// </summary>
11 public static class FileSearchHelperMethods
12 {
13 /// <summary>
14 /// Searches for the existence of a file in multiple directories.
15 /// Search is satisfied if default file path is valid and exists. If not,
16 /// file name is extracted from default path and combined with each of the directories
17 /// looking to see if it exists. If not found, input default path is returned.
18 /// </summary>
19 /// <param name="directories">Array of directories to look in, without filenames in them</param>
20 /// <param name="defaultFullPath">Default path - to use if not found</param>
21 /// <returns>File path if file found. Empty string if not found</returns>
22 public static string SearchFilePaths(string[] directories, string defaultFullPath)
23 {
24 if (String.IsNullOrEmpty(defaultFullPath))
25 {
26 return String.Empty;
27 }
28
29 if (File.Exists(defaultFullPath))
30 {
31 return defaultFullPath;
32 }
33
34 if (directories == null)
35 {
36 return String.Empty;
37 }
38
39 var fileName = Path.GetFileName(defaultFullPath);
40 foreach (var currentPath in directories)
41 {
42 if (String.IsNullOrWhiteSpace(currentPath))
43 {
44 continue;
45 }
46
47 var path = Path.Combine(currentPath, fileName);
48 if (File.Exists(path))
49 {
50 return path;
51 }
52 }
53
54 return String.Empty;
55 }
56 }
57}
diff --git a/src/internal/WixToolset.BaseBuildTasks.Sources/WixCommandLineBuilder.cs b/src/internal/WixToolset.BaseBuildTasks.Sources/WixCommandLineBuilder.cs
index 152992dd..d950bca9 100644
--- a/src/internal/WixToolset.BaseBuildTasks.Sources/WixCommandLineBuilder.cs
+++ b/src/internal/WixToolset.BaseBuildTasks.Sources/WixCommandLineBuilder.cs
@@ -76,79 +76,6 @@ namespace WixToolset.BaseBuildTasks
76 } 76 }
77 77
78 /// <summary> 78 /// <summary>
79 /// Build the extensions argument. Each extension is searched in the current folder, user defined search
80 /// directories (ReferencePath), HintPath, and under Wix Extension Directory in that order.
81 /// The order of precedence is based off of that described in Microsoft.Common.Targets's SearchPaths
82 /// property for the ResolveAssemblyReferences task.
83 /// </summary>
84 /// <param name="extensions">The list of extensions to include.</param>
85 /// <param name="wixExtensionDirectory">Evaluated default folder for Wix Extensions</param>
86 /// <param name="referencePaths">User defined reference directories to search in</param>
87 public void AppendExtensions(ITaskItem[] extensions, string wixExtensionDirectory, string [] referencePaths)
88 {
89 if (extensions == null)
90 {
91 return;
92 }
93
94 foreach (ITaskItem extension in extensions)
95 {
96 string className = extension.GetMetadata("Class");
97
98 string fileName = Path.GetFileName(extension.ItemSpec);
99
100 if (String.IsNullOrEmpty(Path.GetExtension(fileName)))
101 {
102 fileName += ".dll";
103 }
104
105 // First try reference paths
106 var resolvedPath = FileSearchHelperMethods.SearchFilePaths(referencePaths, fileName);
107
108 if (String.IsNullOrEmpty(resolvedPath))
109 {
110 // Now try HintPath
111 resolvedPath = extension.GetMetadata("HintPath");
112
113 if (!File.Exists(resolvedPath))
114 {
115 // Now try the item itself
116 resolvedPath = extension.ItemSpec;
117
118 if (String.IsNullOrEmpty(Path.GetExtension(resolvedPath)))
119 {
120 resolvedPath += ".dll";
121 }
122
123 if (!File.Exists(resolvedPath))
124 {
125 if (!String.IsNullOrEmpty(wixExtensionDirectory))
126 {
127 // Now try the extension directory
128 resolvedPath = Path.Combine(wixExtensionDirectory, Path.GetFileName(resolvedPath));
129 }
130
131 if (!File.Exists(resolvedPath))
132 {
133 // Extension wasn't found, just set it to the extension name passed in
134 resolvedPath = extension.ItemSpec;
135 }
136 }
137 }
138 }
139
140 if (String.IsNullOrEmpty(className))
141 {
142 this.AppendSwitchIfNotNull("-ext ", resolvedPath);
143 }
144 else
145 {
146 this.AppendSwitchIfNotNull("-ext ", className + ", " + resolvedPath);
147 }
148 }
149 }
150
151 /// <summary>
152 /// Append arbitrary text to the command-line if specified. 79 /// Append arbitrary text to the command-line if specified.
153 /// </summary> 80 /// </summary>
154 /// <param name="textToAppend">Text to append.</param> 81 /// <param name="textToAppend">Text to append.</param>