Resources/Development/New-CabDevelopment.ps1
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
function New-CabDevelopment { [CmdletBinding()] Param ( [Parameter(Mandatory=$True)] [string]$Path, [System.Management.Automation.SwitchParameter]$LZXHighCompression, [System.Management.Automation.SwitchParameter]$MakeCABsFromSubDirs ) If ($LZXHighCompression) { $Compress = ".Set CompressionType=LZX" } Else { $Compress = ".Set CompressionType=MSZIP" } If ($MakeCABsFromSubDirs) { Get-ChildItem -Directory -Path $Path | ForEach ($_) { PSMakeCAB $_.FullName } } Else { PSMakeCAB $Path } } function PSMakeCAB($Path) { #Set the CAB File Name $CabFileName = (Get-Item $Path).Name $CabFileNameExt = (Get-Item $Path).Name + ".cab" #Set the Destination Directory $DestinationDir = (Get-Item $Path).Parent.FullName Write-Host "Creating " $DestinationDir\$CabFileNameExt $ddf = ";*** MakeCAB Directive file; .OPTION EXPLICIT .Set CabinetNameTemplate=$CabFileNameExt .Set DiskDirectory1=$DestinationDir .Set Cabinet=on .Set Compress=on $Compress .Set CabinetFileCountThreshold=0 .Set FolderFileCountThreshold=0 .Set FolderSizeThreshold=0 .Set MaxCabinetSize=0 .Set MaxDiskFileCount=0 .Set MaxDiskSize=0 " $PathFullName = (Get-Item $Path).fullname #Remove Streams Get-ChildItem $PathFullName -Recurse | Unblock-File $ddfpath = ($DestinationDir+"\$CabFileName.ddf") $ddf += (ls -recurse $Path | ? {!$_.psiscontainer}|select -expand fullname|%{'"'+$_+'" "'+$_.SubString($PathFullName.length+1)+'"'}) -join "`r`n" $ddf $ddf | Out-File -encoding UTF8 $ddfpath -Width 2000 -Force makecab /F $ddfpath #rm $ddfpath #rm setup.inf #rm setup.rpt } |