-
Notifications
You must be signed in to change notification settings - Fork 401
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
Make use of a specific iOS + MacCatalyst TFM #2243
Conversation
Hey Shaun! Two quick thoughts:
(Also - If this is PR still a work-in-progress, could you flip it to be a Draft PR please? I get distracted by shiny new PRs and want to review them, but I wait when the PR is still in Draft.) |
This isn't aimed at fixing any NativeAOT or Trimming bugs but aimed at the I'll be happy to work on any possible testing options although I am not sure how we can right now. |
I am actually starting to wonder whether this might also fix other issues such as #1374 based on this documentation page https://learn.microsoft.com/en-us/dotnet/standard/frameworks#precedence I read it as apps could be built targeting |
@brminnick I'm not convinced we can create a unit test for this. I do wonder if we could add something to the pipeline to make sure that the packaged information meets what we expect. What do you think? |
Let's chat about it in tomorrow's standup! I'm fairly confident that as long as we set up our CI / CD pipeline correctly to match our targeted frameworks and run the Device Tests in RELEASE configuration with NativeAOT enabled, |
We can replicate the error in a CI pipelines but it’s not straightforward. The latest breakage required .NET 9 RC SDK installed side-by-side to trigger it. Alternatively you can deliberately install old (fixed) workload set instead of the latest one. The trouble with that is that you either need to use custom manifests or start with 8.0.4xx SDK which introduced the workload set support. |
I was thinking of just inspecting the nuget package generated and verifying it targets the expected TFMs for Apple platforms |
I guess a nice test would be to try consuming the nightly build and see if that still exhibits the issue. I've not be able to reproduce the issue @filipnavara is this something that you could easily test/verify? |
Nightly build of what? CommunityToolkit.Maui? If you have a link I can test the scenarios easily and report back. I assume I just need to use this feed:
...and then reference the build number from this PR, right? |
There might be a neater way but I have just knocked up a little console app that could be published as a dotnet tool to perform this verification. The code is: using System.IO.Compression;
using CommandLine;
namespace PackageVerifier;
class Program
{
static void Main(string[] args)
{
Parser.Default.ParseArguments<Options>(args)
.WithParsed<Options>(o =>
{
Console.WriteLine($"Verifying package '{o.PackagePath}'");
var extractDirectory = Path.Join(Environment.CurrentDirectory, "abc");
Console.WriteLine($@"Extracting package to directory '{extractDirectory}'");
ZipFile.ExtractToDirectory(o.PackagePath, extractDirectory);
Console.WriteLine($"Checking for TFMs: '{string.Join(',', o.TargetFrameworkMonikers)}'");
var libDirectory = Path.Join(extractDirectory, "lib");
var directories = new DirectoryInfo(libDirectory).GetDirectories().Select(x => x.Name).ToList();
foreach (var unexpectedDirectory in directories.Except(o.TargetFrameworkMonikers))
{
Console.WriteLine($"WARNING: TFM '{unexpectedDirectory}' was not expected");
}
foreach (var unexpectedDirectory in o.TargetFrameworkMonikers.Except(directories))
{
Console.WriteLine($"ERROR: TFM '{unexpectedDirectory}' is missing");
}
foreach (var unexpectedDirectory in o.TargetFrameworkMonikers.Intersect(directories))
{
Console.WriteLine($"SUCCESS: Expected TFM '{unexpectedDirectory}' exists");
}
});
}
} Usage is something like: dotnet packageverifier --tfms "net9.0-ios17.5" --package-path "/Users/shaunlawrence/Documents/work/projects/toolkits/mct/src/Maui/src/CommunityToolkit.Maui/bin/Release/CommunityToolkit.Maui.1.0.0-pre1.nupkg.zip" And the output currently looks something like:
With a bit more effort it could be modified to be more user friendly and allow it to cause a pipeline build to fail. What do you think? |
Yes that looks like it is the correct feed and approach for the build number as per here https://github.com/CommunityToolkit/Maui/wiki/Preview-Packages#pull-requests- Let me find the build number |
|
Yes, I can confirm that with .NET 9 RC 1 SDK I now get the correct iOS assets. With 9.1.0 on NuGet.org I get the generic |
That's fantastic news! Thank you so much for testing this and all of the input to get us to this stage! |
Thanks for addressing it so quickly. :-) Let me know if there's anything else you need to test. |
I have had some fun playing around with this so I have stuck it in a GitHub repo: https://github.com/bijington/package-verifier |
Hey Shaun! I just tested this NuGet Package on a local environment that only has .NET SDK v8.0.303 installed (which does not include So, the good news is that this PR solves one very specific problem where the user has But it doesn't solve the problem where I think our best move is to add a MSBuild task that checks the user's local environment and produces a build error with a helpful message letting them know which MAUI workload we require. I'll play around with adding something like this today. |
Does it? Wasn't this the original issue because we were implicitly targeting I have the following setup:
When I pull in the latest build https://dev.azure.com/dotnet/CommunityToolkit/_build/results?buildId=110421&view=results from the feed I see the dreaded
On my setup if I revert to the build that targets 17.5 https://dev.azure.com/dotnet/CommunityToolkit/_releaseProgress?_a=release-pipeline-progress&releaseId=9003 then I no longer see this exception. I think we should ship a patch fix with 17.5 now to avoid the large number of developers coming to us with this issue and then ship an 18.0 in the next release. I can confirm that I don't currently have iOS 18.0 support on my Mac but I would like us to be able to safely handle this situation. Perhaps your suggestion of the MS Build task might prevent this? Given that iOS 18.0 was only made available to the public on 16th September 2024 (less than one month ago) I think it might be wise that we don't force users to update all of their tooling so quickly. If they have updated their tooling then us targeting 17.5 should work just fine for them. |
No, it doesn't fix that as is. You should change it back to target |
@filipnavara To workaround your specific problem, I recommend adding a global.json
|
I am aware of that workaround (alongside few others). It's just that .NET 9 SDK builds are noticeably faster on some machines so our devs prefer to use it. |
Note that technically there should be no benefit for libraries to target |
Thanks for confirming the workaround works for you, @filipnavara. We'll close this PR and work on a way that we can leverage MSBuild Task to ensure developer's local environments are using the correct .NET SDK, .NET MAUI Workload and Xcode versions. |
It would be nice to share more details about your plan. I don't think libraries should force users to upgrade SDKs unless there's a compelling reason (eg. relying on new API, tooling or fix). Workloads are already tied to Xcode versions and they have the necessary checks. It is also entirely valid to use .NET 9 SDK to compile Also, NuGet largely runs before most of the MSBuild evaluation takes place. You can detect that you are compiling for |
As Brandon has pointed out to me offline of this discussion; downgrading the TFM and shipping a version would effectively break anyone targeting iOS 18.0 already. So I agree it best that we don't break those users especially if we have a workaround for this issue. The PR for the MSBuild task is #2266. It's frustrating that we have to guard this rather than Nuget doing it but that sadly appears to be some pain of relying on workloads |
How? Lower version of library TFMs is still consumable by (Even if there was such a case, which I still think there is NOT, you can still ship both |
You are correct, I have tested running our build targeting 17.5 from this PR against the latest SDK and workload and it behaves. |
Description of Change
Linked Issues
PR Checklist
approved
(bug) orChampioned
(feature/proposal)main
at time of PRAdditional information