Add function to create a framework dependent package dotnet-sdk containers (#8644)

This commit is contained in:
Aditya Patwardhan 2019-01-15 16:28:52 -08:00 committed by GitHub
parent 279993bf39
commit be4b82c730
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 134 additions and 3 deletions

View file

@ -0,0 +1,30 @@
FROM microsoft/dotnet:3.0.100-preview-sdk
ARG PACKAGENAME
ARG PACKAGELOCATION
ARG PREVIEWSUFFIX=
ARG TESTLIST=/PowerShell/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1,/PowerShell/test/powershell/engine/Module
ARG TESTDOWNLOADCOMMAND="git clone --recursive https://github.com/PowerShell/PowerShell.git"
# Install dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
ca-certificates \
apt-transport-https \
locales \
git
# Setup the locale
ENV LANG en_US.UTF-8
ENV LC_ALL $LANG
RUN locale-gen $LANG && update-locale
# Install PowerShell package
ADD $PACKAGELOCATION/$PACKAGENAME .
RUN mkdir -p /opt/microsoft/powershell
RUN tar zxf $PACKAGENAME -C /opt/microsoft/powershell
# Download and run tests
RUN $TESTDOWNLOADCOMMAND
RUN dotnet /opt/microsoft/powershell/pwsh.dll -c "Import-Module /PowerShell/build.psm1;\$dir='/usr/local/share/powershell/Modules';\$null=New-Item -Type Directory -Path \$dir -ErrorAction SilentlyContinue;Restore-PSPester -Destination \$dir;exit (Invoke-Pester $TESTLIST -PassThru).FailedCount"

View file

@ -239,7 +239,8 @@ function Get-DefaultPreviewConfigForPackageValidation
'fxdependent-opensuse42.3'='linux-x64-fxdependent.tar.gz';
'fxdependent-ubuntu14.04'='linux-x64-fxdependent.tar.gz';
'fxdependent-ubuntu16.04'='linux-x64-fxdependent.tar.gz';
'fxdependent-ubuntu18.04'='linux-x64-fxdependent.tar.gz'
'fxdependent-ubuntu18.04'='linux-x64-fxdependent.tar.gz';
'fxdependent-dotnetsdk-latest'='linux-x64-fxd-dotnetsdk.tar.gz'
}
}

View file

@ -0,0 +1,3 @@
{
"rollForwardOnNoCandidateFx": 2
}

View file

@ -0,0 +1,3 @@
{
"rollForwardOnNoCandidateFx": 2
}

View file

@ -6,7 +6,7 @@ Copyright="Copyright (c) Microsoft Corporation. All rights reserved."
ModuleVersion="1.0.0"
PowerShellVersion="5.0"
CmdletsToExport=@()
FunctionsToExport=@('Start-PSPackage','New-PSSignedBuildZip', 'New-UnifiedNugetPackage', 'New-MSIPatch', 'Expand-PSSignedBuild', 'Publish-NugetToMyGet')
FunctionsToExport=@('Start-PSPackage','New-PSSignedBuildZip', 'New-UnifiedNugetPackage', 'New-MSIPatch', 'Expand-PSSignedBuild', 'Publish-NugetToMyGet', 'New-DotnetSdkContainerFxdPackage')
RootModule="packaging.psm1"
RequiredModules = @("build")
}

View file

@ -273,7 +273,7 @@ function Start-PSPackage {
"fxdependent" {
## Remove PDBs from package to reduce size.
if(-not $IncludeSymbols.IsPresent) {
Get-ChildItem -Recurse $Source -Filter *.pdb | Remove-Item -Force
Get-ChildItem $Source -Filter *.pdb | Remove-Item -Force
}
if ($IsWindows) {
@ -2971,3 +2971,97 @@ function Get-PackageVersionAsMajorMinorBuildRevision
$packageVersion
}
<#
.SYNOPSIS
Create a smaller framework dependent package based off fxdependent package for dotnet-sdk container images.
.PARAMETER FxdPackagePath
Path to the folder containing the fxdependent package.
.PARAMETER ReleaseTag
Release tag to construct the package name.
#>
function New-DotnetSdkContainerFxdPackage {
[CmdletBinding(SupportsShouldProcess = $true)]
param(
[Parameter(Mandatory)] $FxdPackagePath,
[Parameter(Mandatory)] $ReleaseTag
)
$Version = $ReleaseTag -Replace '^v'
if ($IsWindows) {
$basePackagePattern = "*$Version-win-fxdependent.zip"
$packageNamePlatform = 'win'
$packageNameExtension = '.zip'
} else {
$basePackagePattern = "*$Version-linux-x64-fxdependent.tar.gz"
$packageNamePlatform = 'linux-x64'
$packageNameExtension = '.tar.gz'
}
$packageName = "powershell-$Version-$packageNamePlatform-fxd-dotnetsdk$packageNameExtension"
## Get fxdependent package path
$fxdPackage = Get-ChildItem $FxdPackagePath -Recurse -Filter $basePackagePattern
Write-Log "Fxd Package Path: $fxdPackage"
if ($fxdPackage) {
if ($PSCmdlet.ShouldProcess("Create the reduced framework dependent package based of $fxPackage")) {
## Extract fxd package
$tempExtractFolder = New-Item -Type Directory -Path "$FxdPackagePath/fxdreduced" -Force
Push-Location $tempExtractFolder
Write-Log "Pushed location: $tempExtractFolder"
try {
if ($IsWindows) {
Expand-Archive -Path $fxdPackage -DestinationPath $tempExtractFolder
} else {
Start-NativeExecution { tar -xf $fxdPackage }
}
## Remove unnecessary files
$localeFolderToRemove = 'cs', 'de', 'es', 'fr', 'it', 'ja', 'ko', 'pl', 'pt-BR', 'ru', 'tr', 'zh-Hans', 'zh-Hant'
Get-ChildItem -Recurse -Directory | Where-Object { $_.Name -in $localeFolderToRemove } | ForEach-Object { Remove-Item $_.FullName -Force -Recurse -Verbose }
$runtimeFolder = Get-ChildItem -Recurse -Directory -Filter 'runtimes'
# donet SDK container image microsoft/dotnet:2.2-sdk supports the following:
# win10-x64 (Nano Server)
# win-arm (Nano Server)
# linux-musl-x64 (Alpine 3.8)
# linux-x64 (bionic / stretch)
# unix, linux, win for dependencies
# win-x64 to get PowerShell.Native components
$runtimesToKeep = 'win10-x64', 'win-arm', 'win-x64', 'linux-x64', 'linux-musl-x64', 'unix', 'linux', 'win'
$runtimeFolder | ForEach-Object {
Get-ChildItem $_ -Exclude $runtimesToKeep -Directory | Remove-Item -Force -Recurse -Verbose
}
Write-Verbose -Verbose "Compressing"
if ($IsWindows) {
Compress-Archive -Path . -Destination $FxdPackagePath/$packageName
} else {
Start-NativeExecution { tar -czf "$FxdPackagePath/$packageName" . }
}
Write-Log "Compressing complete"
} finally {
Pop-Location
}
}
}
if (Test-Path "$FxdPackagePath/$packageName") {
Write-Host "##vso[artifact.upload containerfolder=release;artifactname=release]$FxdPackagePath/$packageName"
} else {
Write-Log "Package not found: $FxdPackagePath/$packageName"
}
}