You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kev/Drawer/bin/Debug/CopyBinToKep.ps1

39 lines
1.2 KiB
PowerShell

# 定义源目录和目标目录
$sourceDir = "D:\kep\Drawer\Drawer\bin\Debug" # 源目录路径
$destinationDir = "D:\kep\Client\bin\Debug" # 目标目录路径
# 检查源目录是否存在,如果不存在则创建
if (-not (Test-Path -Path $sourceDir)) {
Write-Host "警告: 源目录不存在。" -ForegroundColor Yellow
exit
}
# 检查目标目录是否存在,如果不存在则创建
if (-not (Test-Path -Path $destinationDir)) {
Write-Host "警告: 目录不存在。" -ForegroundColor Yellow
exit
}
# 获取源目录下的所有 .dll, .pdb, .lib 文件
$files = Get-ChildItem -Path "$sourceDir\*" -File -Include *.dll, *.pdb, *.lib,*.exe
# 检查是否找到文件
if ($files.Count -eq 0) {
Write-Host "警告: 源目录中未找到任何 .dll, .pdb, .lib 文件。" -ForegroundColor Yellow
exit
}
# 将文件复制到目标目录
foreach ($file in $files) {
# 构建目标文件路径
$destFilePath = Join-Path -Path $destinationDir -ChildPath $file.Name
$sourcePath = Join-Path -Path $sourceDir -ChildPath $file.Name
try {
# 复制文件
Copy-Item -Path $sourcePath -Destination $destFilePath -Force
Write-Host "复制文件: $sourcePath$destinationDir"
} catch {
Write-Host "错误: 无法复制 $sourcePath - $_" -ForegroundColor Red
}
}