aboutsummaryrefslogtreecommitdiff
path: root/scripts/buildsystems/msbuild/applocal.ps1
blob: 46981fad5bae1fe19b50048e367f3a1f34e9173e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
[cmdletbinding()]
param([string]$targetBinary, [string]$installedDir, [string]$tlogFile)

function resolve($targetBinary) {
    $targetBinaryPath = Resolve-Path $targetBinary
    $targetBinaryDir = Split-Path $targetBinaryPath -parent

    $a = $(dumpbin /DEPENDENTS $targetBinary | ? { $_ -match "^    [^ ].*\.dll" } | % { $_ -replace "^    ","" })
    $a | % {
        if ([string]::IsNullOrEmpty($_)) {
            continue
        }
        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)