diff --git a/build/consolidate-artifacts.ps1 b/build/consolidate-artifacts.ps1 index e7de7fab88..1715a93c3a 100644 --- a/build/consolidate-artifacts.ps1 +++ b/build/consolidate-artifacts.ps1 @@ -1,16 +1,42 @@ # Ensure artifacts directory is clean -Get-ChildItem .\ -Include artifacts -Recurse | ForEach-Object ($_) { Remove-Item $_.Fullname -Force -Recurse } +Get-ChildItem .\ -Include .\artifacts\binaries -Recurse | ForEach-Object ($_) { Remove-Item $_.Fullname -Force -Recurse } +Get-ChildItem .\ -Include .\artifacts\nuget -Recurse | ForEach-Object ($_) { Remove-Item $_.Fullname -Force -Recurse } New-Item -Path artifacts\binaries -ItemType Directory -Force New-Item -Path artifacts\nuget -ItemType Directory -Force $platforms = @('Forms', 'Wpf', 'Uno', 'Maui') -$platformNuGet = $platforms | ForEach-Object { Join-Path -Path .\artifacts -ChildPath "$_\NuGet" } -$platformBinary = $platforms | ForEach-Object { Join-Path -Path .\artifacts -ChildPath "$_\Release" } -Get-ChildItem $platformNuGet -Filter '*.nupkg' | Where-Object { $_.Name.StartsWith('Prism.Core') -eq $false -and $_.Name.StartsWith('Prism.Events') -eq $false } | ForEach-Object { if(!(Test-Path -Path $_.FullName)) { Copy-Item $_.FullName .\artifacts\nuget }else { Write-Warning "File already exists: $($_.FullName)" } } -Get-ChildItem $platformNuGet -Filter '*.snupkg' | Where-Object { $_.Name.StartsWith('Prism.Core') -eq $false -and $_.Name.StartsWith('Prism.Events') -eq $false } | ForEach-Object { if(!(Test-Path -Path $_.FullName)) { Copy-Item $_.FullName .\artifacts\nuget }else { Write-Warning "File already exists: $($_.FullName)" } } -Get-ChildItem $platformBinary | Where-Object { $_.Name -ne 'Core' } | ForEach-Object { if(!(Test-Path -Path $_.FullName)) { Copy-Item $_.FullName .\artifacts\binaries }else { Write-Warning "File already exists: $($_.FullName)" } } -Get-ChildItem .\artifacts\Core\NuGet -Filter '*.nupkg' | ForEach-Object { if(!(Test-Path -Path $_.FullName)) { Copy-Item $_.FullName .\artifacts\nuget }else { Write-Warning "File already exists: $($_.FullName)" } } -Get-ChildItem .\artifacts\Core\NuGet -Filter '*.snupkg' | ForEach-Object { if(!(Test-Path -Path $_.FullName)) { Copy-Item $_.FullName .\artifacts\nuget }else { Write-Warning "File already exists: $($_.FullName)" } } -Get-ChildItem .\artifacts\Core\Release | ForEach-Object { if(!(Test-Path -Path $_.FullName)) { Copy-Item $_.FullName .\artifacts\binaries }else { Write-Warning "File already exists: $($_.FullName)" } } + +$core = @("Prism.Core", "Prism.Events", "Prism.dll", "Prism.pdb", "Prism.xml") +$files = Get-ChildItem -Path .\artifacts -Filter "*" -Recurse | Where-Object { (Test-Path -Path $_.FullName -PathType Leaf) -and $_.FullName -notmatch "artifacts\\binaries|artifacts\\nuget" } + +foreach($file in $files) +{ + if ($file -match ($platforms -join '|') -and $file -match ($core -join '|')) + { + continue + } + elseif ($file -like "*.nupkg" -or $file -like "*.snupkg") + { + Write-Information "Copying $file to .\artifacts\nuget" + Copy-Item $file.FullName .\artifacts\nuget + } + else + { + $parent = Split-Path -Path $file -Parent + $parentDirName = Split-Path -Path $parent -Leaf + + if($parentDirName -like ($platforms -join '|') -or $parentDirName -like 'Core') + { + continue + } + + $copyPath = Join-Path .\artifacts\binaries -ChildPath $parentDirName + + Write-Information "Creating $copyPath" + New-Item -Path $copyPath -ItemType Directory -Force + Write-Information "Copying $file to $copyPath" + Copy-Item $file.FullName $copyPath + } +} Remove-Item artifacts\Core -Recurse Remove-Item artifacts\Wpf -Recurse