C
C#4w ago
khamas

MAUI runtime identifier build hell

I have a class library that requires me to put in an RID to build it. To build one of the projects on windows I need to set the win-x64 RID However when I build a MAUI project on android, I need the android-arm64 RID I have set these:
<RuntimeIdentifiers Condition="$([MSBuild]::IsOSPlatform('windows'))">win-x64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(TargetFramework)' == 'net9.0-android'">android-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="$([MSBuild]::IsOSPlatform('windows'))">win-x64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(TargetFramework)' == 'net9.0-android'">android-arm64</RuntimeIdentifiers>
Now it builds fine, but when I build the MAUI project it doesn't build it in a sub-directory for android-arm64, when I build the class lib using dotnet build -f net9.0-android -r android-arm64 then the sub-directory is created. so basically, the MAUI app is looking for the sub-directory that has the RID but that directory does not exist. The MAUI build also works fine when I do the command dotnet build -f net9.0-android -r android-arm64
8 Replies
ero
ero4w ago
If you build it on Windows and nowhere in the project or the properties you specify the target framework, it will never apply the android runtime identifier. That's what your msbuild condition says
khamas
khamasOP4w ago
the second one should work tho
ero
ero4w ago
Only if you set the TargetFramework anywhere (either in the project or on the command line like you're doing now)
khamas
khamasOP4w ago
yes but shouldn't MAUI build for it automatically?
ero
ero4w ago
i don't see a reason for it to do that, unless there are some implicit target frameworks i don't find it sensible for maui to assume what runtimes or frameworks you want to build for
khamas
khamasOP4w ago
either way, I now set the RID to only be there once the framework is windows
ero
ero4w ago
well no, you set it when the os you're compiling on is windows. not the os you're compiling for.
khamas
khamasOP4w ago
yeah I changed it

Did you find this page helpful?