@@ -2076,7 +2076,7 @@ function ziptestresultlogs {
20762076# CreateProjectPackage
20772077function createprojectpackage {
20782078 [CmdletBinding ()]
2079- param ([Switch ]$help , [Switch ]$rph , [String ]$playlist , [Parameter (Position = 1 )][String ]$project , [Parameter (Position = 2 )][String ]$package )
2079+ param ([Switch ]$help , [Switch ]$rph , [String ]$playlist , [Parameter (Position = 1 )][String ]$project , [Parameter (Position = 2 )][String ]$package , [ String ] $driver , [ String ] $supplemental )
20802080
20812081 function Usage {
20822082 Write-Output " createprojectpackage:"
@@ -2167,6 +2167,60 @@ function createprojectpackage {
21672167 $PackagePath = $env: TEMP + " \prometheus_packages\" + $ (get-date ).ToString(" dd-MM-yyyy" ) + " _" + $ (get-date ).ToString(" hh_mm_ss" ) + " _" + $WntdProject.Name + " ." + $Studio + " x"
21682168 }
21692169 $PackageWriter = New-Object Microsoft.Windows.Kits.Hardware.ObjectModel.Submission.PackageWriter $WntdProject
2170+
2171+ # Add driver files to package if specified
2172+ if (-Not [String ]::IsNullOrEmpty($driver )) {
2173+ $driver = [System.IO.Path ]::GetFullPath($driver )
2174+ if (Test-Path $driver ) {
2175+ # Collect all targets from the project
2176+ $AllTargets = New-Object System.Collections.Generic.List[Microsoft.Windows.Kits.Hardware.ObjectModel.Target ]
2177+ foreach ($Pi in $WntdProject.GetProductInstances ()) {
2178+ foreach ($Target in $Pi.GetTargets ()) {
2179+ $AllTargets.Add ($Target )
2180+ }
2181+ }
2182+
2183+ if ($AllTargets.Count -gt 0 ) {
2184+ # Create ReadOnlyCollection<Target>
2185+ $TargetArray = [Microsoft.Windows.Kits.Hardware.ObjectModel.Target []]$AllTargets.ToArray ()
2186+ $TargetList = New-Object ' System.Collections.ObjectModel.ReadOnlyCollection[Microsoft.Windows.Kits.Hardware.ObjectModel.Target]' (, $TargetArray )
2187+
2188+ # Create ReadOnlyCollection<String> for locales
2189+ $LocaleArray = [string []]@ (" en-US" )
2190+ $LocaleList = New-Object ' System.Collections.ObjectModel.ReadOnlyCollection[string]' (, $LocaleArray )
2191+
2192+ # Create StringCollection instances for out parameters
2193+ $ErrorMessages = New-Object System.Collections.Specialized.StringCollection
2194+ $WarningMessages = New-Object System.Collections.Specialized.StringCollection
2195+
2196+ # Separate symbols (.pdb files) from the driver directory
2197+ $symbolPath = Join-Path ([System.IO.Path ]::GetTempPath()) ([Guid ]::NewGuid().ToString())
2198+ New-Item - ItemType Directory - Path $symbolPath | Out-Null
2199+ Get-ChildItem - Path $driver - Filter * .pdb - Recurse | ForEach-Object { Move-Item - Path $_.FullName - Destination $symbolPath - Force }
2200+
2201+ $AddDriverResult = $PackageWriter.AddDriver ($driver , $symbolPath , $TargetList , $LocaleList , [ref ]$ErrorMessages , [ref ]$WarningMessages )
2202+
2203+ if (-Not $json ) {
2204+ if ($AddDriverResult ) {
2205+ Write-Output " Driver added to package from $driver "
2206+ } else {
2207+ Write-Output " Warning: Driver signability check did not pass"
2208+ foreach ($err in $ErrorMessages ) { Write-Output " Error: $err " }
2209+ foreach ($warn in $WarningMessages ) { Write-Output " Warning: $warn " }
2210+ }
2211+ }
2212+ }
2213+ }
2214+ }
2215+
2216+ # Add supplemental files to package if specified
2217+ if (-Not [String ]::IsNullOrEmpty($supplemental )) {
2218+ if (Test-Path $supplemental ) {
2219+ $PackageWriter.AddSupplementalFiles ($supplemental )
2220+ if (-Not $json ) { Write-Output " Supplemental files added from $supplemental " }
2221+ }
2222+ }
2223+
21702224 if ($rph ) { $PackageWriter.SetProgressActionHandler ($action ) }
21712225 $PackageWriter.Save ($PackagePath )
21722226 $PackageWriter.Dispose ()
0 commit comments