Private/Test-NetcoreProjectFile.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
function Test-NetcoreProjectFile { Param( [Parameter(ValueFromPipeline)] $InputObject ) [bool]$accept = $false, [string]$path; if (Test-Path $InputObject -PathType Leaf) { $accept = $true; $path = $InputObject; if (($InputObject | Get-Member "FullName")) { $path = $InputObject.FullName; } } if ($accept -and ($path.EndsWith("proj"))) { [xml]$doc = $null; try { $doc = Get-Content $path; } catch { return $false; } return &{ try { $foundMatch = ($doc.SelectSingleNode("//Project[@Sdk]") -ne $null); if ($foundMatch) { return $doc; } else { return $false; } } catch { return $false; } }; } return $false; } |