Xpath 不是通过 Powershell Select-Xml 中的运算符
我正在使用 csproj 文件,并且正在尝试编写一个 cmdlet 来提取项目文件引用的所有文件。这将包括所有 Compile、EmbeddedResource、Resource、Content 和 None 元素(更重要的是它们的 @Include 值),但我特别想排除 Reference 元素,因为它们引用 dll,而这与我无关。
我没有太多的经验,但我认为我想要的 xpath 表达式看起来像这样
$projectFile | Select-Xml -namespace @{msb="http://schemas.microsoft.com/developer/msbuild/2003"} -xpath "//msb:ItemGroup/*[not(self::node() = msb:Reference) and @Include]"
但是,一旦我尝试引入 self::node() 我的表达式就不会返回任何节点。我不是 100% 确定 self::node() 是执行此操作的正确方法。知道我要更改什么才能使其在概念上返回“所有包含不是 Reference 元素的节点的属性值吗?”
I'm working with csproj files, and I'm trying to write a cmdlet that extracts all of the files referenced by a project file. This will include all of the Compile, EmbeddedResource, Resource, Content, and None elements (more importantly, their @Include values) but I specifically want to exclude the Reference elements as they refer to dlls, which aren't of concern to me.
I don't have a ton of experience, but I would think the xpath expression I would want would look something like this
$projectFile | Select-Xml -namespace @{msb="http://schemas.microsoft.com/developer/msbuild/2003"} -xpath "//msb:ItemGroup/*[not(self::node() = msb:Reference) and @Include]"
However, as soon as I try to introduce the self::node() my expression returns no nodes. I'm not 100% sure that self::node() is the right way to be doing this though. Any idea what I would change to make it return, conceptually, "all Include attribute values for nodes that are not Reference elements that are child elements of an ItemGroup element?"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您需要:
含义:
msb:ItemGroup
的任何子项的所有Inlude
属性(msb 除外):参考
,在整个文档中I think that you need:
Meaning: all the
Include
attributes of any child ofmsb:ItemGroup
except formsb:Reference
, in the whole document