dotnet / dotnet/android

NETSDK1112 when targeting .NET 9 from .NET 10 and specifying a non-downloaded rid

Open
#10,423 2 comments 0 reactions 0 assignees View on GitHub
Area: App+Library Build
Dominant language
C#
Stars
2.1k
Forks
579
Avg merge
1d 19h
Merged PRs (30d)
252

Description

### Android framework version

net9.0-android

### Affected platform version

.NET 10 Preview 7

### Description

This looks like it'll be a weird one…

**Setup**: assume a "clean machine". Specifically, that you don't have the `microsoft.android.runtime.35.android-arm64` NuGet packages downloaded:

```sh
rm -Rf $HOME/.nuget/packages/microsoft.android.runtime.35.android-arm64
```

Using .NET 10 Preview 7, create a new Android app template:

```dotnetcli
dotnet new android -n net10-android-netsdk1112
```

*Edit* `net10-android-netsdk1112/net10-android-netsdk1112.csproj` so that `$(TargetFramework)` is *net9.0*:

```diff
diff --git a/net10-android-netsdk1112.csproj b/net10-android-netsdk1112.csproj
index 7e6b48f..1c88b86 100644
--- a/net10-android-netsdk1112.csproj
+++ b/net10-android-netsdk1112.csproj
@@ -1,6 +1,6 @@


- net10.0-android
+ net9.0-android^M
24
net10_android_netsdk1112
Exe
```

Build the project, specifying a rid:

```dotnetcli
dotnet build -r android-arm64
```

It *fails*:

```
info NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
net10-android-netsdk1112 failed with 1 error(s) (0.0s)
$HOME/Downloads/dotnet-sdk-10.0.100-preview.7.25380.108-osx-x64/sdk/10.0.100-preview.7.25380.108/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(528,5): error NETSDK1112: The runtime pack for Microsoft.Android.Runtime.35.android-arm64 was not downloaded. Try running a NuGet restore with the RuntimeIdentifier 'android-arm64'.
net10-android-netsdk1112 failed (4.1s) → bin/Debug/net9.0-android/android-arm64/net10-android-netsdk1112.dll
```

Interestingly, the NETSDK1112 only happens when (1) using .NET 10 to build a .NET 9 project *and* (2) specifying a rid.

If you *don't* specify the rid, it builds:

```dotnetcli
dotnet build
```

After which `$HOME/.nuget/packages/microsoft.android.runtime.35.android-arm64` *exists*, and thus after which specifying a rid *will* work:

```dotnetcli
dotnet build -r android-arm64
```

which means that to fully reproduce this you *must* nuke `$HOME/.nuget/packages/microsoft.android.runtime.35.android-arm64`.

Alternatively, it works if you use the .NET 9 SDK to build.

```dotnetcli
rm -Rf $HOME/.nuget/packages/microsoft.android.runtime.35.android-arm64
dotnet build -r android-arm64
# works if .NET 9 is used
```

### Steps to Reproduce

-

### Did you find any workaround?

Either use the .NET 9 SDK, *or* perform a "non-rid build" *before* performing a rid build.

### Relevant log output

```shell

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.