Skip to content

Commit 8ea1708

Browse files
[One .NET] specify all RIDs by default
Fixes: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1413756 Fixes: #6353 The API 31 emulator no longer has 32-bit images and the x86_64 image has dropped support for 32-bit architectures: > adb shell getprop | grep cpu [ro.product.cpu.abi]: [x86_64] [ro.product.cpu.abilist]: [x86_64,arm64-v8a] [ro.product.cpu.abilist32]: [] [ro.product.cpu.abilist64]: [x86_64,arm64-v8a] Compared to an API 30 x86_64 emulator: > adb shell getprop | grep cpu [ro.product.cpu.abi]: [x86_64] [ro.product.cpu.abilist]: [x86_64,x86,arm64-v8a,armeabi-v7a,armeabi] [ro.product.cpu.abilist32]: [x86,armeabi-v7a,armeabi] [ro.product.cpu.abilist64]: [x86_64,arm64-v8a] The problem is our default RIDs are: <RuntimeIdentifiers Condition=" '$(RuntimeIdentifier)' == '' And '$(RuntimeIdentifiers)' == '' ">android-arm64;android-x86</RuntimeIdentifiers> And so you hit this error when trying to deploy a `dotnet new android` app on an API 31 x86_64 emulator: error ADB0020: Mono.AndroidTools.IncompatibleCpuAbiExceptiopn: The package does not support the CPU architecture of this device. To workaround this, you can add `android-x64` to your list of `$(RuntimeIdentifiers)`. To solve this issue, we can default `$(RuntimeIdentifiers)` to all 4 architectures. We have code that will select a single architecture for Debug builds using "Fast Deployment". It seems better to have a default here that will always work, and the only drawback would be the additional architectures for Release builds. After this change, I discovered an issue introduced in 33a6d1e: ILLink error IL1012: IL Linker has encountered an unexpected error. Please report the issue at https://github.com/mono/linker/issues [C:\a\_work\1\s\bin\TestRelease\temp\BuildProguard Enabled Project(1)Trued8r8\UnnamedProject.csproj] ... Unhandled exception. System.IO.IOException: The process cannot access the file 'C:\a\_work\1\s\bin\TestRelease\temp\BuildProguard Enabled Project(1)Trued8r8\obj\Release\proguard\proguard_project_references.cfg' because it is being used by another process. When we build each RID in parallel, each inner build was attempting to write to the same file. I changed the path for this file to be: $(IntermediateOutputPath)%(_RIDs.Identity)\proguard\proguard_project_references.cfg And then set `$(_ProguardProjectConfiguration)` appropriately after the inner builds complete. This also needs to actually be a file path, I don't see how the value was working before: <_ProguardProjectConfiguration Condition=" '$(AndroidLinkTool)' != '' ">;_ProguardProjectConfiguration=$(IntermediateOutputPath)proguard\proguard_project_references.cfg</_ProguardProjectConfiguration> Then another related issue: (_TouchAndroidLinkFlag target) -> Microsoft.Android.Sdk.ILLink.targets(114,5): error MSB3371: The file "obj\Release\net6.0-android\link.flag" cannot be created. The process cannot access the file 'C:\a\_work\2\s\bin\TestRelease\temp\DotNetBuildandroid-armandroid-arm64android-x86android-x64TrueTrue\obj\Release\net6.0-android\link.flag' because it is being used by another process. I setup `$(_AndroidLinkFlag)` the same as `$(_ProguardProjectConfiguration)` to solve this issue.
1 parent 8866030 commit 8ea1708

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AssemblyResolution.targets

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ _ResolveAssemblies MSBuild target.
2828
<OutputPath Condition=" '$(_OuterOutputPath)' != '' ">$(_OuterOutputPath)</OutputPath>
2929
<OutDir Condition=" '$(_OuterOutputPath)' != '' ">$(_OuterOutputPath)</OutDir>
3030
<PublishDir>$(OutputPath)</PublishDir>
31-
<_AndroidLinkFlag>$(_OuterIntermediateOutputPath)link.flag</_AndroidLinkFlag>
3231
<BuildDependsOn>_RemoveLegacyDesigner;$(BuildDependsOn)</BuildDependsOn>
3332
<!-- We don't want IncrementalClean to run here, or files get deleted -->
3433
<CoreBuildDependsOn>
@@ -69,15 +68,13 @@ _ResolveAssemblies MSBuild target.
6968
<_RIDs Include="$(RuntimeIdentifiers)" Condition=" '$(RuntimeIdentifiers)' != '' " />
7069
</ItemGroup>
7170
<PropertyGroup>
72-
<_ProguardProjectConfiguration Condition=" '$(AndroidLinkTool)' != '' ">;_ProguardProjectConfiguration=$(IntermediateOutputPath)proguard\proguard_project_references.cfg</_ProguardProjectConfiguration>
7371
<_AdditionalProperties>
7472
_ComputeFilesToPublishForRuntimeIdentifiers=true
7573
;AppendRuntimeIdentifierToOutputPath=true
7674
;SkipCompilerExecution=true
7775
;_OuterIntermediateAssembly=@(IntermediateAssembly)
7876
;_OuterOutputPath=$(OutputPath)
7977
;_OuterIntermediateOutputPath=$(IntermediateOutputPath)
80-
$(_ProguardProjectConfiguration)
8178
</_AdditionalProperties>
8279
<_AndroidBuildRuntimeIdentifiersInParallel Condition=" '$(_AndroidBuildRuntimeIdentifiersInParallel)' == '' ">true</_AndroidBuildRuntimeIdentifiersInParallel>
8380
</PropertyGroup>
@@ -90,6 +87,12 @@ _ResolveAssemblies MSBuild target.
9087
Targets="_ComputeFilesToPublishForRuntimeIdentifiers">
9188
<Output TaskParameter="TargetOutputs" ItemName="ResolvedFileToPublish" />
9289
</MSBuild>
90+
<!-- Properties produced by the inner build in Microsoft.Android.Sdk.ILLink.targets -->
91+
<PropertyGroup>
92+
<_InnerIntermediateOutputPath>$(IntermediateOutputPath)%(_RIDs.Identity)\</_InnerIntermediateOutputPath>
93+
<_ProguardProjectConfiguration Condition=" '$(AndroidLinkTool)' != '' ">$(_InnerIntermediateOutputPath)proguard\proguard_project_references.cfg</_ProguardProjectConfiguration>
94+
<_AndroidLinkFlag>$(_InnerIntermediateOutputPath)link.flag</_AndroidLinkFlag>
95+
</PropertyGroup>
9396
<ItemGroup>
9497
<_ResolvedAssemblyFiles Include="@(ResolvedFileToPublish)" Condition=" '%(ResolvedFileToPublish.Extension)' == '.dll' " />
9598
<_ResolvedSymbolFiles Include="@(ResolvedFileToPublish)" Condition=" '%(ResolvedFileToPublish.Extension)' == '.pdb' " />

src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<TrimmerDefaultAction Condition=" '$(TrimmerDefaultAction)' == '' and '$(AndroidLinkMode)' == 'Full' ">link</TrimmerDefaultAction>
6767
<SuppressTrimAnalysisWarnings Condition=" '$(SuppressTrimAnalysisWarnings)' == '' ">true</SuppressTrimAnalysisWarnings>
6868
<!-- Prefer $(RuntimeIdentifiers) plural -->
69-
<RuntimeIdentifiers Condition=" '$(RuntimeIdentifier)' == '' And '$(RuntimeIdentifiers)' == '' ">android-arm64;android-x86</RuntimeIdentifiers>
69+
<RuntimeIdentifiers Condition=" '$(RuntimeIdentifier)' == '' And '$(RuntimeIdentifiers)' == '' ">android-arm;android-arm64;android-x86;android-x64</RuntimeIdentifiers>
7070
<RuntimeIdentifier Condition=" '$(RuntimeIdentifiers)' != '' And '$(RuntimeIdentifier)' != '' " />
7171
<AndroidManifest Condition=" '$(AndroidManifest)' == '' and Exists ('Properties\AndroidManifest.xml') and !Exists ('AndroidManifest.xml') ">Properties\AndroidManifest.xml</AndroidManifest>
7272
<AndroidManifest Condition=" '$(AndroidManifest)' == '' ">AndroidManifest.xml</AndroidManifest>

src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.ILLink.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ This file contains the .NET 5-specific targets to customize ILLink
2020
-->
2121
<_TrimmerDumpDependencies Condition=" '$(LinkerDumpDependencies)' == 'true' ">true</_TrimmerDumpDependencies>
2222
<_AndroidLinkerCustomStepAssembly>$(MSBuildThisFileDirectory)..\tools\Microsoft.Android.Sdk.ILLink.dll</_AndroidLinkerCustomStepAssembly>
23+
<_ProguardProjectConfiguration Condition=" '$(AndroidLinkTool)' != '' ">$(IntermediateOutputPath)proguard\proguard_project_references.cfg</_ProguardProjectConfiguration>
2324
</PropertyGroup>
2425
<ItemGroup>
2526
<RuntimeHostConfigurationOption Include="Android.Runtime.AndroidEnvironment.VSAndroidDesignerIsEnabled"

0 commit comments

Comments
 (0)