Skip to content

fix: parse multi-digit .NET versions for host platform selection#169

Draft
Copilot wants to merge 1 commit intofix/not.finding.generation.hostfrom
copilot/sub-pr-168
Draft

fix: parse multi-digit .NET versions for host platform selection#169
Copilot wants to merge 1 commit intofix/not.finding.generation.hostfrom
copilot/sub-pr-168

Conversation

Copy link
Copy Markdown

Copilot AI commented Dec 17, 2025

Fixes issue where SourceGenerationTask fails to correctly determine host platform for .NET 10+. The original code extracted only a single character from the framework description string, which works for .NET 6-9 but breaks for multi-digit versions.

Changes

  • Version parsing: Extract version string using Substring(5).Split('.')[0] instead of single-character extraction
  • Error handling: Added fallback to "net6" if version parsing fails
  • Backward compatibility: Maintains support for existing .NET 6-9 versions
// Before: only worked for single-digit versions
var versionChar = fx[5];
hostPlatform = "net" + versionChar;

// After: handles multi-digit versions
var versionString = fx.Substring(5).Split('.')[0];
if (int.TryParse(versionString, out var version))
{
    hostPlatform = (version > 6) ? "net6" : "net" + version;
}
else
{
    hostPlatform = "net6"; // fallback
}

The fix ensures proper host path resolution for all .NET versions while respecting the existing <RollForward>LatestMajor</RollForward> configuration that targets net6 as the minimum shipped host platform.

Closes #167


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix generationtask not finding host on net10 builds fix: parse multi-digit .NET versions for host platform selection Dec 17, 2025
Copilot AI requested a review from ajpinedam December 17, 2025 03:32
@ajpinedam ajpinedam marked this pull request as ready for review December 17, 2025 03:35
@ajpinedam ajpinedam marked this pull request as draft December 17, 2025 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants