-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Android publish: error NETSDK1191: A runtime identifier for the property 'SelfContained' couldn't be inferred #15696
Comments
Also receiving this, this effectively hard breaks .NET 8 Preview 5. Downgrading to .NET 8 Preview 4 also resolves this problem. Per here, Android defaults to Edit: I think the docs are outdated, Android recommends targeting arm64-v8a |
Doing |
This is likely caused by: dotnet/sdk#30038 For Android, can you use |
Fixes: dotnet/maui#15696 Context: dotnet/sdk#30038 In .NET 8 Preview 5, there are various changes to default values: * `dotnet publish` is now `Release` by default * Builds that provide a `$(RuntimeIdentifier)` are no longer "self contained" by default. The result of this change is the problem: dotnet new android dotnet publish Microsoft.NET.RuntimeIdentifierInference.targets(212,5): error NETSDK1191: A runtime identifier for the property 'SelfContained' couldn't be inferred. Specify a rid explicitly. While these commands all work: dotnet build dotnet build -c Release dotnet publish -c Debug dotnet publish -r android-arm64 `Debug` configurations work fine, because trimming is not involved. `dotnet build` works fine, because the offending default appears to be: https://github.com/dotnet/sdk/blob/540b197311bc8d1c2a991fed1b935b094a4d7b2d/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets#L64-L76 `Microsoft.NET.RuntimeIdentifierInference.targets` has a lot of MSBuild validation logic, that its main job is to emit nice error messages for incorrect combinations of MSBuild properties/settings. Android is kind of the odd one out when you compare to .NET console apps, NativeAOT, etc.: * We default to `RuntimeIdentifiers=android-arm;android-arm64;android-x86;android-x64`. * We do our own "inner build" for each `RuntimeIdentifier`. * Inside our build we force `$(SelfContained)` to `true` no matter what. As there is no such thing as a system-wide .NET on Android. The fix appears to be to default `PublishSelfContained=false` and let our existing logic force `SelfContained=true`. I added a new test for this scenario. Our existing test didn't work because it was passing a `RuntimeIdentifier`.
For now, the workarounds are:
There isn't a non-self-contained Android app, as that would imply some kind of system-wide .NET package from Google Play, etc. that runs on Android. We don't have such a thing. |
Fixes: dotnet/maui#15696 Context: dotnet/sdk#30038 In .NET 8 Preview 5, there are various changes to default values: * `dotnet publish` is now `Release` by default * Builds that provide a `$(RuntimeIdentifier)` are no longer "self contained" by default. The result of this change is the problem: dotnet new android dotnet publish Microsoft.NET.RuntimeIdentifierInference.targets(212,5): error NETSDK1191: A runtime identifier for the property 'SelfContained' couldn't be inferred. Specify a rid explicitly. While these commands all work: dotnet build dotnet build -c Release dotnet publish -c Debug dotnet publish -r android-arm64 `Debug` configurations work fine, because trimming is not involved. `dotnet build` works fine, because the offending default appears to be: https://github.com/dotnet/sdk/blob/540b197311bc8d1c2a991fed1b935b094a4d7b2d/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets#L64-L76 `Microsoft.NET.RuntimeIdentifierInference.targets` has a lot of MSBuild validation logic, that its main job is to emit nice error messages for incorrect combinations of MSBuild properties/settings. Android is kind of the odd one out when you compare to .NET console apps, NativeAOT, etc.: * We default to `RuntimeIdentifiers=android-arm;android-arm64;android-x86;android-x64`. * We do our own "inner build" for each `RuntimeIdentifier`. * Inside our build we force `$(SelfContained)` to `true` no matter what. As there is no such thing as a system-wide .NET on Android. The fix appears to be to default `PublishSelfContained=false` and let our existing logic force `SelfContained=true`. I added a new test for this scenario. Our existing test didn't catch this because it was passing a `RuntimeIdentifier`.
Setting |
Description
After .Net 8 Preview 5 publishing Android App broke.
dotnet publish ./MauiApp1/MauiApp1.csproj -f net8.0-android -c Release
error NETSDK1191: A runtime identifier for the property 'SelfContained' couldn't be inferred
A runtime Identifier cannot be speciified because Android publishes for several Processor Architectures android-arm64 android-arm for example.
Steps to Reproduce
Create new Maui Project select .Net 8.0 (Preview)
Execute on Command line
dotnet publish ./MauiApp1/MauiApp1.csproj -f net8.0-android -c Release
Link to public reproduction project repository
https://github.com/inforithmics/AndroidMauiPublish
Version with bug
8.0.0-preview.5.8529
Last version that worked well
8.0.0-preview.4.8333
Affected platforms
Android
Affected platform versions
Android
Did you find any workaround?
specifying android runtime:
dotnet publish -r android-arm64 ./MauiApp1/MauiApp1.csproj -f net8.0-android -c Release
but this builds only for android-arm64 in .Net 8
dotnet publish ./MauiApp1/MauiApp1.csproj -f net7.0-android -c Release
built in .Net 7 for the other platforms too (android-arm/android-arm64 for example)
Relevant log output
The text was updated successfully, but these errors were encountered: