From 9c5173cc29b97aa722cea4138947702c3d621985 Mon Sep 17 00:00:00 2001 From: Ivandro Jao Date: Fri, 22 Nov 2024 11:09:33 +0000 Subject: [PATCH] Refactor directory zipping to DLL copying Converted action from zipping all files in directories (excluding .pdb) to copying the first .dll file from each directory to the output directory. Adjusted structure to enhance readability and maintain consistency. --- source/zip-plugin-files.ps1 | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/source/zip-plugin-files.ps1 b/source/zip-plugin-files.ps1 index 7a11c80..43fa431 100644 --- a/source/zip-plugin-files.ps1 +++ b/source/zip-plugin-files.ps1 @@ -11,32 +11,22 @@ $directories = @( $outputDirectory = "C:\plugins\" # Create the output directory if it doesn't exist -if (-not (Test-Path -Path $outputDirectory)) { +if (-not (Test-Path -Path $outputDirectory)) +{ New-Item -ItemType Directory -Path $outputDirectory } # Loop through each directory in the list -foreach ($directory in $directories) { - if (Test-Path -Path $directory) { +foreach ($directory in $directories) +{ + if (Test-Path -Path $directory) + { # Find the first .dll file in the directory $dllFile = Get-ChildItem -Path $directory -Filter *.dll | Select-Object -First 1 - - if ($dllFile) { - # Get the name of the dll file (without extension) to use as the zip file name - $zipFileName = [System.IO.Path]::GetFileNameWithoutExtension($dllFile.Name) - - # Define the zip file path - $zipFilePath = Join-Path -Path $outputDirectory -ChildPath "$zipFileName.zip" - - # Zip all files in the directory except .pdb files - $itemsToZip = Get-ChildItem -Path $directory -Exclude *.pdb - Compress-Archive -Path $itemsToZip.FullName -DestinationPath $zipFilePath - - Write-Output "Zipped '$directory' to '$zipFilePath'" - } else { - Write-Output "No .dll file found in directory '$directory'" - } - } else { + Copy-Item -Path $dllFile.FullName -Destination $outputDirectory + } + else + { Write-Output "Directory '$directory' does not exist" } } \ No newline at end of file