-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[net7] Creating a cross-targeted net7.0-ios
+ net6.0-ios
packages forces consumers to build with net7 workloads
#30103
Comments
From @rolfbjarne on Mon, 31 Oct 2022 14:21:24 GMT @jonathanpeppers is this something you've seen for Android too? |
From @jeromelaban on Mon, 31 Oct 2022 14:23:11 GMT Android does not seem to exhibit this problem at this point, maybe the binaries did not change versions enough to cause this? |
From @jonathanpeppers on Mon, 31 Oct 2022 14:25:01 GMT I think we've always kept I don't know if that is the right approach, but it's been that way for a long time, maybe since beginning of Xamarin.Android? |
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
From @rolfbjarne on Mon, 07 Nov 2022 09:59:35 GMT
We've released iOS 16 support for
This error seems to indicate that the consumer isn't using the latest version of the .NET 6 workloads (with iOS 16 support). Can you include a binlog of a build that fails like this? |
From @msftbot[bot] on Mon, 07 Nov 2022 09:59:43 GMT Hi @jeromelaban. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
From @filipnavara on Mon, 07 Nov 2022 10:03:28 GMT
So, funny story... I keep trying to explain to the SDK team that I need to update workloads for different SDK versions (#27109). This is yet another use case for that. The suggestion to use "global.json" to force specific SDK version doesn't work if you want to multi-target, and they insist that the broken |
From @jeromelaban on Mon, 07 Nov 2022 13:48:50 GMT @rolfbjarne the issue here is that the final app is not supposed to be updating to the latest of .NET 6 SDK. If my library is cross-targeting for net6-ios and net7-ios, I'm assuming that it will work like Now I understand that there's the underlying native SDK variant, where it should be that I should build Note that here, the overall scenario is that as a nuget package author I do not want to impose an SDK update to my consumers on package upgrades, regardless of the SDK used to build that the package. I still want them to build able to build an app two years from now without updating anything. I'll try to get a binlog. |
From @rolfbjarne on Mon, 23 Jan 2023 22:38:58 GMT Ok, so to recap, what's needed is a way to build with the earliest version (or a specific version) of a workload for a given .NET version (the project doesn't really have to be multi-targetting, that just makes the problem more complicated to solve), to ensure maximum compatibility with your customers. The use-case would be to compile a library that uses the earliest managed API for the workload (to maximize compatibility with that .NET version, since consumers of that library can then use any workload version when consuming said library). And ideally this would be specified in the csproj somehow. It seems that specifying the OS version in the TargetFramework could be a way to express this: <TargetFrameworks>net6.0-ios15.4;net7.0-ios16.0</TargetFrameworks> but that doesn't work (the Moving to dotnet/runtime, since I don't think we can do this today with how workloads are designed and implemented. |
@steveisok should we move this to SDK or keep it here? |
this isn't anything set by the runtime workloads |
Correct, I think this needs to move to the sdk |
to me this looks like the problem is coming from the manifest "Microsoft.iOS.Sdk.net7": {
"kind": "sdk",
"version": "16.0.1478",
"alias-to": {
"any": "Microsoft.iOS.Sdk"
}
},
"Microsoft.iOS.Sdk.net6": {
"kind": "sdk",
"version": "16.0.527",
"alias-to": {
"any": "Microsoft.iOS.Sdk"
}
}, that says to use 16.0.527 when targeting net6 <Project>
<ImportGroup Condition=" '$(TargetPlatformIdentifier)' == 'iOS' ">
<Import Project="Sdk.props" Sdk="Microsoft.$(TargetPlatformIdentifier).Sdk.net7" Condition=" $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '7.0')) " />
<Import Project="Sdk.props" Sdk="Microsoft.$(TargetPlatformIdentifier).Sdk.net6" Condition=" $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '6.0')) " />
<Import Project="Sdk.props" Sdk="Microsoft.$(TargetPlatformIdentifier).Windows.Sdk.Aliased.net7" Condition=" $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '7.0')) And $([MSBuild]::IsOSPlatform('windows'))" />
<Import Project="Sdk.props" Sdk="Microsoft.$(TargetPlatformIdentifier).Windows.Sdk.Aliased.net6" Condition=" $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '6.0')) And $([MSBuild]::IsOSPlatform('windows'))" />
</ImportGroup>
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '6.0')) ">
<SdkSupportedTargetPlatformIdentifier Include="ios" DisplayName="iOS" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetPlatformIdentifier)' == 'iOS' and $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '6.0')) ">
<AfterMicrosoftNETSdkTargets>$(AfterMicrosoftNETSdkTargets);$(_XamarinSdkRootDirectory)..\16.0.1478\targets\Xamarin.Shared.Sdk.MultiTarget.targets</AfterMicrosoftNETSdkTargets>
</PropertyGroup>
</Project> I think you'll need to add 15.x variant to the workload to have it work like that |
If I'm understanding what @rolfbjarne was saying, for iOS or any platform that plays fast and loose with compat, some/all of the older workload versions should hang around so that we can reference it. Yeah, I agree with @lewing, the only way I know how to pull it off is to add however many 15.x variants you need. |
my understanding is if you add net6.0-ios15 packs and aliases and import those by checking TargetPlatformVersion in the targets file you will get what you want for the Micrsoft.iOS reference, if we need ios15 specific builds of runtime we'll have to add those and the version check to the runtime manifest as well (i hope we would just need to reference the last build and not continue to service those builds as well) cc @dsplaisted something like "Microsoft.iOS15.Sdk.net6": {
"kind": "sdk",
"version": "15.4.300",
"alias-to": {
"any": "Microsoft.iOS.Sdk"
}
}, and <ImportGroup Condition=" '$(TargetPlatformIdentifier)' == 'iOS' ">
<Import Project="Sdk.props" Sdk="Microsoft.$(TargetPlatformIdentifier).Sdk.net7" Condition=" $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '7.0')) " />
<Import Project="Sdk.props" Sdk="Microsoft.$(TargetPlatformIdentifier).Sdk.net6" Condition=" $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '6.0')) and $([MSBuild]::VersionEquals($(TargetPlatformVersion), '16'))" />
<Import Project="Sdk.props" Sdk="Microsoft.$(TargetPlatformIdentifier)15.Sdk.net6" Condition=" $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '6.0')) and $([MSBuild]::VersionEquals($(TargetPlatformVersion), '15'))" />
</ImportGroup> |
this would potentially lead to very large workloads even if you split them along the platform version. I really feel like we keep running into places where being tied to the manifest versions and forcing everything to be bundled limits things |
As far as I'm understanding it, this is the main problem. You don't necessarily need to split into separate workloads. If you want, you can have a single workload that handles multiple versions, and will use the appropriate targeting and runtime packs. That's essentially what we do in the base SDK, we have a mapping from the target framework to the targeting and runtime pack versions. You don't have to include all those assets in the workload either, you can have it so if they are not installed they will be downloaded during NuGet restore. |
OK, thanks for the ideas how to implement this in the workload, I'll give it a try and see if I can make it work somehow. |
@rolfbjarne Any updates for this? |
No updates yet, and it will likely take a little while. |
If I were to use Here is an example of MAUI package taken from https://dev.azure.com/xamarin/public/_build/results?buildId=78627&view=artifacts&pathAsName=false&type=publishedArtifacts I still don't understand how this work in dotnet and xamarin. Does |
Yes.
I believe there will be confusion no matter what we do, because if we don't implicitly use the latest version, people will have to opt in to any updates we ship whenever Apple releases OS updates. |
Document the plan to: * Compile against an earlier version of our bindings. * dotnet/sdk#30103 * Consume preview packages for a preview version of Xcode. * #18343
…eting. (#18896) Multi targetting is described here: https://github.com/xamarin/xamarin-macios/blob/main/docs/multi-target-framework.md This PR implements support building using the latest .NET 7 packages we're shipping, by specifying the OS version in the target framework. It does so by: * Renaming the ref, sdk and runtime packs to contain the target framework and the target platfrom version, so the packages will now be named: * iOS * Microsoft.iOS.Sdk.net7.0_16.4 * Microsoft.iOS.Ref.net7.0_16.4 * Microsoft.iOS.Runtime.ios-arm64.net7.0_16.4 * Microsoft.iOS.Runtime.iossimulator-arm64.net7.0_16.4 * Microsoft.iOS.Runtime.iossimulator-x64.net7.0_16.4 * tvOS * Microsoft.tvOS.Sdk.net7.0_16.4 * Microsoft.tvOS.Ref.net7.0_16.4 * Microsoft.tvOS.Runtime.ios-arm64.net7.0_16.4 * Microsoft.tvOS.Runtime.iossimulator-arm64.net7.0_16.4 * Microsoft.tvOS.Runtime.iossimulator-x64.net7.0_16.4 * Mac Catalyst * Microsoft.MacCatalyst.Sdk.net7.0_16.4 * Microsoft.MacCatalyst.Ref.net7.0_16.4 * Microsoft.MacCatalyst.Runtime.maccatalyst-x64.net7.0_16.4 * Microsoft.MacCatalyst.Runtime.maccatalyst-arm64.net7.0_16.4 * macOS * Microsoft.macOS.Sdk.net7.0_13.3 * Microsoft.macOS.Ref.net7.0_13.3 * Microsoft.macOS.Runtime.osx-x64.net7.0_13.3 * Microsoft.macOS.Runtime.osx-arm64.net7.0_13.3 * Note that the workloads are also updated in this PR. Contributes towards: * #18790. * dotnet/sdk#30103. * #18343.
…geting (#18884) Multi targetting is described here: https://github.com/xamarin/xamarin-macios/blob/main/docs/multi-target-framework.md This PR implements support building using the initial .NET 7 macOS and Mac Catalyst packages we shipped, by adding "net7.0-maccatalyst15.4" or "net7.0-macos12.3" as a target framework. It does so by: * Renaming the ref, sdk and runtime packs to contain the target framework and the target platfrom version, so the packages will now be named: * Microsoft.MacCatalyst.Sdk.net7.0_15.4 * Microsoft.MacCatalyst.Ref.net7.0_15.4 * Microsoft.MacCatalyst.Runtime.maccatalyst-x64.net7.0_15.4 * Microsoft.MacCatalyst.Runtime.maccatalyst-arm64.net7.0_15.4 * Microsoft.macOS.Sdk.net7.0_12.3 * Microsoft.macOS.Ref.net7.0_12.3 * Microsoft.macOS.Runtime.osx-x64.net7.0_12.3 * Microsoft.macOS.Runtime.osx-arm64.net7.0_12.3 * Only publish the above packages to NuGet (i.e. _not_ publish the template pack, nor the workload pack). This is because we don't need to publish any new templates/workloads, we only need to support being included in a newer workload. * Note that the workloads are also updated in this PR: these workloads will never be published, but it's to keep the tests working. Contributes towards: * #18790. * dotnet/sdk#30103. * #18343.
…ting (#18891) Multi targetting is described here: https://github.com/xamarin/xamarin-macios/blob/main/docs/multi-target-framework.md This PR implements support building using the initial .NET 7 macOS and Mac Catalyst packages we shipped, by adding "net7.0-ios16.0" or "net7.0-tvos16.0" as a target framework. It does so by: * Renaming the ref, sdk and runtime packs to contain the target framework and the target platfrom version, so the packages will now be named: * Microsoft.iOS.Sdk.net7.0_16.0 * Microsoft.iOS.Ref.net7.0_16.0 * Microsoft.iOS.Runtime.ios-arm64.net7.0_16.0 * Microsoft.iOS.Runtime.iossimulator-arm64.net7.0_16.0 * Microsoft.iOS.Runtime.iossimulator-x64.net7.0_16.0 * Microsoft.tvOS.Sdk.net7.0_16.0 * Microsoft.tvOS.Ref.net7.0_16.0 * Microsoft.tvOS.Runtime.ios-arm64.net7.0_16.0 * Microsoft.tvOS.Runtime.iossimulator-arm64.net7.0_16.0 * Microsoft.tvOS.Runtime.iossimulator-x64.net7.0_16.0 * Only publish the above packages to NuGet (i.e. _not_ publish the template pack, nor the workload pack). This is because we don't need to publish any new templates/workloads, we only need to support being included in a newer workload. * Note that the workloads are also updated in this PR: these workloads will never be published, but it's to keep the tests working. Contributes towards: * #18790. * dotnet/sdk#30103. * #18343. This PR is best reviewed commit-by-commit.
Multi targetting is described here: https://github.com/xamarin/xamarin-macios/blob/main/docs/multi-target-framework.md This change implements support for: * Building using the first .NET 7 packages we shipped. * Building using the last .NET 7 packages we've shipped. In both cases by specifying the OS version in the target framework. Additionally adding support for any other API/OS version is trivial: it's just a matter of listing the corresponding versions in a few files (this is particularly interesting to add support for preview versions). It does so by: * Renaming the ref, sdk and runtime packs to contain the target framework and the target platfrom version, so the packages will now be named: * iOS * Microsoft.iOS.Sdk.net8.0_16.4 * Microsoft.iOS.Ref.net8.0_16.4 * Microsoft.iOS.Runtime.ios-arm64.net8.0_16.4 * Microsoft.iOS.Runtime.iossimulator-arm64.net8.0_16.4 * Microsoft.iOS.Runtime.iossimulator-x64.net8.0_16.4 * tvOS * Microsoft.tvOS.Sdk.net8.0_16.4 * Microsoft.tvOS.Ref.net8.0_16.4 * Microsoft.tvOS.Runtime.ios-arm64.net8.0_16.4 * Microsoft.tvOS.Runtime.iossimulator-arm64.net8.0_16.4 * Microsoft.tvOS.Runtime.iossimulator-x64.net8.0_16.4 * Mac Catalyst * Microsoft.MacCatalyst.Sdk.net8.0_16.4 * Microsoft.MacCatalyst.Ref.net8.0_16.4 * Microsoft.MacCatalyst.Runtime.maccatalyst-x64.net8.0_16.4 * Microsoft.MacCatalyst.Runtime.maccatalyst-arm64.net8.0_16.4 * macOS * Microsoft.macOS.Sdk.net8.0_13.3 * Microsoft.macOS.Ref.net8.0_13.3 * Microsoft.macOS.Runtime.osx-x64.net8.0_13.3 * Microsoft.macOS.Runtime.osx-arm64.net8.0_13.3 * Updating the WorkloadManifest.json and WorkloadManifest.targets files to load the correct packs according to the TargetFramework in the developer's project. * We're also now giving a better error message for invalid/unsupported/eol'ed target frameworks. Fixes #18790. * Add a few tests. Fixes: * #18790. * dotnet/sdk#30103. * #16802. Contributes towards: * #18343.
This has been fixed (xamarin/xamarin-macios#18931), and should be in .NET 8 RC 2. Contrary to other platforms, library authors will have to be explicit about the target platform version if they want the earliest: <TargetFrameworks>net7.0-ios16.0;net7.0-ios16.4;net8.0-ios-17.0</TargetFrameworks> This will create a library for three different iOS versions. Also note that we won't support all released OS versions, it'll typically be the first release for a given .NET version (which was iOS 16.0 for .NET 7), and the latest (currently iOS 16.4). If Apple releases iOS 16.5, we won't support using |
Thanks a lot for the update! |
Unfortunately we ran into some problems, so we had to pull this for .NET 8, and I'm reopening until we can get it in (in a .NET 8 service releae). |
I've made another attempt at implementing this, but I'm not entirely sure when we'll be able to release it. At this point it might be released in our Xcode 15.3 release, but it's not certain yet. It's also planned for .NET 9 preview 3, but once again, we might run into trouble and have to back it out until we iron out some more issues. |
Nobody found any issues, so it ended up released in .NET 9 preview 3. This should now work in an iOS library project when using .NET 9 preview 3: <TargetFrameworks>net9.0-ios17.2;net8.0-ios17.0</TargetFrameworks> For now, the .NET 9 preview release supports only two OS targets: iOS 17.2 for .NET 9 and iOS 17.0 for .NET 8. The idea is to eventually support the earliest and latest OS version for each .NET version, so when .NET 9 becomes stable in the fall, that will be iOS 18.0 for .NET 9, and iOS 17.0 + iOS 17.5 (assuming this is the latest iOS 17 minor version at the time) for .NET 8. Then in subsequent versions of .NET 9, we'll always keep iOS 18.0 as supported, while also supporting the latest iOS version as well. You can also choose a TargetFramework without an OS version, and it will default to the latest. So this is equivalent to the above: <TargetFrameworks>net9.0-ios;net8.0-ios17.0</TargetFrameworks> The general recommendation would be:
Please test and let me know if there are any issues! |
@rolfbjarne I think it would be great if there is a way to opt-in a warning when the specified version isn't supported by the current .NET SDK, e.g, doing |
That will be an error in .NET 9, and (eventually, once the code has been released in a service update) a warning in .NET 8. |
@rolfbjarne We've validated that this works for us. Thanks for all the fixes! |
That's great, thanks for confirming! |
From @jeromelaban on Mon, 31 Oct 2022 14:18:39 GMT
Creating a cross-targeted
net7.0-ios
+net6.0-ios
packages forces consumers to build with net7 workloads, causing dependents on net6.0 to fail building with the following message:This means that any library author currently cannot build packages for net6.0 and net7.0 without resorting to manual package authoring and multi-builds with
global.json
modifications.Steps to Reproduce
<TargetFrameworks>net6.0-ios;net7.0-ios</TargetFramework>
Expected Behavior
net6.0-ios
binaries referenceMicrosoft.iOS
15.4.300.xActual Behavior
The
net6.0-ios
binaries referenceMicrosoft.iOS
16.0.xEnvironment
.NET 7.0 RC2 with workloads (VS 17.4 Preview 5)
Build Logs
I can provide those as needed.
As needed.
Example Project (If Possible)
Copied from original issue xamarin/xamarin-macios#16524
The text was updated successfully, but these errors were encountered: