-
-
Notifications
You must be signed in to change notification settings - Fork 235
Expand file tree
/
Copy pathSentry.Android.AssemblyReader.Tests.csproj
More file actions
72 lines (62 loc) · 4.64 KB
/
Copy pathSentry.Android.AssemblyReader.Tests.csproj
File metadata and controls
72 lines (62 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(LatestTfm);$(PreviousTfm)</TargetFrameworks>
<!-- IMPORTANT: We must test with new TFMs as the store format changes with new versions of .NET -->
<TargetFrameworks Condition="'$(NO_ANDROID)' == ''">$(TargetFrameworks);$(LatestAndroidTfm);$(PreviousAndroidTfm)</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Sentry.Android.AssemblyReader\Sentry.Android.AssemblyReader.csproj" />
<ProjectReference Include="..\Sentry.Testing\Sentry.Testing.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="TestAPKs\" />
</ItemGroup>
<!-- Target to ensure AndroidTestApp is restored -->
<Target Name="EnsureAndroidTestAppRestored"
Condition="!Exists('$(MSBuildProjectDirectory)\..\AndroidTestApp\obj\project.assets.json')">
<Message Importance="high" Text="Restoring AndroidTestApp via MSBuild task..." />
<Exec Command="dotnet restore ../AndroidTestApp/AndroidTestApp.csproj -f --nologo" />
</Target>
<!-- Restore exactly once: https://learn.microsoft.com/en-gb/visualstudio/msbuild/run-target-exactly-once -->
<Target Name="BuildTestAPKsBeforeOuterBuild" DependsOnTargets="EnsureAndroidTestAppRestored"
Condition="'$(TargetPlatformIdentifier)' != 'android'"
BeforeTargets="DispatchToInnerBuilds" />
<!-- Build the Android test app in various configurations during the build of this test project. -->
<Target Name="BuildTestAPKs" BeforeTargets="BeforeBuild" Condition="'$(TargetPlatformIdentifier)' != 'android'">
<!-- Restore exactly once: https://learn.microsoft.com/en-gb/visualstudio/msbuild/run-target-exactly-once -->
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="EnsureAndroidTestAppRestored" RemoveProperties="TargetFramework" />
<MSBuild Projects="$(MSBuildProjectFile)" Targets="_InnerBuildTestAPKs" Properties="TargetFramework=net10.0-android" Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' And '$(TargetFrameworkVersion)' == 'v10.0'" />
<MSBuild Projects="$(MSBuildProjectFile)" Targets="_InnerBuildTestAPKs" Properties="TargetFramework=net9.0-android" Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' And '$(TargetFrameworkVersion)' == 'v9.0'" />
</Target>
<Target Name="_InnerBuildTestAPKs">
<!-- https://learn.microsoft.com/visualstudio/msbuild/msbuild-batching -->
<ItemGroup>
<_TestAPK Include="1" Properties="_Aot=False;_Store=False;_Compressed=False" />
<_TestAPK Include="2" Properties="_Aot=False;_Store=False;_Compressed=True" />
<_TestAPK Include="3" Properties="_Aot=False;_Store=True;_Compressed=False" />
<_TestAPK Include="4" Properties="_Aot=False;_Store=True;_Compressed=True" />
<_TestAPK Include="5" Properties="_Aot=True;_Store=False;_Compressed=False" />
<_TestAPK Include="6" Properties="_Aot=True;_Store=False;_Compressed=True" />
<_TestAPK Include="7" Properties="_Aot=True;_Store=True;_Compressed=False" />
<_TestAPK Include="8" Properties="_Aot=True;_Store=True;_Compressed=True" />
</ItemGroup>
<MSBuild Projects="$(MSBuildProjectFile)" Targets="_BuildTestAPK" Properties="%(_TestAPK.Properties)" BuildInParallel="false" />
</Target>
<Target Name="_BuildTestAPK">
<PropertyGroup>
<_ConfigString>A=$(_Aot)-S=$(_Store)-C=$(_Compressed)</_ConfigString>
<SourceAPK>..\AndroidTestApp\bin\$(TargetFramework)\$(_ConfigString)\com.companyname.AndroidTestApp-Signed.apk</SourceAPK>
<DestinationAPK>TestAPKs\$(TargetFramework)-$(_ConfigString).apk</DestinationAPK>
</PropertyGroup>
<!-- Note we use RunAOTCompilation rather than PublishAot here - full NativeAOT compilation on Android is still experimental -->
<MSBuild Projects="..\AndroidTestApp\AndroidTestApp.csproj" Targets="Build" Properties="Configuration=Release;RunAOTCompilation=$(_Aot);UseNativeAot=false;_IsPublishing=true;AndroidUseAssemblyStore=$(_Store);AndroidEnableAssemblyCompression=$(_Compressed);OutDir=bin\$(TargetFramework)\$(_ConfigString)\" Condition="!Exists('$(DestinationAPK)')" />
<Message Text="Copying APK from $(SourceAPK) to $(DestinationAPK)" Importance="high" />
<Copy SourceFiles="$(SourceAPK)" DestinationFiles="$(DestinationAPK)" Condition="!Exists('$(DestinationAPK)')" />
<PropertyGroup>
<DestinationAPKExists Condition="Exists('$(DestinationAPK)')">True</DestinationAPKExists>
<DestinationAPKExists Condition="!Exists('$(DestinationAPK)')">False</DestinationAPKExists>
</PropertyGroup>
<Message Text="APK copy result: Exists('$(DestinationAPK)') = $(DestinationAPKExists)" Importance="high" />
</Target>
</Project>