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
97 changes: 86 additions & 11 deletions tools/packaging/packaging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3038,12 +3038,16 @@ Create a smaller framework dependent package based off fxdependent package for d

.PARAMETER Path
Path to the folder containing the fxdependent package.

.PARAMETER KeepWindowsRuntimes
Specify this switch if the Windows runtimes are to be kept.
#>
function ReduceFxDependentPackage
{
[CmdletBinding()]
param(
[Parameter(Mandatory)] [string] $Path
[Parameter(Mandatory)] [string] $Path,
[switch] $KeepWindowsRuntimes
)

if (-not (Test-Path $path))
Expand All @@ -3055,8 +3059,20 @@ function ReduceFxDependentPackage
$localeFolderToRemove = 'cs', 'de', 'es', 'fr', 'it', 'ja', 'ko', 'pl', 'pt-BR', 'ru', 'tr', 'zh-Hans', 'zh-Hant'
Get-ChildItem $Path -Recurse -Directory | Where-Object { $_.Name -in $localeFolderToRemove } | ForEach-Object { Remove-Item $_.FullName -Force -Recurse -Verbose }

Write-Log -message "Starting to cleanup runtime folders"

$runtimeFolder = Get-ChildItem $Path -Recurse -Directory -Filter 'runtimes'

$runtimeFolderPath = $runtimeFolder | Out-String
Write-Log -message $runtimeFolderPath

if ($runtimeFolder.Count -eq 0)
{
throw "runtimes folder not found under $Path"
}

Write-Log -message (Get-ChildItem $Path | Out-String)

# donet SDK container image microsoft/dotnet:2.2-sdk supports the following:
# win10-x64 (Nano Server)
# win-arm (Nano Server)
Expand All @@ -3066,15 +3082,18 @@ function ReduceFxDependentPackage
# unix, linux, win for dependencies
# linux-arm and linux-arm64 for arm containers
# osx to run global tool on macOS
$runtimesToKeep = if ($Environment.IsWindows) {
$runtimesToKeep = if ($KeepWindowsRuntimes) {
'win10-x64', 'win-arm', 'win-x64', 'win'
} else {
'linux-x64', 'linux-musl-x64', 'unix', 'linux', 'linux-arm', 'linux-arm64', 'osx'
}

$runtimeFolder | ForEach-Object {
Get-ChildItem $_ -Exclude $runtimesToKeep -Directory | Remove-Item -Force -Recurse -Verbose
Get-ChildItem -Path $_.FullName -Directory -Exclude $runtimesToKeep | Remove-Item -Force -Recurse -Verbose
}

## Remove the shim layer assemblies
Get-ChildItem -Path $Path -Filter "Microsoft.PowerShell.GlobalTool.Shim.*" | Remove-Item -Verbose
}

<#
Expand Down Expand Up @@ -3116,6 +3135,9 @@ function New-GlobalToolNupkg
Remove-Item -Path (Join-Path $LinuxBinPath 'libcrypto.so.1.0.0') -Verbose -Force -Recurse
Remove-Item -Path (Join-Path $LinuxBinPath 'libssl.so.1.0.0') -Verbose -Force -Recurse

## Remove unnecessary xml files
Get-ChildItem -Path $LinuxBinPath, $WindowsBinPath -Filter *.xml | Remove-Item -Verbose

if ($UnifiedPackage)
{
Write-Log "Creating a unified package"
Expand All @@ -3128,17 +3150,24 @@ function New-GlobalToolNupkg
ReduceFxDependentPackage -Path $LinuxBinPath

Write-Log "Reducing size of Windows package"
ReduceFxDependentPackage -Path $WindowsBinPath
ReduceFxDependentPackage -Path $WindowsBinPath -KeepWindowsRuntimes

Write-Log "Creating a Linux and Windows packages"
$packageInfo += @{ RootFolder = (New-TempFolder); PackageName = "PowerShell.Linux"; Type = "Linux"}
$packageInfo += @{ RootFolder = (New-TempFolder); PackageName = "PowerShell.Windows"; Type = "Windows"}
$packageInfo += @{ RootFolder = (New-TempFolder); PackageName = "PowerShell.Linux.Alpine"; Type = "PowerShell.Linux.Alpine"}
$packageInfo += @{ RootFolder = (New-TempFolder); PackageName = "PowerShell.Linux.x64"; Type = "PowerShell.Linux.x64"}
$packageInfo += @{ RootFolder = (New-TempFolder); PackageName = "PowerShell.Linux.arm32"; Type = "PowerShell.Linux.arm32"}
$packageInfo += @{ RootFolder = (New-TempFolder); PackageName = "PowerShell.Linux.arm64"; Type = "PowerShell.Linux.arm64"}

$packageInfo += @{ RootFolder = (New-TempFolder); PackageName = "PowerShell.Windows.x64"; Type = "PowerShell.Windows.x64"}
$packageInfo += @{ RootFolder = (New-TempFolder); PackageName = "PowerShell.Windows.arm32"; Type = "PowerShell.Windows.arm32"}
}

$packageInfo | ForEach-Object {
$ridFolder = New-Item -Path (Join-Path $_.RootFolder "tools/netcoreapp2.1/any") -ItemType Directory

switch ($_.Type)
$packageType = $_.Type

switch ($packageType)
{
"Unified"
{
Expand All @@ -3161,17 +3190,63 @@ function New-GlobalToolNupkg
$toolSettings = $packagingStrings.GlobalToolSettingsFile -f (Split-Path $ShimDllPath -Leaf)
}

"Linux"
"PowerShell.Linux.Alpine"
{
Write-Log "Copying runtime assemblies from $LinuxBinPath"
Write-Log "Copying runtime assemblies from $LinuxBinPath for $packageType"
Copy-Item "$LinuxBinPath/*" -Destination $ridFolder -Recurse
Remove-Item -Path $ridFolder/runtimes/linux-arm -Recurse -Force
Remove-Item -Path $ridFolder/runtimes/linux-arm64 -Recurse -Force
Remove-Item -Path $ridFolder/runtimes/linux-x64 -Recurse -Force
Remove-Item -Path $ridFolder/runtimes/osx -Recurse -Force
$toolSettings = $packagingStrings.GlobalToolSettingsFile -f "pwsh.dll"
}

"Windows"
"PowerShell.Linux.x64"
{
Write-Log "Copying runtime assemblies from $LinuxBinPath"
Write-Log "Copying runtime assemblies from $LinuxBinPath for $packageType"
Copy-Item "$LinuxBinPath/*" -Destination $ridFolder -Recurse
Remove-Item -Path $ridFolder/runtimes/linux-arm -Recurse -Force
Remove-Item -Path $ridFolder/runtimes/linux-arm64 -Recurse -Force
Remove-Item -Path $ridFolder/runtimes/linux-musl-x64 -Recurse -Force
Remove-Item -Path $ridFolder/runtimes/osx -Recurse -Force
$toolSettings = $packagingStrings.GlobalToolSettingsFile -f "pwsh.dll"
}

"PowerShell.Linux.arm32"
{
Write-Log "Copying runtime assemblies from $LinuxBinPath for $packageType"
Copy-Item "$LinuxBinPath/*" -Destination $ridFolder -Recurse
Remove-Item -Path $ridFolder/runtimes/linux-arm64 -Recurse -Force
Remove-Item -Path $ridFolder/runtimes/linux-musl-x64 -Recurse -Force
Remove-Item -Path $ridFolder/runtimes/linux-x64 -Recurse -Force
Remove-Item -Path $ridFolder/runtimes/osx -Recurse -Force
$toolSettings = $packagingStrings.GlobalToolSettingsFile -f "pwsh.dll"
}

"PowerShell.Linux.arm64"
{
Write-Log "Copying runtime assemblies from $LinuxBinPath for $packageType"
Copy-Item "$LinuxBinPath/*" -Destination $ridFolder -Recurse
Remove-Item -Path $ridFolder/runtimes/linux-arm -Recurse -Force
Remove-Item -Path $ridFolder/runtimes/linux-musl-x64 -Recurse -Force
Remove-Item -Path $ridFolder/runtimes/linux-x64 -Recurse -Force
Remove-Item -Path $ridFolder/runtimes/osx -Recurse -Force
$toolSettings = $packagingStrings.GlobalToolSettingsFile -f "pwsh.dll"
}

"PowerShell.Windows.x64"
{
Write-Log "Copying runtime assemblies from $WindowsBinPath for $packageType"
Copy-Item "$WindowsBinPath/*" -Destination $ridFolder -Recurse
Remove-Item -Path $ridFolder/runtimes/win-arm -Recurse -Force
$toolSettings = $packagingStrings.GlobalToolSettingsFile -f "pwsh.dll"
}

"PowerShell.Windows.arm32"
{
Write-Log "Copying runtime assemblies from $WindowsBinPath for $packageType"
Copy-Item "$WindowsBinPath/*" -Destination $ridFolder -Recurse
Remove-Item -Path $ridFolder/runtimes/win-x64 -Recurse -Force
$toolSettings = $packagingStrings.GlobalToolSettingsFile -f "pwsh.dll"
}
}
Expand Down
28 changes: 25 additions & 3 deletions tools/releaseBuild/azureDevOps/templates/nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,28 @@ jobs:
New-UnifiedNugetPackage -PackagePath "$(PackagePath)" -PackageVersion "$(Version)" -winx86BinPath "$(winX86Path)" -winx64BinPath "$(winX64Path)" -winArm32BinPath "$(winArm32Path)" -winArm64BinPath "$(winArm64Path)" -linuxArm32BinPath "$(linuxArm32Path)" -linuxBinPath "$(linuxX64Path)" -osxBinPath "$(macOSPath)" -GenAPIToolPath "$(GenAPIToolPath)"
displayName: 'Create Nuget Package Folders'

- powershell: |
Get-ChildItem $(linuxFxdPath)
Get-ChildItem $(winFxdPath)
displayName: Capture fxd folders

- powershell: |
Import-Module $env:BUILD_SOURCESDIRECTORY\build.psm1
Import-Module $env:BUILD_SOURCESDIRECTORY\tools\packaging

# Create unified package first
New-GlobalToolNupkg -UnifiedPackage -LinuxBinPath "$(linuxFxdPath)" -WindowsBinPath "$(winFxdPath)" -PackageVersion "$(Version)" -DestinationPath "$(PackagePath)"
New-GlobalToolNupkg -UnifiedPackage -LinuxBinPath "$(linuxFxdPath)" -WindowsBinPath "$(winFxdPath)" -PackageVersion "$(Version)" -DestinationPath "$(PackagePath)\globaltool"

# Create packages for dotnet sdk
New-GlobalToolNupkg -LinuxBinPath "$(linuxFxdPath)" -WindowsBinPath "$(winFxdPath)" -PackageVersion "$(Version)" -DestinationPath "$(PackagePath)"
New-GlobalToolNupkg -LinuxBinPath "$(linuxFxdPath)" -WindowsBinPath "$(winFxdPath)" -PackageVersion "$(Version)" -DestinationPath "$(PackagePath)\globaltool"
displayName: 'Create Global tool packages'

- powershell: |
Get-ChildItem "$(PackagePath)" -Recurse
displayName: Capture generated packages

- powershell: |
$packages = Get-ChildItem "$(PackagePath)\*.nupkg" | Select-Object -ExpandProperty FullName
$packages = Get-ChildItem "$(PackagePath)\*.nupkg", "$(PackagePath)\globaltool\*.nupkg" | Select-Object -ExpandProperty FullName

if($packages.Count -lt 1)
{
Expand Down Expand Up @@ -184,6 +189,12 @@ jobs:
parameters:
artifactPath: '$(System.ArtifactsDirectory)\signed'

- powershell: |
$null = New-Item -Path "$(System.ArtifactsDirectory)\signed\globaltool" -ItemType Directory
Move-Item -Path "$(System.ArtifactsDirectory)\signed\PowerShell.*" -Destination "$(System.ArtifactsDirectory)\signed\globaltool" -Force
Get-ChildItem "$(System.ArtifactsDirectory)\signed\globaltool" -Recurse
displayName: Move global tool packages to subfolder and capture

- task: AzureFileCopy@1
displayName: 'Upload NuGet packages to Azure'
inputs:
Expand All @@ -194,6 +205,17 @@ jobs:
ContainerName: '$(AzureVersion)-nuget'
condition: and(succeeded(), eq(variables['Build.Reason'], 'Manual'))

- task: AzureFileCopy@1
displayName: 'Upload global tool packages to Azure'
inputs:
sourcePath: '$(System.ArtifactsDirectory)\signed\globaltool'
azureSubscription: '$(GlobalToolSubscription)'
Destination: AzureBlob
storage: '$(GlobalToolStorageAccount)'
ContainerName: 'tool'
blobPrefix: '$(Version)'
condition: and(succeeded(), eq(variables['Build.Reason'], 'Manual'))

- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
displayName: 'Component Detection'
inputs:
Expand Down