diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index 3aaee4e6ebb..7026fb393ef 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -146,38 +146,50 @@ function Start-PSPackage { $Source = Split-Path -Path $Script:Options.Output -Parent - # If building a symbols package, don't include the publish build. + # If building a symbols package, we add a zip of the parent to publish if ($IncludeSymbols.IsPresent) { $publishSource = $Source $buildSource = Split-Path -Path $Source -Parent $Source = New-TempFolder + $symbolsSource = New-TempFolder - # files not to include as individual files. These files will be included in publish.zip - $toExclude = @( - 'hostfxr.dll' - 'hostpolicy.dll' - 'libhostfxr.so' - 'libhostpolicy.so' - 'libhostfxr.dylib' - 'libhostpolicy.dylib' - 'Publish' - ) - Get-ChildItem -Path $buildSource | Where-Object {$toExclude -inotcontains $_.Name} | Copy-Item -Destination $Source -Recurse - - # Replace binaries with crossgen'ed binaires from publish folder. - Get-ChildItem -Recurse $Source | ForEach-Object { - $relativePath = $_.FullName.Replace($Source, '') - $publishPath = Join-Path $publishSource -ChildPath $relativePath - if (Test-Path -Path $publishPath) + try + { + # Copy files which go into the root package + Get-ChildItem -Path $publishSource | Copy-Item -Destination $Source -Recurse + + # files not to include as individual files. These files will be included in the root package + # pwsh.exe is just dotnet.exe renamed by dotnet.exe during the build. + $toExclude = @( + 'hostfxr.dll' + 'hostpolicy.dll' + 'libhostfxr.so' + 'libhostpolicy.so' + 'libhostfxr.dylib' + 'libhostpolicy.dylib' + 'Publish' + 'pwsh.exe' + ) + # Copy file which go into symbols.zip + Get-ChildItem -Path $buildSource | Where-Object {$toExclude -inotcontains $_.Name} | Copy-Item -Destination $symbolsSource -Recurse + + # Exclude Pester until we move it to PSModuleRestore + $pesterPath = Join-Path -Path $symbolsSource -ChildPath 'Modules\Pester' + if(Test-Path -Path $pesterPath) { - Copy-Item -Path $publishPath -Destination $_.FullName -Force + Remove-Item -Path $pesterPath -Recurse -Force -ErrorAction SilentlyContinue } - } - $zipSource = Join-Path $publishSource -ChildPath '*' - $zipPath = Join-Path -Path $Source -ChildPath 'publish.zip' - Compress-Archive -Path $zipSource -DestinationPath $zipPath + # Zip symbols.zip to the root package + $zipSource = Join-Path $symbolsSource -ChildPath '*' + $zipPath = Join-Path -Path $Source -ChildPath 'symbols.zip' + Compress-Archive -Path $zipSource -DestinationPath $zipPath + } + finally + { + Remove-Item -Path $symbolsSource -Recurse -Force -ErrorAction SilentlyContinue + } } log "Packaging Source: '$Source'" diff --git a/tools/releaseBuild/createComplianceFolder.ps1 b/tools/releaseBuild/createComplianceFolder.ps1 new file mode 100644 index 00000000000..31b972b9bc5 --- /dev/null +++ b/tools/releaseBuild/createComplianceFolder.ps1 @@ -0,0 +1,38 @@ +param( + [Parameter(HelpMessage="Artifact folder to find compliance files in.")] + [string[]] + $ArtifactFolder, + [Parameter(HelpMessage="VSTS Variable to set path to complinance Files.")] + [string] + $VSTSVariableName +) + +$compliancePath = $null +foreach($folder in $ArtifactFolder) +{ + # Find Symbols zip which contains compliance files + Write-Host "ArtifactFolder: $folder" + $filename = Join-Path -Path $folder -ChildPath 'symbols.zip' + $name = Split-Path -Path $folder -Leaf + + # Throw is compliance zip does not exist + if (!(Test-Path $filename)) + { + throw "symbols.zip for $VSTSVariableName does not exist" + } + + # make sure we have a single parent for everything + if (!$compliancePath) + { + $parent = Split-Path -Path $folder + $compliancePath = Join-Path -Path $parent -ChildPath 'compliance' + } + + # Extract complance files to individual folder to avoid overwriting files. + $unzipPath = Join-Path -Path $compliancePath -ChildPath $name + Write-Host "Symbols-zip: $filename ; unzipPath: $unzipPath" + Expand-Archive -Path $fileName -DestinationPath $unzipPath +} + +# set VSTS variable with path to compliance files +Write-Host "##vso[task.setvariable variable=$VSTSVariableName]$unzipPath" \ No newline at end of file