Beispiel #1
0
        protected static List <string> AdjustFilePaths(ITaskItem[] tasks, string[] referencePaths)
        {
            List <string> sourceFilePaths = new List <string>();

            if (tasks == null)
            {
                return(sourceFilePaths);
            }

            foreach (ITaskItem task in tasks)
            {
                string filePath = task.ItemSpec;
                if (!File.Exists(filePath))
                {
                    filePath = task.GetMetadata("HintPath");
                    if (!File.Exists(filePath))
                    {
                        string searchPath = FileSearchHelperMethods.SearchFilePaths(referencePaths, filePath);
                        if (!String.IsNullOrEmpty(searchPath))
                        {
                            filePath = searchPath;
                        }
                    }
                }
                sourceFilePaths.Add(filePath);
            }

            return(sourceFilePaths);
        }
Beispiel #2
0
        /// <summary>
        /// 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.
        /// </summary>
        /// <param name="extensions">The list of extensions to include.</param>
        /// <param name="wixExtensionDirectory">Evaluated default folder for Wix Extensions</param>
        /// <param name="referencePaths">User defined reference directories to search in</param>
        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);
                }
            }
        }