-
-
Notifications
You must be signed in to change notification settings - Fork 55
Fix runtime detection in targets file #477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
A fix to ensure the .targets
file correctly detects installed .NET SDK versions by capturing and parsing the dotnet --list-sdks
output.
- Enabled MSBuild capture of SDK list output (
StdOut
) for detection - Consolidated version checks into a single
PropertyGroup
withIsMatchingX
flags and conditional overrides - Removed legacy version-specific groups and the
FlatSharpPrettyPrint
flag handling, and added a diagnostic message
Comments suppressed due to low confidence (2)
src/FlatSharp.Compiler/FlatSharp.Compiler.targets:174
- Removing the
FlatSharpPrettyPrint
property group disables the--pretty-print
option for the compiler; reintroduce conditional handling or merge it into the unifiedCompilerCommand
construction.
<PropertyGroup Condition=" '$(FlatSharpPrettyPrint)' == 'true' ">
src/FlatSharp.Compiler/FlatSharp.Compiler.targets:103
- [nitpick] Hard-coding version checks for each major release requires manual updates for .NET 10+; consider extracting the highest major version dynamically to reduce future maintenance.
<IsMatching6>$([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), '6\\.0\\.\d+'))</IsMatching6>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #477 +/- ##
=======================================
Coverage 96.04% 96.04%
=======================================
Files 124 124
Lines 8928 8928
Branches 749 749
=======================================
Hits 8575 8575
Misses 261 261
Partials 92 92 Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors how the FlatSharp compiler MSBuild targets detect the .NET version and cleans up CI workflow configurations.
- Switches from
dotnet --list-sdks
todotnet --version
for version detection - Consolidates
CompilerVersion
assignments into onePropertyGroup
with conditional overrides for .NET 6–9 - Removes the deprecated
dotnet-quality
input from CI workflow files
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/FlatSharp.Compiler/FlatSharp.Compiler.targets | Updated runtime detection logic; refactored CompilerVersion settings; added a diagnostic message |
.github/workflows/stryker.yml | Removed deprecated dotnet-quality input |
.github/workflows/dotnet.yml | Removed deprecated dotnet-quality input |
.github/workflows/codecov.yml | Removed deprecated dotnet-quality input |
Comments suppressed due to low confidence (1)
src/FlatSharp.Compiler/FlatSharp.Compiler.targets:107
- [nitpick] Setting
CompilerVersion
tonet9.0
by default makes the explicit condition for 9.0 redundant. You could remove the 9-case or adjust the default placement for clarity.
<CompilerVersion>net9.0</CompilerVersion>
<Exec Command="dotnet --version" ConsoleToMsBuild="true"> | ||
<Output TaskParameter="ConsoleOutput" PropertyName="StdOut" /> | ||
</Exec> | ||
|
||
<PropertyGroup> | ||
<CompilerVersion>net9.0</CompilerVersion> | ||
</PropertyGroup> | ||
|
||
<!-- try .net6.0. --> | ||
<PropertyGroup Condition=" $([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), '6\.0\.\d+')) "> | ||
<CompilerVersion>net6.0</CompilerVersion> | ||
</PropertyGroup> | ||
|
||
<!-- try .net7.0. --> | ||
<PropertyGroup Condition=" $([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), '7\.0\.\d+')) "> | ||
<CompilerVersion>net7.0</CompilerVersion> | ||
</PropertyGroup> | ||
|
||
<!-- try .net8.0. --> | ||
<PropertyGroup Condition=" $([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), '8\.0\.\d+')) "> | ||
<CompilerVersion>net8.0</CompilerVersion> | ||
</PropertyGroup> | ||
|
||
<!-- try .net9.0. --> | ||
<PropertyGroup Condition=" $([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), '9\.0\.\d+')) "> | ||
<CompilerVersion>net9.0</CompilerVersion> | ||
</PropertyGroup> | ||
<IsMatching6>$([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), '6\.0\.\d+'))</IsMatching6> | ||
<IsMatching7>$([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), '7\.0\.\d+'))</IsMatching7> | ||
<IsMatching8>$([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), '8\.0\.\d+'))</IsMatching8> | ||
<IsMatching9>$([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), '9\.0\.\d+'))</IsMatching9> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using dotnet --version
reports the SDK version, not installed runtimes. To detect runtimes, consider using dotnet --list-runtimes
instead.
<Exec Command="dotnet --version" ConsoleToMsBuild="true"> | |
<Output TaskParameter="ConsoleOutput" PropertyName="StdOut" /> | |
</Exec> | |
<PropertyGroup> | |
<CompilerVersion>net9.0</CompilerVersion> | |
</PropertyGroup> | |
<!-- try .net6.0. --> | |
<PropertyGroup Condition=" $([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), '6\.0\.\d+')) "> | |
<CompilerVersion>net6.0</CompilerVersion> | |
</PropertyGroup> | |
<!-- try .net7.0. --> | |
<PropertyGroup Condition=" $([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), '7\.0\.\d+')) "> | |
<CompilerVersion>net7.0</CompilerVersion> | |
</PropertyGroup> | |
<!-- try .net8.0. --> | |
<PropertyGroup Condition=" $([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), '8\.0\.\d+')) "> | |
<CompilerVersion>net8.0</CompilerVersion> | |
</PropertyGroup> | |
<!-- try .net9.0. --> | |
<PropertyGroup Condition=" $([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), '9\.0\.\d+')) "> | |
<CompilerVersion>net9.0</CompilerVersion> | |
</PropertyGroup> | |
<IsMatching6>$([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), '6\.0\.\d+'))</IsMatching6> | |
<IsMatching7>$([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), '7\.0\.\d+'))</IsMatching7> | |
<IsMatching8>$([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), '8\.0\.\d+'))</IsMatching8> | |
<IsMatching9>$([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), '9\.0\.\d+'))</IsMatching9> | |
<Exec Command="dotnet --list-runtimes" ConsoleToMsBuild="true"> | |
<Output TaskParameter="ConsoleOutput" PropertyName="StdOut" /> | |
</Exec> | |
<PropertyGroup> | |
<IsMatching6>$([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), 'Microsoft\.NETCore\.App 6\.0\.\d+'))</IsMatching6> | |
<IsMatching7>$([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), 'Microsoft\.NETCore\.App 7\.0\.\d+'))</IsMatching7> | |
<IsMatching8>$([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), 'Microsoft\.NETCore\.App 8\.0\.\d+'))</IsMatching8> | |
<IsMatching9>$([System.Text.RegularExpressions.Regex]::IsMatch($(StdOut), 'Microsoft\.NETCore\.App 9\.0\.\d+'))</IsMatching9> |
Copilot uses AI. Check for mistakes.
…om/jamescourtney/FlatSharp into fix_targets_file_runtime_detection
* Fix runtime detection in targets file * Restore pretty print * Use --version instead of --list-sdks * Update dotnet.yml * Update codecov.yml * Update stryker.yml * copilot can't make up its mind
Fix for #476