I am trying to use Cake as a build tool but am running into an issue in their powershell script.
The script is trying to find nuget.exe in the environment variable path. If it doesn't exist it downloads it.
The issue is that msbuild.exe is always returned and if nuget.exe does not exist the script fails as it tries to us msbuild.exe
$existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_) }
$NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1
No matter which exeI try to search for using this script even if it exists, msbuild.exe is always returned in the list.
I would use a different and probably more effective check for nuget.exe availability
As Enrico Campidoglio suggested, you may add
-CommandType Application. In theory, it should be even more efficient. In (my) practice, this is not always the case.