From cd61b7a0b6fb4ff54aa78803b64dfe81cddcbb80 Mon Sep 17 00:00:00 2001 From: Bruce Markham <219281+brucificus@users.noreply.github.com> Date: Mon, 25 Sep 2023 18:37:45 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20Updates=20Build=20Scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/funcs/Expand-PackageExportOutput.ps1 | 11 ++++++++++- build/publish.ps1 | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/build/funcs/Expand-PackageExportOutput.ps1 b/build/funcs/Expand-PackageExportOutput.ps1 index d67f7dd..87dcf24 100644 --- a/build/funcs/Expand-PackageExportOutput.ps1 +++ b/build/funcs/Expand-PackageExportOutput.ps1 @@ -7,6 +7,7 @@ function Expand-PackageExportOutput { param( ) + $InformationPreference = "Continue" [string] $ds = [System.IO.Path]::DirectorySeparatorChar [string] $out = "${PSScriptRoot}${ds}..${ds}..${ds}out" @@ -56,6 +57,13 @@ function Expand-PackageExportOutput { throw "No psd1 file was found in '$moduleLocation' that matches '$psgalleryNupkgName'." } + Write-Information "Cleaning up NuPkg artifacts." + [string[]] $cleanupFilePatternsToDelete = @("[Content_Types].xml", "*.nuspec", "_rels", "package") + foreach ($cleanupFilePatternToDelete in $cleanupFilePatternsToDelete) { + @(Get-ChildItem -Path $moduleLocation -Filter $cleanupFilePatternToDelete -Force) ` + | ForEach-Object { Write-Information ("Removing: " + $_.FullName); Remove-Item -LiteralPath $_.FullName -Force -Recurse -ErrorAction Continue } + } + # Move the expanded NuPkg to the psd1's name, which is a requirement before it can be imported. Write-Information "Renaming folder '$moduleLocation' to match the module name." [string] $newModuleLocation = $null @@ -64,6 +72,7 @@ function Expand-PackageExportOutput { Remove-Item -Path $newModuleLocation -Recurse -Force | Out-Null } $moduleLocation = (Rename-Item -Path $moduleLocation -NewName $psd1.BaseName -Force -PassThru).FullName - $psd1 = Get-ChildItem -Path (Join-Path -Path $moduleLocation -ChildPath $psd1.Name) -File -Force | Select-Object -First 1 + $psd1 = Get-Item -Path (Join-Path -Path $moduleLocation -ChildPath $psd1.Name) | Select-Object -First 1 + return $psd1 } diff --git a/build/publish.ps1 b/build/publish.ps1 index f7d2937..d9ddd9c 100644 --- a/build/publish.ps1 +++ b/build/publish.ps1 @@ -13,6 +13,7 @@ param( [switch] $WhatIf ) $ErrorActionPreference = "Stop" +$InformationPreference = "Continue" Set-StrictMode -Version Latest @@ -20,9 +21,10 @@ Set-StrictMode -Version Latest . "${PSScriptRoot}${ds}funcs${ds}Expand-PackageExportOutput.ps1" [System.IO.FileInfo] $psd1 = Expand-PackageExportOutput [hashtable] $psd1Data = Import-PowerShellDataFile -Path $psd1.FullName +[string] $expandedModulePath = $psd1.Directory.FullName Publish-Module ` - -Path (Split-Path $psd1 -Parent) ` + -Path $expandedModulePath ` -NuGetApiKey $NUGET_KEY ` -ReleaseNotes $psd1Data.PrivateData.PSData.ReleaseNotes ` -Tags $psd1Data.PrivateData.PSData.Tags `