18 lines
902 B
PowerShell
18 lines
902 B
PowerShell
$xunitPackages = @'
|
|
<PackageReference Include="xunit" Version="2.9.3" />
|
|
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2" PrivateAssets="all" />
|
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
|
'@
|
|
|
|
Get-ChildItem -Path "src" -Filter "*.csproj" -Recurse | Where-Object { $_.Name -like "*.Tests.csproj" } | ForEach-Object {
|
|
$content = Get-Content $_.FullName -Raw
|
|
if ($content -match '<IsTestProject>true</IsTestProject>' -and $content -notmatch 'Include="xunit"') {
|
|
# Find the first ItemGroup with PackageReference and add xunit there
|
|
if ($content -match '(<ItemGroup>\s*<PackageReference)') {
|
|
$content = $content -replace '(<ItemGroup>\s*<PackageReference)', "$xunitPackages`n`$1"
|
|
Set-Content $_.FullName $content -NoNewline
|
|
Write-Host "Added xunit to: $($_.FullName)"
|
|
}
|
|
}
|
|
}
|