简体   繁体   English

在VS2015中调试Powershell无法可视化XML对象

[英]Debugging Powershell in VS2015 Can't Visualize XML objects

I am attempting to code/debug a powershell script within vs2015, having installed the PowerShellTools.14.0.vsix addon. 我试图在vs2015中编写/调试powershell脚本,安装了PowerShellTools.14.0.vsix插件。 (Note, this is happening inside a VM, running Windows Server 2008 R2, powershell version 3.0) (注意,这发生在运行Windows Server 2008 R2,PowerShell 3.0版的VM中)

All is working well, save that I am unable to debug XML resources. 一切都运行良好,除了我无法调试XML资源。 I cannot see into the XML objects. 我无法看到XML对象。 Variables in the watch window contain no relevant data (unless you call the XMLElement hierarchy relevant). 监视窗口中的变量不包含相关数据(除非您调用XMLElement层次结构相关)。 Conversion to other types, like JSON also seem to provide no help. 转换为其他类型,如JSON似乎也没有提供任何帮助。

Here's some sample code... 这是一些示例代码......

$r = Invoke-SafeWebRequest -Uri $url 
[xml]$xml = $r

Invoke-SafeWebRequest is a simple wrapper around Invoke-WebRequest to handle non-200-ok status returns from REST-ish web services. Invoke-SafeWebRequest是一个简单的Invoke-WebRequest包装器,用于处理REST-ish Web服务的非200-ok状态返回。 It always returns a simple string 它总是返回一个简单的字符串

Here's what the watch window looks like. 这是观察窗口的样子。 As you can see, there's no data, other than structure here. 如您所见,除了结构之外,没有数据。 观察窗口

What I'm expecting to see in that watch window, is some kind of visualization of the XML data. 我希望在该监视窗口中看到的是XML数据的某种可视化。

I've also tried a few alternatives for loading the XML data into an XML object, and I haven't seen any different behavior, except for this one: 我还尝试了一些替代方法来将XML数据加载到XML对象中,除了这个之外我没有看到任何不同的行为:

$y = New-Object -TypeName System.Xml.XmlDocument
$y.LoadXml($r)

Which looks like this in the watch window.. 在观察窗口看起来像这样.. 另一个观察窗口

I am somewhat confused that the New-Object I created doesn't seem to have the type that I asked it to have. 我有点困惑的是,我创建的New-Object似乎没有我要求的类型。 But at least this object will let me see inner text, etc. But, again, when I try to examine the child nodes, I get the same behavior again (as with the first screenshot), and I'm unable to see the actual data returned. 但至少这个对象会让我看到内部文本等等。但是,当我尝试检查子节点时,我再次得到相同的行为(与第一个屏幕截图一样),我无法看到实际数据返回。

Am I somehow loading the data into XML incorrectly? 我以某种方式错误地将数据加载到XML中? Shouldn't I be able to visualize this data easily? 我不应该能够轻松地将这些数据可视化吗? Is there something else I'm missing? 还有什么我想念的吗?

As near as I can tell, this appears to be a bug with Powershell Tools. 尽管我可以说,这似乎是Powershell Tools的一个错误。

Adam Driscoll says "We aren't really expanding the XmlElement nodes correctly." Adam Driscoll说:“我们并没有真正正确地扩展XmlElement节点。” And a bug was logged on September 17, 2015... it is open at the time of this post. 并且在2015年9月17日记录了一个错误...它在本文发布时已经打开。

https://github.com/adamdriscoll/poshtools/issues/337 https://github.com/adamdriscoll/poshtools/issues/337

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM