Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 35 additions & 23 deletions tools/packaging/packaging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
38 changes: 38 additions & 0 deletions tools/releaseBuild/createComplianceFolder.ps1
Original file line number Diff line number Diff line change
@@ -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"