当前文件夹结构如下所示:
ISPS/
âââ ISPS/
â âââ Private/
â âââ Public/
â â âââ Add-ICDCrawler.ps1
â â âââ Get-ICDCrawler.ps1
â â âââ New-ICDCrawler.ps1
â â âââ Remove-ICDCrawler.ps1
â âââ ISPSCrawler.psd1
â âââ ISPSCrawler.psm1
âââ tests/
â âââ Add-ICDCrawler.tests.ps1
â âââ Get-ICDCrawler.tests.ps1
â âââ New-ICDCrawler.tests.ps1
â âââ Remove-ICDCrawler.tests.ps1
奇怪的测试是
Remove-ICDCrawler.tests.ps1
$ModuleRoot = Split-Path $PSScriptRoot -Parent
. $ModuleRoot\ISPS\Public\Get-ICDCrawler.ps1
. $ModuleRoot\ISPS\Public\Remove-ICDCrawler.ps1
当它运行时,dot寻源可以正确地用于
Get-ICDCrawler
Remove-ICDCrawler
. 这是出现的错误消息:
. : The term 'D:\Projects\ISPS\ISPS\ISPS\Public\Remove-ICDCrawler.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At D:\Projects\ISPS\tests\Remove-ICDCrawler.tests.ps1:4 char:3
+ . $ModuleRoot\ISPS\Public\Remove-ICDCrawler.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
这就够直截了当的了。有一个太多了
ISPS
ISP
Get-ICDCrawler.ps1
和
Remove-ICDCrawler.ps1
ISP
从第4行的路径来看是可行的,但它违背了我所知道的关于PowerShell的一切。有人知道为什么会这样吗?
Name Value
---- -----
PSVersion 5.1.15063.608
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.15063.608
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1