通过powershell复制文件

时间:2014-07-23 16:53:17

标签: powershell copy

我有一个Project,它在bin文件夹中构建了一堆dll,并且还引用了外部lib文件夹中的其他dll。我需要先从lib文件夹中复制所有内容,然后从我的应用程序的bin文件夹中复制,并将所有dll复制到我的解决方案的部署位置。 这需要递归lib文件夹,因为很多引用都在他们自己的文件夹结构中。

1 个答案:

答案 0 :(得分:0)

想出来,所以我想与其他可能想要做同样事情的人分享。 这是powershell脚本:

Clear-Host
Write-Host "Copying the LIB folder now.."
$LibFolderPath = "C:\lib"
$DestPath = "C:\website\bin\"
$BinPath = "C:\project\bin"
ForEach($file in Get-Childitem $LibFolderPath -Recur`enter code here`se -ErrorAction SilentlyContinue `
| Where-Object {$_.Extension -Match "dll" -or $_.Extension -Match "pdb"} )
{
Write-Host "Copying file: $file"
Copy-Item -Path $file.fullname -Destination $DestPath -force 
}


Write-Host "Copying the BIN folder now.."
ForEach($file in Get-Childitem $BinPath -Recurse -ErrorAction SilentlyContinue `
| Where-Object {$_.Extension -Match "dll" -or $_.Extension -Match "pdb"} )
{
Write-Host "Copying file: $file"
Copy-Item -Path $file.fullname -Destination $DestPath -force 
}
相关问题