From 08f53f409020b12dffaa2aeefa943b667a4b9328 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Fri, 14 Oct 2022 09:34:30 -0700 Subject: Simplify reference resolution WiX v3 extension loading had options that were rarely if ever used and library paths modeled after C++. Given the new Sdk-style model in WiX v4, we can simplify reference resolution. Fixes 6945, 6946 --- .../FileSearchHelperMethods.cs | 57 ----------------- .../WixCommandLineBuilder.cs | 73 ---------------------- 2 files changed, 130 deletions(-) delete mode 100644 src/internal/WixToolset.BaseBuildTasks.Sources/FileSearchHelperMethods.cs (limited to 'src/internal/WixToolset.BaseBuildTasks.Sources') 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 @@ -// 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. - -namespace WixToolset.BaseBuildTasks -{ - using System; - using System.IO; - - /// - /// Contains helper methods on searching for files - /// - public static class FileSearchHelperMethods - { - /// - /// Searches for the existence of a file in multiple directories. - /// Search is satisfied if default file path is valid and exists. If not, - /// file name is extracted from default path and combined with each of the directories - /// looking to see if it exists. If not found, input default path is returned. - /// - /// Array of directories to look in, without filenames in them - /// Default path - to use if not found - /// File path if file found. Empty string if not found - public static string SearchFilePaths(string[] directories, string defaultFullPath) - { - if (String.IsNullOrEmpty(defaultFullPath)) - { - return String.Empty; - } - - if (File.Exists(defaultFullPath)) - { - return defaultFullPath; - } - - if (directories == null) - { - return String.Empty; - } - - var fileName = Path.GetFileName(defaultFullPath); - foreach (var currentPath in directories) - { - if (String.IsNullOrWhiteSpace(currentPath)) - { - continue; - } - - var path = Path.Combine(currentPath, fileName); - if (File.Exists(path)) - { - return path; - } - } - - return String.Empty; - } - } -} 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 @@ -75,79 +75,6 @@ namespace WixToolset.BaseBuildTasks } } - /// - /// Build the extensions argument. Each extension is searched in the current folder, user defined search - /// directories (ReferencePath), HintPath, and under Wix Extension Directory in that order. - /// The order of precedence is based off of that described in Microsoft.Common.Targets's SearchPaths - /// property for the ResolveAssemblyReferences task. - /// - /// The list of extensions to include. - /// Evaluated default folder for Wix Extensions - /// User defined reference directories to search in - public void AppendExtensions(ITaskItem[] extensions, string wixExtensionDirectory, string [] referencePaths) - { - if (extensions == null) - { - return; - } - - foreach (ITaskItem extension in extensions) - { - string className = extension.GetMetadata("Class"); - - string fileName = Path.GetFileName(extension.ItemSpec); - - if (String.IsNullOrEmpty(Path.GetExtension(fileName))) - { - fileName += ".dll"; - } - - // First try reference paths - var resolvedPath = FileSearchHelperMethods.SearchFilePaths(referencePaths, fileName); - - if (String.IsNullOrEmpty(resolvedPath)) - { - // Now try HintPath - resolvedPath = extension.GetMetadata("HintPath"); - - if (!File.Exists(resolvedPath)) - { - // Now try the item itself - resolvedPath = extension.ItemSpec; - - if (String.IsNullOrEmpty(Path.GetExtension(resolvedPath))) - { - resolvedPath += ".dll"; - } - - if (!File.Exists(resolvedPath)) - { - if (!String.IsNullOrEmpty(wixExtensionDirectory)) - { - // Now try the extension directory - resolvedPath = Path.Combine(wixExtensionDirectory, Path.GetFileName(resolvedPath)); - } - - if (!File.Exists(resolvedPath)) - { - // Extension wasn't found, just set it to the extension name passed in - resolvedPath = extension.ItemSpec; - } - } - } - } - - if (String.IsNullOrEmpty(className)) - { - this.AppendSwitchIfNotNull("-ext ", resolvedPath); - } - else - { - this.AppendSwitchIfNotNull("-ext ", className + ", " + resolvedPath); - } - } - } - /// /// Append arbitrary text to the command-line if specified. /// -- cgit v1.2.3-55-g6feb