Android publish: error NETSDK1191: A runtime identifier for the property 'SelfContained' couldn't be inferred

See original GitHub issue

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

  1. Create new Maui Project select .Net 8.0 (Preview)

  2. 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

MSBuild version 17.7.0-preview-23281-03+4ce2ff1f8 for .NET
  Determining projects to restore...
  Restored C:\temp\MauiApp1\MauiApp1\MauiApp1.csproj (in 698 ms).
C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInf
erence.targets(212,5): error NETSDK1191: A runtime identifier for the property 'SelfContained' couldn't be inferred. Sp
ecify a rid explicitly. [C:\temp\MauiApp1\MauiApp1\MauiApp1.csproj::TargetFramework=net8.0-android]

Issue Analytics

  • State:closed
  • Created 3 months ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jonathanpepperscommented, Jun 20, 2023

For now, the workarounds are:

  • Use dotnet build instead
  • Set <PublishSelfContained>false</PublishSelfContained> or <SelfContained>false</SelfContained> in your .csproj, the Android build forces SelfContained=true no matter what.

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.

0reactions
inforithmicscommented, Jun 21, 2023

Setting <SelfContained>false</SelfContained> in the csproj worked - Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

`RuntimeIdentifier` warning if self-contained is unspecified ...
NET SDK defaults the build, publish, and run outputs to be self-contained applications. The default without specifying a RuntimeIdentifier is to ...
Read more >
error NETSDK1031: It is not supported to build or publish a ...
I am able to resolve the issue by adding <RuntimeIdentifier>linux-x64</RuntimeIdentifier> line in .csproj file: <Project Sdk="Microsoft.NET.
Read more >
It is not supported to publish an app without RuntimeIdentifier
Resolution: The issue I found to be not specifying the runtime identifier in the project file or through the publish command.
Read more >
Solved: Publish/Deploy self-contained win-x64 not working
I'm using Esri.ArcGISRuntime.WPF v200.0.0 in a WPF + NET7 application. I am publishing it as self-contained win-x64. Accoring to https ...
Read more >
Should I use self-contained or framework-dependent ...
In this post I compare the impact of the framework-dependent vs self-contained mode on Docker image size, taking layer caching into account.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found