Skip to content

Commit 831cd47

Browse files
fix: failed to write libxamarin-app.so (#4400)
* fix: failed to write libxamarin-app.so Another try at #4091 The theory is that it might be related to the restore operation rather than the build: https://github.com/getsentry/sentry-dotnet/blob/25a2d578cd35766fcccf9e9fbab660d238640fdf/test/Sentry.Android.AssemblyReader.Tests/Sentry.Android.AssemblyReader.Tests.csproj#L19-L26 In CI we run the restore once, separate from the build... so this PR attempts to restore the `AndroidTestApp` in the same way (rather than as a dependency of the `BuildTestAPKs` target). #skip-changelog * Update Sentry.Android.AssemblyReader.Tests.csproj * Add AndroidTestApp to solution (so no special restore operation is required) * Revert "Add AndroidTestApp to solution (so no special restore operation is required)" This reverts commit 7eca52f. * Use Run Target Exactly Once trick... * Update Sentry.Android.AssemblyReader.Tests.csproj * Update test/Sentry.Android.AssemblyReader.Tests/Sentry.Android.AssemblyReader.Tests.csproj
1 parent 618c06a commit 831cd47

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

test/Sentry.Android.AssemblyReader.Tests/Sentry.Android.AssemblyReader.Tests.csproj

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,21 @@
1717
</ItemGroup>
1818

1919
<!-- Target to ensure AndroidTestApp is restored -->
20-
<Target Name="EnsureAndroidTestAppRestored" Condition="'$(TargetPlatformIdentifier)' != 'android' and '$(AndroidTestAppRestored)' != 'true'">
21-
<!-- Only restore once. Spawn as a separate process to escape any "no-restore" arguments to the build -->
20+
<Target Name="EnsureAndroidTestAppRestored"
21+
Condition="!Exists('$(MSBuildProjectDirectory)\..\AndroidTestApp\obj\project.assets.json')">
22+
<Message Importance="high" Text="Restoring AndroidTestApp via MSBuild task..." />
2223
<Exec Command="dotnet restore ../AndroidTestApp/AndroidTestApp.csproj --nologo" />
23-
<PropertyGroup>
24-
<AndroidTestAppRestored>true</AndroidTestAppRestored>
25-
</PropertyGroup>
2624
</Target>
2725

26+
<!-- Restore exactly once: https://learn.microsoft.com/en-gb/visualstudio/msbuild/run-target-exactly-once -->
27+
<Target Name="BuildTestAPKsBeforeOuterBuild" DependsOnTargets="EnsureAndroidTestAppRestored"
28+
Condition="'$(TargetPlatformIdentifier)' != 'android'"
29+
BeforeTargets="DispatchToInnerBuilds" />
30+
2831
<!-- Build the Android test app in various configurations during the build of this test project. -->
29-
<Target Name="BuildTestAPKs" BeforeTargets="DispatchToInnerBuilds;BeforeBuild" DependsOnTargets="EnsureAndroidTestAppRestored" Condition="'$(TargetPlatformIdentifier)' != 'android'">
32+
<Target Name="BuildTestAPKs" BeforeTargets="BeforeBuild" Condition="'$(TargetPlatformIdentifier)' != 'android'">
33+
<!-- Restore exactly once: https://learn.microsoft.com/en-gb/visualstudio/msbuild/run-target-exactly-once -->
34+
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="EnsureAndroidTestAppRestored" RemoveProperties="TargetFramework" />
3035
<MSBuild Projects="$(MSBuildProjectFile)" Targets="_InnerBuildTestAPKs" Properties="TargetFramework=net8.0-android" Condition="$(TargetFramework) == 'net8.0'" />
3136
<MSBuild Projects="$(MSBuildProjectFile)" Targets="_InnerBuildTestAPKs" Properties="TargetFramework=net9.0-android" Condition="$(TargetFramework) == 'net9.0'" />
3237
</Target>

0 commit comments

Comments
 (0)