Skip to content

Commit

Permalink
Refactor directory zipping to DLL copying
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ivandrofly committed Nov 22, 2024
1 parent 596ac67 commit 9c5173c
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions source/zip-plugin-files.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

0 comments on commit 9c5173c

Please sign in to comment.