Repository navigation
[.NET 8] Mono workload doesn't import Microsoft.NET.Runtime.MonoAOTCompiler.Task #77385
Description
Description
As seen here: dotnet/android#7451
It appears that building a net7.0-android project with a .NET 8 SDK skips this import:
<!-- ======== C:\a\_work\1\s\xamarin-android\bin\Release\dotnet\sdk-manifests\8.0.200\microsoft.net.workload.mono.toolchain.net7\WorkloadManifest.targets ======= -->
<Project>
<Import Condition="'$(TargetsNet7)' == 'true' and '$(RunAOTCompilation)' == 'true' and '$(UsingBrowserRuntimeWorkload)' == 'true'" Project="Sdk.props" Sdk="Microsoft.NET.Runtime.MonoAOTCompiler.Task.net7" />And then a Release build with AOT happens to work, because we have these imports as a fallback:
(We're wanting to remove these imports from .NET 8, and stop supporting the $(AotAssemblies) brought forward from Xamarin.Android)
The end result is several build warnings, such as:
Warnings
C:\a\_work\1\s\xamarin-android\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.1\targets\Microsoft.Android.Sdk.Aot.targets(27,5): warning MSB4011: "C:\a\_work\1\s\xamarin-android\bin\Release\dotnet\packs\Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-x86\8.0.0-alpha.1.22507.5\Sdk\Sdk.props" cannot be imported again. It was already imported at "C:\a\_work\1\s\xamarin-android\bin\Release\dotnet\sdk-manifests\8.0.200\microsoft.net.workload.mono.toolchain.net7\WorkloadManifest.targets (9,9)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\a\_work\1\a\TestRelease\10-22_07.31.58\temp\DotNetPublishTrue[net7.0 android 33]\UnnamedProject.csproj]
C:\a\_work\1\s\xamarin-android\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.1\targets\Microsoft.Android.Sdk.Aot.targets(28,5): warning MSB4011: "C:\a\_work\1\s\xamarin-android\bin\Release\dotnet\packs\Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-x64\8.0.0-alpha.1.22507.5\Sdk\Sdk.props" cannot be imported again. It was already imported at "C:\a\_work\1\s\xamarin-android\bin\Release\dotnet\sdk-manifests\8.0.200\microsoft.net.workload.mono.toolchain.net7\WorkloadManifest.targets (10,9)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\a\_work\1\a\TestRelease\10-22_07.31.58\temp\DotNetPublishTrue[net7.0 android 33]\UnnamedProject.csproj]
C:\a\_work\1\s\xamarin-android\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.1\targets\Microsoft.Android.Sdk.Aot.targets(29,5): warning MSB4011: "C:\a\_work\1\s\xamarin-android\bin\Release\dotnet\packs\Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm\8.0.0-alpha.1.22507.5\Sdk\Sdk.props" cannot be imported again. It was already imported at "C:\a\_work\1\s\xamarin-android\bin\Release\dotnet\sdk-manifests\8.0.200\microsoft.net.workload.mono.toolchain.net7\WorkloadManifest.targets (11,9)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\a\_work\1\a\TestRelease\10-22_07.31.58\temp\DotNetPublishTrue[net7.0 android 33]\UnnamedProject.csproj]
C:\a\_work\1\s\xamarin-android\bin\Release\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.1\targets\Microsoft.Android.Sdk.Aot.targets(30,5): warning MSB4011: "C:\a\_work\1\s\xamarin-android\bin\Release\dotnet\packs\Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm64\8.0.0-alpha.1.22507.5\Sdk\Sdk.props" cannot be imported again. It was already imported at "C:\a\_work\1\s\xamarin-android\bin\Release\dotnet\sdk-manifests\8.0.200\microsoft.net.workload.mono.toolchain.net7\WorkloadManifest.targets (12,9)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\a\_work\1\a\TestRelease\10-22_07.31.58\temp\DotNetPublishTrue[net7.0 android 33]\UnnamedProject.csproj]
But I think the core problem might be $(UsingBrowserRuntimeWorkload) isn't set?
Reproduction Steps
- Install .NET 8 and the Android workload
dotnet new android, then change TFM tonet7.0-androiddotnet build -c Release -bl
See the warnings in the build log.
Actual behavior
Building net7.0-android apps with the .NET 8 SDK emits build warnings.
Expected behavior
Building net7.0-android apps with the .NET 8 SDK should have no build warnings.
Regression?
It works to multitarget .NET 7 SDK, building net6.0-android apps, so yes?
Known Workarounds
Targeting net8.0-android and net6.0-android with the .NET 8 SDK appear to work.
Configuration
.NET SDK 8.0.200-alpha.1.22511.1
.NET runtime 8.0.0-alpha.1.22507.5
Other information
.binlog: dotnet8-7-multitargeting.zip
Activity
Remove a net7.0 assertion for build warnings
radical commentedon Oct 24, 2022
cc @lewing @steveisok
I will also take a look later today.
steveisok commentedon Oct 24, 2022
We didn't really need a property for mobile previously, but I think that would simplify the fix for this.
Bump to .NET 8
[Workloads] Add UsingMobileWorkload property to control loading net7 …
Bump to dotnet/installer@d5520378 8.0.200-alpha.1.22511.1 (#7451)
jonathanpeppers commentedon Oct 31, 2022
We hit another error related to this problem, building a
net7.0-androidapp with a .NET 8 SDK:Logs: runtimeconfigparser.zip
4 remaining items
jonathanpeppers commentedon Nov 4, 2022
This fix doesn't appear to work, because the .NET 8
.targetsare imported last?Maybe we can't rely on this having a stable order, and you have to make the same check in all three
WorkloadManifests.targetsfiles?Here is a
.binlog: net7onnet8.zipThis failed here: dotnet/android#7505
steveisok commentedon Nov 4, 2022
Weird, in the sdk I'm using, it comes in the right order.
My SDK version is
8.0.100-alpha.1.22531.1jonathanpeppers commentedon Nov 4, 2022
What happens when the name changes to
microsoft.net.workload.mono.toolchain.net8, will it move to the bottom?I don't know how much you can rely on the ordering, but we could ask the .NET SDK team?
[tests] temporarily ignore net6.0 and net7.0 tests
steveisok commentedon Nov 4, 2022
dotnet/sdk#28607 makes things right, but only for .NET 7 it seems.
@dsplaisted did this go into the .NET 8 SDK yet?
steveisok commentedon Nov 4, 2022
As long as the SDK current baseline manifest targets run first, I don't think it'll matter what net* workload targets load.
[xaprepare] use 8.0.100 version band for Mono workloads
dsplaisted commentedon Nov 4, 2022
It had not gone into main yet. I've just merged dotnet/sdk#28875, so now it is in main (pending code flow and builds of course).
jonathanpeppers commentedon Nov 4, 2022
I think this also will fix the ordering for us: dotnet/android#7530
Parts of our build moves files around manually, so we had
sdk-manifests/8.0.100-alpha.1instead of8.0.100.[xaprepare] use 8.0.100 version band for Mono workloads (#7530)
jonathanpeppers commentedon Nov 7, 2022
This appeared to be fixed by dotnet/android#7530, our build has to do manual things with workloads, so it can build against the abstract Mono workload.
I don't think the ordering issue would have happened when installing workloads normally.