You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by "paulirwin.apache.org via commits" <co...@lucenenet.apache.org> on 2026/10/31 19:18:12 UTC

(lucenenet) branch master updated: Allow Generate-TestWorkflows.ps1 to run on macOS/Linux, #1473 (#1515)

This is an automated email from the ASF dual-hosted git repository.

paulirwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git


The following commit(s) were added to refs/heads/master by this push:
     new bd394723d Allow Generate-TestWorkflows.ps1 to run on macOS/Linux, #1473 (#1515)
bd394723d is described below

commit bd394723d81f9d6b9bbae40fcd119f282319c444
Author: Paul Irwin <pa...@gmail.com>
AuthorDate: Sat Oct 31 13:18:06 2026 -0600

    Allow Generate-TestWorkflows.ps1 to run on macOS/Linux, #1473 (#1515)
---
 .github/workflows/Generate-TestWorkflows.ps1            | 17 ++++++++++++-----
 Directory.Build.props                                   |  5 +++++
 TestTargetFramework.props                               |  2 +-
 .../Lucene.Net.Analysis.OpenNLP.csproj                  |  2 +-
 .../Lucene.Net.Tests.Analysis.OpenNLP.csproj            |  2 +-
 5 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/.github/workflows/Generate-TestWorkflows.ps1 b/.github/workflows/Generate-TestWorkflows.ps1
index 1a5fc754c..b43c5b9a8 100644
--- a/.github/workflows/Generate-TestWorkflows.ps1
+++ b/.github/workflows/Generate-TestWorkflows.ps1
@@ -124,6 +124,8 @@ function Get-ProjectDependencies([string]$ProjectPath, [string]$RelativeRoot, [S
     $rootPath = [System.IO.Path]::GetDirectoryName($resolvedProjectPath)
     [xml]$project = Get-Content $resolvedProjectPath
     foreach ($name in $project.SelectNodes("//Project/ItemGroup/ProjectReference") | Where-Object { $_.Include -notmatch '^$' } | ForEach-Object { $_.Include -split ';'}) {
+        # Project files use Windows separators, which are not recognized on macOS/Linux. Forward slashes work everywhere.
+        $name = $name -replace '\\', '/'
         $dependencyFullPath = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($rootPath, $name))
         Get-ProjectDependencies $dependencyFullPath $RelativeRoot $Result
         $dependency = Resolve-RelativePath $RelativeRoot $dependencyFullPath
@@ -136,17 +138,21 @@ function Get-ProjectExternalPaths([string]$ProjectPath, [string]$RelativeRoot, [
     $rootPath = [System.IO.Path]::GetDirectoryName($resolvedProjectPath)
     [xml]$project = Get-Content $resolvedProjectPath
     foreach ($name in $project.SelectNodes("//Project/ItemGroup/Compile") | Where-Object { $_.Include -notmatch '^$' } | ForEach-Object { $_.Include -split ';'}) {
+        # Project files use Windows separators, which are not recognized on macOS/Linux. Forward slashes work everywhere.
+        $name = $name -replace '\\', '/'
         # Temporarily override wildcard patterns so we can resolve the path and then put them back.
-        $name = $name -replace '\\\*\*\\\*', 'Wildcard1' -replace '\*', 'Wildcard2'
-        $dependencyFullPath = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($rootPath, $name)) -replace 'Wildcard1', '\**\*' -replace 'Wildcard2', '*'
+        $name = $name -replace '/\*\*/\*', 'Wildcard1' -replace '\*', 'Wildcard2'
+        $dependencyFullPath = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($rootPath, $name)) -replace 'Wildcard1', '/**/*' -replace 'Wildcard2', '*'
         # Make the path relative to the repo root.
         $dependency = $($($dependencyFullPath.Replace($RelativeRoot, '.')) -replace '\\', '/').TrimStart('./')
         $result.Add($dependency) | Out-Null
     }
     foreach ($name in $project.SelectNodes("//Project/ItemGroup/EmbeddedResource") | Where-Object { $_.Include -notmatch '^$' } | ForEach-Object { $_.Include -split ';'}) {
+        # Project files use Windows separators, which are not recognized on macOS/Linux. Forward slashes work everywhere.
+        $name = $name -replace '\\', '/'
         # Temporarily override wildcard patterns so we can resolve the path and then put them back.
-        $name = $name -replace '\\\*\*\\\*', 'Wildcard1' -replace '\*', 'Wildcard2'
-        $dependencyFullPath = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($rootPath, $name)) -replace 'Wildcard1', '\**\*' -replace 'Wildcard2', '*'
+        $name = $name -replace '/\*\*/\*', 'Wildcard1' -replace '\*', 'Wildcard2'
+        $dependencyFullPath = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($rootPath, $name)) -replace 'Wildcard1', '/**/*' -replace 'Wildcard2', '*'
         # Make the path relative to the repo root.
         $dependency = $($($dependencyFullPath.Replace($RelativeRoot, '.')) -replace '\\', '/').TrimStart('./')
         $result.Add($dependency) | Out-Null
@@ -174,7 +180,8 @@ function Get-ProjectPathDirectories([string]$ProjectPath, [string]$RelativeRoot,
 
 function Get-SupportedTargetFrameworksString([Parameter(Mandatory)][string] $ProjectPath) {
     # NOTE: This will not appear when run directly in the console with minimal verbosity. MSBuild only produces the output when using a pipe, which is what we are doing here.
-    $output = dotnet build "$ProjectPath" --verbosity minimal --nologo --no-restore /t:PrintTargetFrameworks /p:TestProjectsOnly=true /p:TestFrameworks=true 2>&1 | Out-String
+    # IncludeNetFrameworkTargets=true reports the .NET Framework targets even when not running on Windows, so the result is the same on every platform.
+    $output = dotnet build "$ProjectPath" --verbosity minimal --nologo --no-restore /t:PrintTargetFrameworks /p:TestProjectsOnly=true /p:TestFrameworks=true /p:IncludeNetFrameworkTargets=true 2>&1 | Out-String
     if ($output -match 'SupportedTargetFrameworks=([^\s]+)') {
         return $matches[1]
     }
diff --git a/Directory.Build.props b/Directory.Build.props
index 346ea1ba8..c6c7a3894 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -49,6 +49,11 @@
 
     <NetCoreOnlyTargetFrameworks>net10.0;net8.0</NetCoreOnlyTargetFrameworks>
     <NetCoreOnlyTargetFrameworks Condition=" '$(IsLegacyVisualStudioVersion)' == 'true' ">net8.0</NetCoreOnlyTargetFrameworks>
+
+    <!-- Projects that only add .NET Framework targets on Windows key off of this property rather than checking the OS directly.
+      Pass IncludeNetFrameworkTargets=true to evaluate those targets on macOS/Linux, which Generate-TestWorkflows.ps1 does
+      so the generated workflows are the same on every platform. -->
+    <IncludeNetFrameworkTargets Condition=" '$(IncludeNetFrameworkTargets)' == '' And $([MSBuild]::IsOsPlatform('Windows')) ">true</IncludeNetFrameworkTargets>
   </PropertyGroup>
 
   <!-- IMPORTANT: When these values are changed, the CI counter number should also be reset. -->
diff --git a/TestTargetFramework.props b/TestTargetFramework.props
index 4a5b57dee..dae583dcd 100644
--- a/TestTargetFramework.props
+++ b/TestTargetFramework.props
@@ -51,7 +51,7 @@
 
     <!-- CI builds - always build all test frameworks (CI installs required SDKs) -->
     <TargetFrameworks Condition=" '$(TestFrameworks)' == 'true' ">net10.0;net9.0;net8.0</TargetFrameworks>
-    <TargetFrameworks Condition=" '$(TestFrameworks)' == 'true' And $([MSBuild]::IsOsPlatform('Windows'))  And '$(IsLegacyVisualStudioVersion)' != 'true' ">$(TargetFrameworks);net48;net472</TargetFrameworks>
+    <TargetFrameworks Condition=" '$(TestFrameworks)' == 'true' And '$(IncludeNetFrameworkTargets)' == 'true' And '$(IsLegacyVisualStudioVersion)' != 'true' ">$(TargetFrameworks);net48;net472</TargetFrameworks>
     <TargetFramework Condition=" '$(TargetFrameworks)' != '' "></TargetFramework>
   </PropertyGroup>
 
diff --git a/src/Lucene.Net.Analysis.OpenNLP/Lucene.Net.Analysis.OpenNLP.csproj b/src/Lucene.Net.Analysis.OpenNLP/Lucene.Net.Analysis.OpenNLP.csproj
index cbce7cae1..c3e189875 100644
--- a/src/Lucene.Net.Analysis.OpenNLP/Lucene.Net.Analysis.OpenNLP.csproj
+++ b/src/Lucene.Net.Analysis.OpenNLP/Lucene.Net.Analysis.OpenNLP.csproj
@@ -36,7 +36,7 @@
     <!-- .NET Framework is conditional on VS version (VS2024+ = 18.0) due to invalid build warnings with C# 14.0 build features -->
     <TargetFrameworks>net10.0;net8.0</TargetFrameworks>
     <TargetFrameworks Condition=" '$(IsLegacyVisualStudioVersion)' == 'true' ">net8.0</TargetFrameworks>
-    <TargetFrameworks Condition=" $([MSBuild]::IsOsPlatform('Windows')) And '$(IsLegacyVisualStudioVersion)' != 'true' ">$(TargetFrameworks);net472</TargetFrameworks>
+    <TargetFrameworks Condition=" '$(IncludeNetFrameworkTargets)' == 'true' And '$(IsLegacyVisualStudioVersion)' != 'true' ">$(TargetFrameworks);net472</TargetFrameworks>
 
     <AssemblyTitle>Lucene.Net.Analysis.OpenNLP</AssemblyTitle>
     <PackageTags>$(PackageTags);analysis;natural;language;processing;opennlp</PackageTags>
diff --git a/src/Lucene.Net.Tests.Analysis.OpenNLP/Lucene.Net.Tests.Analysis.OpenNLP.csproj b/src/Lucene.Net.Tests.Analysis.OpenNLP/Lucene.Net.Tests.Analysis.OpenNLP.csproj
index bf1136e9a..473399caf 100644
--- a/src/Lucene.Net.Tests.Analysis.OpenNLP/Lucene.Net.Tests.Analysis.OpenNLP.csproj
+++ b/src/Lucene.Net.Tests.Analysis.OpenNLP/Lucene.Net.Tests.Analysis.OpenNLP.csproj
@@ -29,7 +29,7 @@
     <!--suppress MsbuildTargetFrameworkTagInspection - even though this only has one target right now, we need to use the plural version for the line below -->
     <TargetFrameworks Condition=" '$(TargetFramework)' == '' ">net10.0;net9.0;net8.0</TargetFrameworks>
     <TargetFrameworks Condition=" '$(TargetFramework)' == '' And '$(IsLegacyVisualStudioVersion)' == 'true' ">net9.0;net8.0</TargetFrameworks>
-    <TargetFrameworks Condition=" '$(TargetFramework)' == '' And $([MSBuild]::IsOsPlatform('Windows')) And '$(IsLegacyVisualStudioVersion)' != 'true' ">$(TargetFrameworks);net48</TargetFrameworks>
+    <TargetFrameworks Condition=" '$(TargetFramework)' == '' And '$(IncludeNetFrameworkTargets)' == 'true' And '$(IsLegacyVisualStudioVersion)' != 'true' ">$(TargetFrameworks);net48</TargetFrameworks>
 
     <AssemblyTitle>Lucene.Net.Tests.Analysis.OpenNLP</AssemblyTitle>
     <TestShardIsolated>true</TestShardIsolated>