Skip to content

chore: enable testing under .NET 11#29

Merged
jonpryor merged 1 commit intomasterfrom
dev/jonpryor/jonp-try-net11
Feb 23, 2026
Merged

chore: enable testing under .NET 11#29
jonpryor merged 1 commit intomasterfrom
dev/jonpryor/jonp-try-net11

Conversation

@jonpryor
Copy link
Copy Markdown
Contributor

As we now have three versions under consideration -- .NET 9, .NET 10, .NET 11 -- using string comparisons for version numbers doesn't work.

Instead, we need to use version comparison, which is done by prefixing variables and strings with [version] and changing the comparison operand accordingly:

# old and busted:
if ($dotnet -eq "10.0")

# new hotness:
if ([version]$dotnet -ge [version]"10.0")

GitHub Issue (If applicable): #

PR Type

What kind of change does this PR introduce?

What is the current behavior?

What is the new behavior?

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Docs have been added/updated which fit documentation template. (for bug fixes / features)
  • Unit Tests and/or UI Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Wasm UI Tests are not showing unexpected any differences. Validate PR Screenshots Compare Test Run results.
  • Contains NO breaking changes
  • Updated the Release Notes
  • Associated with an issue (GitHub or internal)

Other information

Internal Issue (If applicable):

Context: unoplatform/uno.templates#1992

As we now have three versions under consideration -- .NET 9, .NET 10,
.NET 11 -- using string comparisons for version numbers doesn't work.

Instead, we need to use version comparison, which is done by prefixing
variables and strings with `[version]` and changing the comparison
operand accordingly:

	# old and busted:
	if ($dotnet -eq "10.0")

	# new hotness:
	if ([version]$dotnet -ge [version]"10.0")

Additionally, `dotnet new unoapp -tfm net11.0` fails because .NET 11
is not yet supported; see unoplatform/uno.templates#1992.

Work around this issue by instead generating the template for `net10.0`
and then replacingn all instances of `net10.0` with `net11.0` in the
generated project file.

We also need to update `global.json` to allow preview SDK versions.
@jonpryor jonpryor force-pushed the dev/jonpryor/jonp-try-net11 branch from 0133a1c to 03e198c Compare February 23, 2026 18:06
@jonpryor jonpryor requested review from Copilot and jeromelaban and removed request for Copilot February 23, 2026 19:25
@jonpryor jonpryor merged commit b39f0eb into master Feb 23, 2026
70 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the daily template size tracking GitHub Actions workflow to include .NET 11 in the test matrix and replaces fragile string comparisons with proper PowerShell version comparisons.

Changes:

  • Adds .NET 11 to the default dotnet_versions input and installs the .NET 11 SDK (preview) in the matrix preparation job.
  • Switches version gating (e.g., Android NAOT inclusion) from string comparisons to [version] comparisons.
  • Adjusts project creation/build logic to generate a net10 project and then retarget it for .NET 11.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -265,7 +271,7 @@ jobs:
xcode-version: '26.0'

- name: Setup Xcode for .NET 10 iOS
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Step name is now misleading: the condition applies to iOS builds for any .NET version other than 9.0 (including 11.0), but the name still says “.NET 10 iOS”. Consider renaming the step to reflect what it actually configures (e.g., “.NET 10+ iOS”).

Suggested change
- name: Setup Xcode for .NET 10 iOS
- name: Setup Xcode for .NET 10+ iOS

Copilot uses AI. Check for mistakes.
$tfm = "net$dotnetVersion"
if ([version]$dotnetVersion -gt [version]"10.0") {
$tfm = "net10.0"
Write-Host "Using TFM net10.0 when building for .NET 11"
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch triggers for any version > 10.0, but the log message is hard-coded to “.NET 11”. If a future version is added (e.g., 12.0), this becomes confusing. Consider making the message version-agnostic or checking specifically for 11.0.

Suggested change
Write-Host "Using TFM net10.0 when building for .NET 11"
Write-Host "Using TFM net10.0 when building for .NET $dotnetVersion"

Copilot uses AI. Check for mistakes.
Comment on lines +63 to +68
- name: Setup .NET 11
uses: actions/setup-dotnet@v5
with:
dotnet-version: '11.0.x'
dotnet-quality: 'preview'

Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added .NET 11 setup runs only in the prepare-matrix job; each job gets a fresh runner, so build-and-measure will not automatically have the .NET 11 SDK available. If the matrix includes 11.0, the Setup .NET ${{ matrix.dotnet }} step in build-and-measure also needs to install .NET 11 (and likely with dotnet-quality: preview / a compatible setup-dotnet version) or the builds will fail.

Copilot uses AI. Check for mistakes.
Comment on lines +360 to +367
(Get-Content $projectFile.FullName).Replace("net10.0", $tfm) | Set-Content $projectFile.FullName

Write-Host "New $($projectFile.FullName) contents:"
Get-Content $projectFile.FullName | ForEach-Object { Write-Host $_ }

$globalJson = Get-ChildItem -Path $projectName -Filter "global.json" -Recurse | Select-Object -First 1
Write-Host "Updating $($globalJson.FullName) to allow prerelease"
(Get-Content $globalJson.FullName).Replace('"allowPrerelease": false', '"allowPrerelease": true') | Set-Content $globalJson.FullName
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get-Content without -Raw returns a string array for multi-line files; calling .Replace(...) on that array will throw and break the workflow. Read the file as a single string (e.g., -Raw) or perform the replacement line-by-line before writing it back.

Suggested change
(Get-Content $projectFile.FullName).Replace("net10.0", $tfm) | Set-Content $projectFile.FullName
Write-Host "New $($projectFile.FullName) contents:"
Get-Content $projectFile.FullName | ForEach-Object { Write-Host $_ }
$globalJson = Get-ChildItem -Path $projectName -Filter "global.json" -Recurse | Select-Object -First 1
Write-Host "Updating $($globalJson.FullName) to allow prerelease"
(Get-Content $globalJson.FullName).Replace('"allowPrerelease": false', '"allowPrerelease": true') | Set-Content $globalJson.FullName
(Get-Content $projectFile.FullName -Raw).Replace("net10.0", $tfm) | Set-Content $projectFile.FullName
Write-Host "New $($projectFile.FullName) contents:"
Get-Content $projectFile.FullName | ForEach-Object { Write-Host $_ }
$globalJson = Get-ChildItem -Path $projectName -Filter "global.json" -Recurse | Select-Object -First 1
Write-Host "Updating $($globalJson.FullName) to allow prerelease"
(Get-Content $globalJson.FullName -Raw).Replace('"allowPrerelease": false', '"allowPrerelease": true') | Set-Content $globalJson.FullName

Copilot uses AI. Check for mistakes.
Comment on lines +360 to +367
(Get-Content $projectFile.FullName).Replace("net10.0", $tfm) | Set-Content $projectFile.FullName

Write-Host "New $($projectFile.FullName) contents:"
Get-Content $projectFile.FullName | ForEach-Object { Write-Host $_ }

$globalJson = Get-ChildItem -Path $projectName -Filter "global.json" -Recurse | Select-Object -First 1
Write-Host "Updating $($globalJson.FullName) to allow prerelease"
(Get-Content $globalJson.FullName).Replace('"allowPrerelease": false', '"allowPrerelease": true') | Set-Content $globalJson.FullName
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as above: Get-Content returns an array for multi-line JSON, so .Replace(...) will fail. Use Get-Content -Raw (or equivalent) to safely do the replacement and write back the updated contents.

Suggested change
(Get-Content $projectFile.FullName).Replace("net10.0", $tfm) | Set-Content $projectFile.FullName
Write-Host "New $($projectFile.FullName) contents:"
Get-Content $projectFile.FullName | ForEach-Object { Write-Host $_ }
$globalJson = Get-ChildItem -Path $projectName -Filter "global.json" -Recurse | Select-Object -First 1
Write-Host "Updating $($globalJson.FullName) to allow prerelease"
(Get-Content $globalJson.FullName).Replace('"allowPrerelease": false', '"allowPrerelease": true') | Set-Content $globalJson.FullName
(Get-Content -Raw $projectFile.FullName).Replace("net10.0", $tfm) | Set-Content $projectFile.FullName
Write-Host "New $($projectFile.FullName) contents:"
Get-Content $projectFile.FullName | ForEach-Object { Write-Host $_ }
$globalJson = Get-ChildItem -Path $projectName -Filter "global.json" -Recurse | Select-Object -First 1
Write-Host "Updating $($globalJson.FullName) to allow prerelease"
(Get-Content -Raw $globalJson.FullName).Replace('"allowPrerelease": false', '"allowPrerelease": true') | Set-Content $globalJson.FullName

Copilot uses AI. Check for mistakes.
Comment on lines +358 to +367
$projectFile = Get-ChildItem -Path $projectName -Filter "*.csproj" -Exclude "*.Tests.csproj" -Recurse | Select-Object -First 1
Write-Host "Updating $($projectFile.FullName) to target $tfm"
(Get-Content $projectFile.FullName).Replace("net10.0", $tfm) | Set-Content $projectFile.FullName

Write-Host "New $($projectFile.FullName) contents:"
Get-Content $projectFile.FullName | ForEach-Object { Write-Host $_ }

$globalJson = Get-ChildItem -Path $projectName -Filter "global.json" -Recurse | Select-Object -First 1
Write-Host "Updating $($globalJson.FullName) to allow prerelease"
(Get-Content $globalJson.FullName).Replace('"allowPrerelease": false', '"allowPrerelease": true') | Set-Content $globalJson.FullName
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$projectFile/$globalJson are used immediately for .FullName without verifying they were found. If the template output changes (or a project type doesn’t emit global.json), this will fail with a null dereference. Add explicit checks with a clear error/exit (similar to the later check in the Build step).

Copilot uses AI. Check for mistakes.

# Disable XAML/Resource Trimming for net10 due to https://github.com/unoplatform/uno/issues/21731
$enableXamlTrimming = $dotnetVersion -ne "10.0"
$enableXamlTrimming = [version]$dotnetVersion -le [version]"10.0"
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition no longer matches the comment. The comment says trimming should be disabled only for net10, but [version]$dotnetVersion -le 10.0 enables trimming for 9.0 and 10.0 and disables it for 11.0. Use a version comparison that disables trimming specifically for 10.0 (and enables it for 9.0 and 11.0).

Suggested change
$enableXamlTrimming = [version]$dotnetVersion -le [version]"10.0"
$enableXamlTrimming = [version]$dotnetVersion -ne [version]"10.0"

Copilot uses AI. Check for mistakes.
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.

3 participants