Ejemplo n.º 1
0
 public static string GetMetadataValue(MSBuild.ProjectItem item, string name)
 {
     return item.GetMetadataValue(name);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Get the parent node of an msbuild item
        /// </summary>
        /// <param name="item">msbuild item</param>
        /// <returns>parent node</returns>
        protected virtual HierarchyNode GetItemParentNode(MSBuild.ProjectItem item, IDictionary<string, HierarchyNode> nodeCache)
        {
            if (item == null)
                throw new ArgumentNullException("item");
            if (nodeCache == null)
                throw new ArgumentNullException("nodeCache");
            //Contract.Ensures(Contract.Result<HierarchyNode>() != null);

            HierarchyNode currentParent = this;
            string strPath = item.EvaluatedInclude;
            string link = item.GetMetadataValue(ProjectFileConstants.Link);
            if (!string.IsNullOrEmpty(link))
                strPath = link;

            strPath = Path.GetDirectoryName(strPath);
            if (strPath.Length > 0)
            {
                if (!nodeCache.TryGetValue(strPath, out currentParent))
                {
                    // Use the relative to verify the folders...
                    currentParent = this.CreateFolderNodes(strPath, nodeCache);
                    nodeCache.Add(strPath, currentParent);
                }
            }

            return currentParent;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Get the parent node of an msbuild item
 /// </summary>
 /// <param name="item">msbuild item</param>
 /// <returns>parent node</returns>
 private HierarchyNode GetItemParentNode(MSBuild.ProjectItem item)
 {
     var isLink = IsLinkNode(item);
     var path = isLink ? item.GetMetadataValue("Link") : item.EvaluatedInclude;
     var dir = Path.GetDirectoryName(path);
     return Path.IsPathRooted(dir) || string.IsNullOrEmpty(dir)
         ? this : CreateFolderNodes(dir);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Add an item to the hierarchy based on the item path
        /// </summary>
        /// <param name="item">Item to add</param>
        /// <returns>Added node</returns>
        protected virtual HierarchyNode AddIndependentFileNode(MSBuild.ProjectItem item, IDictionary<string, HierarchyNode> parentNodeCache)
        {
            if (item == null)
                throw new ArgumentNullException("item");
            if (parentNodeCache == null)
                throw new ArgumentNullException("parentNodeCache");
            //Contract.Ensures(Contract.Result<HierarchyNode>() != null);

            // Make sure the item is within the project folder hierarchy. If not, link it.
            string linkPath = item.GetMetadataValue(ProjectFileConstants.Link);
            if (String.IsNullOrEmpty(linkPath))
            {
                string projectFolder = new Uri(this.ProjectFolder).LocalPath;
                string itemPath = new Uri(Path.Combine(this.ProjectFolder, item.EvaluatedInclude)).LocalPath;
                if (!itemPath.StartsWith(projectFolder, StringComparison.OrdinalIgnoreCase))
                {
                    linkPath = Path.GetFileName(item.EvaluatedInclude);
                    item.SetMetadataValue(ProjectFileConstants.Link, linkPath);
                }
            }

            HierarchyNode currentParent = GetItemParentNode(item, parentNodeCache);
            return AddFileNodeToNode(item, currentParent);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get the parent node of an msbuild item
        /// </summary>
        /// <param name="item">msbuild item</param>
        /// <returns>parent node</returns>
        private HierarchyNode GetItemParentNode(MSBuild.ProjectItem item)
        {
            HierarchyNode currentParent = this;
            string strPath;

            // !EFW
            // If it's a link, use the linked path for the node
            strPath = item.GetMetadataValue(ProjectFileConstants.Link);

            if(String.IsNullOrEmpty(strPath))
                strPath = item.EvaluatedInclude;

            strPath = Path.GetDirectoryName(strPath);
            if(strPath.Length > 0)
            {
                // Use the relative to verify the folders...
                currentParent = this.CreateFolderNodes(strPath);
            }
            return currentParent;
        }