Created
April 5, 2016 19:09
-
-
Save P-A-R-U-S/14f00d13f19cee1a2ad9fb4c6f7da3a5 to your computer and use it in GitHub Desktop.
.NET: Copy PBD file to GAC ( Powershell script that copy all you PDB field to GAC)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ODB Files Location | |
$binFolder = "C:\Projects\.net 2.0\build\bin" | |
$gacFolder = "%SYSTEMROOT%\Assembly\GAC_MSIL" | |
set-location $binFolder | |
$pdbfiles = get-childitem | where {$_.name.EndsWith("pdb")} | |
foreach ($pdb in $pdbfiles) | |
{ | |
$dllPath = [System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName($pdb.FullName),[System.IO.Path]::GetFileNameWithoutExtension($pdb.FullName)) + ".dll" | |
if([System.IO.File]::Exists($dllPath)) | |
{ | |
#Write-Host 'EXIST:' $pdb.FullName | |
$dll = [System.Reflection.Assembly]::LoadFile($dllpath) | |
#$dll.FullName | |
$version = $dll.GetName().Version | |
#$version | |
$token = $dll.GetName().GetPublicKeyToken() | |
#$token | |
if($token -ne $null) | |
{ | |
$dllPath | |
$tokenStr = "" | |
foreach($b in $token) | |
{ | |
#Write-Host 'EXIST:' $b | |
if ([int]$b -lt 16) | |
{ | |
$tokenStr += "0"; | |
} | |
$tokenStr += [Convert]::ToString($b,16) | |
} | |
$tokenStr | |
$d = $version.ToString() + "__" + $tokenStr | |
$installPath = [System.IO.Path]::Combine($gacFolder,([System.IO.Path]::GetFileNameWithoutExtension($dllPath))) | |
$installPath = [System.IO.Path]::Combine($installPath,$d); | |
$installPath = [System.IO.Path]::Combine($installPath,[System.IO.Path]::GetFileName($pdb)) | |
#Write-Host "CHECK PATH:" $installPath | |
if([System.IO.Directory]::Exists([System.IO.Path]::GetDirectoryName($installPath))) | |
{ | |
Write-Host "COPY:" $pdb.FullName " --> " $installPath | |
[System.IO.File]::Copy($pdb.FullName,$installPath,$true) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment