Skip to content

Commit b221042

Browse files
committed
updated the powershell script
1 parent e2c77f5 commit b221042

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

CreateTemplate.ps1

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,22 @@ $excludedItems = @(
4848
"appsettings.Development.json", "CreateTemplate.ps1", "nupkg"
4949
)
5050

51+
# Get absolute path of the output directory to avoid copying it
52+
$absoluteOutputPath = (Resolve-Path -Path $OutputDirectory).Path
53+
5154
# Get all directories in the source directory except excluded ones
5255
Get-ChildItem -Path $SourceDirectory -Directory |
53-
Where-Object { $excludedItems -notcontains $_.Name } |
56+
Where-Object {
57+
$excludedItems -notcontains $_.Name -and
58+
# Skip if the current directory is the output directory
59+
$_.FullName -ne $absoluteOutputPath -and
60+
# Skip if the current directory is inside the output directory
61+
-not $_.FullName.StartsWith("$absoluteOutputPath\") -and
62+
# Skip if the output directory is inside the current directory
63+
-not $absoluteOutputPath.StartsWith("$($_.FullName)\")
64+
} |
5465
ForEach-Object {
66+
Write-Host "Copying directory: $($_.Name)"
5567
Copy-Item -Path $_.FullName -Destination $OutputDirectory -Recurse -Force
5668
}
5769

@@ -63,6 +75,7 @@ Get-ChildItem -Path $SourceDirectory -File |
6375
$_.Extension -ne ".nupkg"
6476
} |
6577
ForEach-Object {
78+
Write-Host "Copying file: $($_.Name)"
6679
Copy-Item -Path $_.FullName -Destination $OutputDirectory -Force
6780
}
6881

0 commit comments

Comments
 (0)