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
8 changes: 6 additions & 2 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ Fix steps:
Configuration=$Configuration
Verbose=$true
SMAOnly=[bool]$SMAOnly
PSModuleRestore=$PSModuleRestore
}
$script:Options = New-PSOptions @OptionsArguments

Expand Down Expand Up @@ -602,7 +603,9 @@ function New-PSOptions {

[string]$Output,

[switch]$SMAOnly
[switch]$SMAOnly,

[switch]$PSModuleRestore
)

# Add .NET CLI tools to PATH
Expand Down Expand Up @@ -716,7 +719,8 @@ function New-PSOptions {
Framework = $Framework;
Runtime = $Runtime;
Output = $Output;
CrossGen = $CrossGen }
CrossGen = $CrossGen
PSModuleRestore = $PSModuleRestore }
}

# Get the Options of the last build
Expand Down
49 changes: 42 additions & 7 deletions tools/packaging/packaging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,19 @@ function Start-PSPackage {
# crossgen doesn't support arm32 yet
$crossGenCorrect = $true
}
elseif(-not $IncludeSymbols.IsPresent -and $Script:Options.CrossGen) {
elseif($Script:Options.CrossGen) {
$crossGenCorrect = $true
}
elseif ($IncludeSymbols.IsPresent) {
$crossGenCorrect = $true

$PSModuleRestoreCorrect = $false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comments about this.


# Require PSModuleRestore for packaging without symbols
# But Disallow it when packaging with symbols
if (!$IncludeSymbols.IsPresent -and $Script:Options.PSModuleRestore) {
$PSModuleRestoreCorrect = $true
}
elseif ($IncludeSymbols.IsPresent -and !$Script:Options.PSModuleRestore) {
$PSModuleRestoreCorrect = $true
}

# Make sure the most recent build satisfies the package requirement
Expand All @@ -108,10 +116,11 @@ function Start-PSPackage {
# also ensure `Start-PSPackage` does what the user asks/expects, because once packages
# are generated, it'll be hard to verify if they were built from the correct content.
$params = @('-Clean')
if(-not $IncludeSymbols.IsPresent)
{
$params += '-CrossGen'
$params += '-CrossGen'
if (!$IncludeSymbols.IsPresent) {
$params += '-PSModuleRestore'
}

$params += '-Runtime', $Runtime
$params += '-Configuration', $Configuration

Expand Down Expand Up @@ -140,9 +149,35 @@ function Start-PSPackage {
# If building a symbols package, don't include the publish build.
if ($IncludeSymbols.IsPresent)
{
$publishSource = $Source
$buildSource = Split-Path -Path $Source -Parent
$Source = New-TempFolder
Get-ChildItem -Path $buildSource | Where-Object {$_.Name -ine 'Publish'} | Copy-Item -Destination $Source -Recurse

# 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)
{
Copy-Item -Path $publishPath -Destination $_.FullName -Force
}
}

$zipSource = Join-Path $publishSource -ChildPath '*'
$zipPath = Join-Path -Path $Source -ChildPath 'publish.zip'
Compress-Archive -Path $zipSource -DestinationPath $zipPath
}

log "Packaging Source: '$Source'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ try{

Write-Verbose "Starting powershell build for RID: $Runtime and ReleaseTag: $ReleaseTag ..." -verbose
$buildParams = @{}
$buildParams['CrossGen'] = $true
if(!$Symbols.IsPresent)
{
$buildParams['CrossGen'] = $true
$buildParams['PSModuleRestore'] = $true
}

Start-PSBuild -Clean -PSModuleRestore -Runtime $Runtime -Configuration Release @releaseTagParam @buildParams
Start-PSBuild -Clean -Runtime $Runtime -Configuration Release @releaseTagParam @buildParams

$pspackageParams = @{'Type'='msi'}
if ($Runtime -ne 'win10-x64')
Expand Down