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
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 2 additions & 1 deletion docker/tests/containerTestCommon.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/powershell-unix/runtimeconfig.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"rollForwardOnNoCandidateFx": 2
}
3 changes: 3 additions & 0 deletions src/powershell-win-core/runtimeconfig.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"rollForwardOnNoCandidateFx": 2
}
2 changes: 1 addition & 1 deletion tools/packaging/packaging.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
96 changes: 95 additions & 1 deletion tools/packaging/packaging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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"
}
}