2016-09-19 11:50:08 +08:00
|
|
|
[cmdletbinding()]
|
|
|
|
param([string]$targetBinary, [string]$installedDir, [string]$tlogFile)
|
|
|
|
|
|
|
|
function resolve($targetBinary) {
|
|
|
|
$targetBinaryPath = Resolve-Path $targetBinary
|
|
|
|
$targetBinaryDir = Split-Path $targetBinaryPath -parent
|
|
|
|
|
2016-11-09 11:02:59 +08:00
|
|
|
$a = $(dumpbin /DEPENDENTS $targetBinary | ? { $_ -match "^ [^ ].*\.dll" } | % { $_ -replace "^ ","" })
|
2016-09-19 11:50:08 +08:00
|
|
|
$a | % {
|
|
|
|
if (Test-Path "$installedDir\$_") {
|
|
|
|
if (Test-Path "$targetBinaryDir\$_") {
|
|
|
|
Write-Verbose "$_ is already present"
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Copy-Item $installedDir\$_ $targetBinaryDir
|
|
|
|
Write-Verbose "Copying $installedDir\$_ -> $_"
|
|
|
|
}
|
|
|
|
"$targetBinaryDir\$_"
|
|
|
|
if ($tlogFile) { Add-Content $tlogFile "$targetBinaryDir\$_" }
|
|
|
|
resolve("$targetBinaryDir\$_")
|
|
|
|
} else {
|
|
|
|
Write-Verbose "$installedDir\$_ not found"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resolve($targetBinary)
|