Skip to content

Known issues in .NET

Jonathan Peppers edited this page Feb 21, 2023 · 22 revisions

.NET 8 Preview 1 does not yet support win-arm64

Some of the changes that enable win-arm64 are in .NET 7, but did not make it appropriately to .NET 8 Preview 1. This should be addressed in a future preview.

.NET 8 Preview 1: mono-aot-cross is not executable

On macOS, if you encounter a build error related to mono-aot-cross:

An error occurred trying to start process '/usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.maccatalyst-x64/8.0.0-preview.1.23106.5/Sdk/../tools/mono-aot-cross'. Permission denied

You can workaround the issue, by making the file executable:

sudo chmod +x /usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.*/8.0.0-preview.1.*/tools/mono-aot-cross

This is tracked in dotnet/runtime#82201.

Specifying both -f and -r to dotnet build fails to restore for multi-targeted projects

This will manifest as a build error like this:

error : The RuntimeIdentifier 'android-arm64' is invalid.

The cause is that by passing -r <runtime identifier> to 'dotnet build' that runtime identifier is used for all target frameworks in the project file when the project is restored, while it's only a valid runtime identifier for one of the target frameworks.

Potential workaround is to restore manually, and build without restoring:

$ dotnet restore
$ dotnet build --no-restore -f net6.0-android -r android-arm64

This happens with dotnet publish as well.

This will be fixed in a future version of NuGet.

Ref: https://github.com/dotnet/sdk/issues/21877.
Ref: https://github.com/NuGet/Home/issues/11653.

dotnet pack and .aar files

In some cases .aar files are not packaged correctly for .nupkg output of Android class libraries.

For example:

  1. dotnet new androidlib
  2. Add MyAndroidLibrary.aar file
  3. dotnet pack
  4. lib\net6.0-android31.0\MyAndroidLibrary.aar is missing from the .nupkg

To workaround this issue, add the following to your .csproj file:

<ItemGroup>
  <AndroidLibrary Update="**\*.aar" Pack="false" />
  <None Update="**\*.aar" Pack="true" PackagePath="lib\$(TargetFramework)$(TargetPlatformVersion)" />
</ItemGroup>

Ref: https://github.com/xamarin/xamarin-android/issues/7040.
Ref: https://github.com/xamarin/xamarin-android/pull/7045.

Clone this wiki locally