File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,6 +126,46 @@ jobs:
126126
127127 Add-Content $env:GITHUB_OUTPUT "antlr4JarPath=$antlrJar"
128128
129+ - name : Patch Antlr4ToolPath condition in Lucene.Net.Expressions.csproj
130+ shell : pwsh
131+ run : |
132+ $projFile = "src/Lucene.Net.Expressions/Lucene.Net.Expressions.csproj"
133+ if (-not (Test-Path $projFile)) {
134+ Write-Warning "Project file not found: $projFile"
135+ exit 0
136+ }
137+
138+ [xml]$xml = Get-Content $projFile
139+ $nodes = $xml.SelectNodes("//Antlr4ToolPath")
140+ if ($nodes.Count -eq 0) {
141+ Write-Host "No Antlr4ToolPath element found. No change needed."
142+ exit 0
143+ }
144+
145+ $modified = $false
146+ foreach ($node in $nodes) {
147+ if (-not $node.Attributes["Condition"]) {
148+ $attr = $xml.CreateAttribute("Condition")
149+ $attr.Value = " '$(Antlr4ToolPath)' == '' "
150+ $node.Attributes.Append($attr) | Out-Null
151+ $modified = $true
152+ Write-Host "Added missing Condition attribute to Antlr4ToolPath."
153+ }
154+ }
155+
156+ if ($modified) {
157+ $utf8NoBom = New-Object System.Text.UTF8Encoding $false
158+ $writer = [System.IO.StreamWriter]::new($projFile, $false, $utf8NoBom)
159+ try {
160+ $xml.Save($writer)
161+ } finally {
162+ $writer.Close()
163+ }
164+ Write-Host "Patched $projFile successfully."
165+ } else {
166+ Write-Host "Condition already present. No changes made."
167+ }
168+
129169 - name : Restore
130170 run : dotnet restore
131171
You can’t perform that action at this time.
0 commit comments