Auto-detect installed .NET SDK version for generated C# project files#280
Auto-detect installed .NET SDK version for generated C# project files#280
Conversation
…e C# project files Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com>
|
Instead of targeting a dotnet version cant you target netstandard2.0 or netstandard2.1 |
Targeting
Additionally, the test project ( Fixing the three issues above would require non-trivial changes to the boilerplate (removing/polyfilling modern C# features). The auto-detection approach in the current PR avoids that by keeping the code targeting |
Generated and boilerplate C#
.csprojfiles hardcoded a specific TFM (net8.0ornet10.0), requiring manual edits when using a different SDK and causing version mismatches between the generated library and test projects.Changes
generate.py— Added_detect_dotnet_framework()that runsdotnet --versionand returns the active TFM (e.g.net10.0), falling back tonet8.0. Updated--target_frameworkdefault to use it, so generated.csprojfiles automatically target the installed SDK.run_tests.py— Added the same detection helper. C#build_dirnow uses the detected TFM instead of the hardcodednet10.0. Code generation passes--target_framework <detected>.dotnet buildpasses-p:BuildTargetFramework=<detected>.StructFrameTests.csproj— Replaced hardcoded<TargetFramework>net8.0</TargetFramework>with an intermediate property so the test runner can override it without the NuGet restore phase ignoring the override (a known limitation of-p:TargetFramework=):net8.0remains the minimum fallback for manual builds on systems withoutdotnetonPATH.🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.