私はMercurialリポジトリのルートディレクトリに次のコマンドを実行しています。私は「の.hg」で始まるすべてのファイルとフォルダを削除する:PowerShell remove-itemは成功しましたが例外をスローします
gci -rec -filter ".hg*" | remove-item -recurse -force
奇妙なこと、それは実際に動作するが、それでも次の例外生成しないことです:例外ので
Get-ChildItem : Could not find a part of the path 'C:\temp\WSCopyTest\MyCompany.Services.DaftPunk\.hg\'.
At line:1 char:4
+ gci <<<< -rec -filter ".hg*" | remove-item -recurse -force
+ CategoryInfo : ReadError: (C:\temp\WSCopyT...es.DaftPunk\.hg:String) [Get-ChildItem], DirectoryNotFoundException
+ FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand
をGet-ChildItem
によってスローされ、私はPowerShellのパイプラインの私の理解が間違っていると思う。ほとんどの場合、Get-ChildItem
はアイテムを見つけてパイプラインの次のコマンドレットに渡し、次のコマンドレットを探します。それはどういう仕組みですか?
以下は、同じマシン上で、問題を再現するスクリプトをすることになっていたが、それは完璧に動作します:
$repoRoot = "C:\Temp\HgDeleteTest\MyRepo"
remove-item $repoRoot -recurse -force
md $repoRoot
pushd $repoRoot
hg.exe init
add-content ShouldBeLeftBehind.txt "This is some text in a file that should be left behind once the various .hg files/directories are removed."
add-content .hgignore syntax:glob
add-content .hgignore *.dll
add-content .hgignore *.exe
hg.exe commit --addremove --message "Building test repository with one commit."
gci -rec -filter ".hg*" | remove-item -recurse -force
popd
同じマシンで動作するのと同じ問題ですが、別のマシンでこのエラーが発生します。 – johntrepreneur
2つの動作セットがある場合は、それがパワーシェルバージョンの問題である可能性があります。 – johntrepreneur