I have the script:
$Test = (dotnet list C:\Tasks.Api.csproj package) and it provides some packages (WITH 2 SPACES ON THE END!):
Project 'Tasks.Api' has the following package references
[net5.0]:
Top-level Package Requested Resolved
> AspNetCore.HealthChecks.SqlServer 6.0.0 6.0.0
> Microsoft.ApplicationInsights.AspNetCore 2.18.0 2.18.0
> Microsoft.EntityFrameworkCore.Tools 5.0.11 5.0.11
> Swashbuckle.AspNetCore 6.2.3 6.2.3
(SPACE)
(SPACE)
gettype provide next:
Then I have a "good" file (txt):
AspNetCore.HealthChecks.SqlServer
Microsoft.ApplicationInsights.AspNetCore
Now I want to know, does my "good" file contains lines from $Test or not?
I think I tried millions of other options, but now I'm stuck on it:
$whiteliste = Get-Content C:\whitelist.txt
$test = (dotnet list C:\Tasks.Api.csproj package)
$array = @()
$test[3..($test.Length-2)] | foreach {
$array+=$_
}
Foreach ($item in $array) {
Write-host "!!!" $item
$containsWord = $whiteliste | %{$_ -contains $item.Remove(" ")}
if ($containsWord -contains $true) {
Write-Host "There is!"
} else {
Write-Host "There ins't!"
}
}
Thanks!
