英文:
MyCommand's Source vs Path
问题
$MyInvocation.MyCommand
的.Source
与.Path
在什么情况下不同?
根据文档,其中一个"获取脚本文件的路径",而另一个"获取此命令的源",但每当我看到其中一个有值时,另一个也具有相同的值。
这只是与此特定自动变量的巧合,其他ExternalScriptInfo
是否更复杂?
英文:
Under what circumstances does $MyInvocation.MyCommand
's .Source
differ from .Path
?
One "Gets the path to the script file." whilst the other "Gets the source of this command." according to the docs, but whenever I've ever seen one populated the other has the same value.
Is this just a coincidence with this specific automatic variable and other ExternalScriptInfo
s are more complex?
答案1
得分: 1
如评论中所提到的,对于 ExternalScriptInfo
实例,Path
、Source
和 Definition
属性始终返回底层路径 - 可以通过查看此处的源代码进行验证。
对于 ApplicationInfo
也是一样的情况,请查看此处的源代码。
英文:
As mentioned in the comments, for ExternalScriptInfo
instances, the Path
, Source
and Definition
properties always return the underlying path - as can be verified by inspecting the source code here.
The same goes for ApplicationInfo
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论