Skip to content

Commit 98599da

Browse files
Add function to build psrp.windows nuget package
1 parent 64eb8c8 commit 98599da

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

build.psm1

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,83 @@ function Start-BuildNativeUnixBinaries {
398398
}
399399
}
400400

401+
function Start-BuildWindowsNativePackage
402+
{
403+
[CmdletBinding()]
404+
param(
405+
[Parameter(Mandatory = $true)]
406+
[ValidateNotNullOrEmpty()]
407+
[string] $PackageRoot,
408+
409+
[Parameter(Mandatory = $true)]
410+
[ValidateNotNullOrEmpty()]
411+
[string] $PluginVersion
412+
)
413+
414+
if(-not (Test-Path $PackageRoot))
415+
{
416+
Write-Verbose "Creating PackageRoot: $PackageRoot as it does not exist."
417+
}
418+
419+
$plugingPackageRoot = Join-Path $PackageRoot -ChildPath 'psrp.windows'
420+
421+
$pluginX64Path = New-Item -ItemType Directory -Path (Join-Path $plugingPackageRoot -ChildPath 'runtimes' -AdditionalChildPath 'win-x64','native')
422+
$pluginX86Path = New-Item -ItemType Directory -Path (Join-Path $plugingPackageRoot -ChildPath 'runtimes' -AdditionalChildPath 'win-x86','native')
423+
$pluginArmPath = New-Item -ItemType Directory -Path (Join-Path $plugingPackageRoot -ChildPath 'runtimes' -AdditionalChildPath 'win-arm','native')
424+
$pluginArm64Path = New-Item -ItemType Directory -Path (Join-Path $plugingPackageRoot -ChildPath 'runtimes' -AdditionalChildPath 'win-arm64','native')
425+
426+
BuildPwrshPlugingNugetLayout -Destination $pluginX64Path -Arch 'x64'
427+
BuildPwrshPlugingNugetLayout -Destination $pluginX86Path -Arch 'x86'
428+
BuildPwrshPlugingNugetLayout -Destination $pluginArmPath -Arch 'x64_arm'
429+
BuildPwrshPlugingNugetLayout -Destination $pluginArm64Path -Arch 'x64_arm64'
430+
431+
$plugingNuspec = @'
432+
<?xml version="1.0" encoding="utf-8"?>
433+
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
434+
<metadata>
435+
<id>psrp.windows</id>
436+
<version>{0}</version>
437+
<authors>Microsoftss</authors>
438+
<owners>Microsoft,PowerShell</owners>
439+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
440+
<description>PowerShell WS-Man PSRP Client for Windows</description>
441+
<copyright>Copyright 2017 Microsoft</copyright>
442+
<contentFiles>
443+
<files include="**/*" buildAction="None" copyToOutput="true" flatten="false" />
444+
</contentFiles>
445+
</metadata>
446+
</package>
447+
'@
448+
449+
$plugingNuspec -f $PluginVersion | Out-File -FilePath (Join-Path $plugingPackageRoot -ChildPath 'psrp.windows.nuspec') -Force
450+
451+
try {
452+
Push-Location $plugingPackageRoot
453+
nuget.exe pack .
454+
}
455+
finally {
456+
Pop-Location
457+
}
458+
}
459+
460+
function BuildPwrshPlugingNugetLayout
461+
{
462+
param(
463+
[string] $Destination,
464+
[string] $Arch
465+
)
466+
467+
try {
468+
Start-BuildNativeWindowsBinaries -Configuration 'Release' -Arch $Arch -Clean -ErrorAction Stop
469+
}
470+
catch {
471+
throw "Build failed: $_.Message"
472+
}
473+
474+
Copy-Item -Path $PSScriptRoot/src/powershell-win-core/pwrshplugin.dll -Destination $Destination
475+
Copy-Item -Path $PSScriptRoot/src/powershell-win-core/pwrshplugin.pdb -Destination $Destination
476+
}
477+
401478
function Start-PSBuild {
402479
[CmdletBinding()]
403480
param(

0 commit comments

Comments
 (0)