Conversation
f750804 to
0133a1c
Compare
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.
0133a1c to
03e198c
Compare
There was a problem hiding this comment.
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_versionsinput 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 | |||
There was a problem hiding this comment.
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”).
| - name: Setup Xcode for .NET 10 iOS | |
| - name: Setup Xcode for .NET 10+ iOS |
| $tfm = "net$dotnetVersion" | ||
| if ([version]$dotnetVersion -gt [version]"10.0") { | ||
| $tfm = "net10.0" | ||
| Write-Host "Using TFM net10.0 when building for .NET 11" |
There was a problem hiding this comment.
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.
| Write-Host "Using TFM net10.0 when building for .NET 11" | |
| Write-Host "Using TFM net10.0 when building for .NET $dotnetVersion" |
| - name: Setup .NET 11 | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: '11.0.x' | ||
| dotnet-quality: 'preview' | ||
|
|
There was a problem hiding this comment.
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.
| (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 |
There was a problem hiding this comment.
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.
| (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 |
| (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 |
There was a problem hiding this comment.
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.
| (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 |
| $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 |
There was a problem hiding this comment.
$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).
|
|
||
| # 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" |
There was a problem hiding this comment.
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).
| $enableXamlTrimming = [version]$dotnetVersion -le [version]"10.0" | |
| $enableXamlTrimming = [version]$dotnetVersion -ne [version]"10.0" |
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: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:
Screenshots Compare Test Runresults.Other information
Internal Issue (If applicable):