Skip to content

Commit 7b08d12

Browse files
committed
Run script in a separate process to prevent files from locking
1 parent 3e0d73d commit 7b08d12

File tree

1 file changed

+52
-30
lines changed

1 file changed

+52
-30
lines changed

development/validation/Test-DLL.ps1

Lines changed: 52 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,57 +4,79 @@ function Test-DLL {
44
Helper script for checking DLLs
55
66
.DESCRIPTION
7-
This script does three things:
8-
- displays build configuration
9-
- displays target CPU information
10-
- displays informtaion about Jit Optimization
7+
This script displays information about every dll located in a given path
118
12-
.PARAMETER StartPath
13-
Location of the folder where your DLLs live.
9+
You can get information about
10+
- FileVersion
11+
- ProductVersion
12+
- LegalCopyright
13+
- BuildConfiguration
14+
- TargetCPU
15+
- JitOptimized flag
16+
17+
.PARAMETER DllFolder
18+
Location of the folder with dlls.
1419
1520
.EXAMPLE
1621
Test-DLL "C:\dll" -CleanHost
17-
Clears console and then displays information about all DLLs located in "C:\\dll"
22+
Clears console and then displays information about all DLLs located in "C:\dll"
1823
1924
.EXAMPLE
2025
Test-DLL "C:\dll"
21-
Displays information about all DLLs located in "C:\\dll"
26+
Displays information about all DLLs located in "C:\dll"
2227
#>
2328

2429
[CmdletBinding()]
2530
param(
2631
[Parameter(Mandatory = $true)]
27-
[string]$StartPath,
32+
[string]$DllFolder,
2833
[Parameter(Mandatory = $false)]
2934
[switch]$CleanHost
3035
)
3136

3237
process {
33-
if (!(Test-Path $StartPath)) {
38+
if (!(Test-Path $DllFolder)) {
3439
Write-Host "Incorrect folder path:" -ForegroundColor Red
35-
Write-Host "$StartPath" -ForegroundColor Red
40+
Write-Host "$LogsFolder" -ForegroundColor Red
3641
exit
3742
}
38-
if ($CleanHost) {
39-
Clear-Host
40-
}
4143

42-
Import-Module DLLInfo
43-
Get-ChildItem $StartPath | % {
44-
Write-Host $_.FullName -ForegroundColor Green
45-
$versionInfo = (Get-Item $_.FullName).VersionInfo
46-
$versionInfo.ProductVersion
47-
$versionInfo.FileVersion
48-
$versionInfo.LegalCopyright
49-
50-
$buildConfiguration = Get-BuildConfiguration $_.FullName
51-
$targetCPU = Get-TargetCPU $_.FullName
52-
$jitOptimized = Test-JitOptimized $_.FullName
53-
54-
Write-Host "BuildConfiguration`t [$buildConfiguration]" -ForegroundColor Yellow
55-
Write-Host "TargetCPU`t`t [$targetCPU] " -ForegroundColor Yellow
56-
Write-Host "JitOptimized`t`t [$jitOptimized]" -ForegroundColor Yellow
57-
write-host ""
44+
$scriptBlock = {
45+
[CmdletBinding()]
46+
param([string]$DllFolder)
47+
48+
begin {
49+
Import-Module DLLInfo
50+
}
51+
52+
process {
53+
Get-ChildItem -LiteralPath $DllFolder -Filter "*.dll" | % {
54+
Write-Host $_.FullName -ForegroundColor Yellow
55+
$versionInfo = (Get-Item $_.FullName).VersionInfo
56+
Write-Host "FileVersion `t`t[$($versionInfo.FileVersion)]"
57+
Write-Host "ProductVersion`t`t[$($versionInfo.ProductVersion)]"
58+
Write-Host "LegalCopyright`t`t[$($versionInfo.LegalCopyright)]"
59+
$buildConfiguration = Get-BuildConfiguration $_.FullName
60+
if ($buildConfiguration -eq "Release") {
61+
Write-Host "BuildConfiguration`t[$buildConfiguration]" -ForegroundColor Green
62+
}
63+
else {
64+
Write-Host "BuildConfiguration`t[$buildConfiguration]" -ForegroundColor Red
65+
}
66+
$targetCPU = Get-TargetCPU $_.FullName
67+
Write-Host "TargetCPU`t`t[$targetCPU] "
68+
$jitOptimized = Test-JitOptimized $_.FullName
69+
Write-Host "JitOptimized`t`t[$jitOptimized]"
70+
write-host ""
71+
}
72+
}
5873
}
74+
75+
$tmp = New-TemporaryFile
76+
$scriptBlock.ToString() | Out-File $tmp.FullName
77+
$scriptFilePath = [System.IO.Path]::ChangeExtension($tmp.FullName, ".ps1")
78+
$tmp | Rename-Item -NewName $tmp.Name.Replace(".tmp", ".ps1")
79+
Invoke-Expression "powershell.exe $scriptFilePath `"'$DllFolder'`""
80+
Remove-Item $scriptFilePath -Force
5981
}
6082
}

0 commit comments

Comments
 (0)