# 定义源目录和目标目录 $sourceDir = "D:\kep\Drawer\Drawer\bin\Release" # 源目录路径 $destinationDir = "D:\kep\Client\bin\Release" # 目标目录路径 # 检查源目录是否存在,如果不存在则创建 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 } }