To select every AssemblyInfo.cs from a directory minus specifically one, I run a powershell script :
Clear-Host
$SrcDir = "D:\Projects\Lambda\Sources"
Write-Host $SrcDir
cd $SrcDir
$ExcludeXYZCallStrategy = $SrcDir + "\Lambda.XYZ\XYZCallStrategy\Properties\AssemblyInfo.cs"
# 2. Select Files to be updated
Write-Host $ExcludeXYZCallStrategy
# both these syntaxes fail (tried one after the other not together ofc) :
$Assemblyfiles = Get-ChildItem -Path $SrcDir -Recurse -Include AssemblyInfo.cs -Exclude $ExcludeXYZCallStrategy
$Assemblyfiles = Get-ChildItem -Path $SrcDir -Recurse -Include AssemblyInfo.cs -Exclude D:\Projects\Lambda\Sources\Lambda.XYZ\XYZCallStrategy\Properties\AssemblyInfo.cs
Write-Host $Assemblyfiles
Write-Host "Files Count : " $Assemblyfiles.count
I tried different syntaxes to force Get-ChildItem to exclude that one file but I failed.
I tried these these answers to no avail :
From the doc, I found nothing that would explain why the file is not excluded.
Since it's only one file, you could use Where-Object
.
$Assemblyfiles = Get-ChildItem -Path $SrcDir -Recurse -Include AssemblyInfo.cs | Where-Object { $_.FullName -ne "D:\Projects\Lambda\Sources\Lambda.XYZ\XYZCallStrategy\Properties\AssemblyInfo.cs" }