Skip to content

Conversation

@jonathanpeppers
Copy link
Member

Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=4422361&view=ms.vss-test-web.build-test-results-tab&runId=18547936&resultId=100086&paneView=debug

We had an MSBuild test failing under .NET 6:

MSBuildDeviceIntegration On Device - macOS - One .NET > SwitchConfigurationsShouldRedeploy
fastdev directory should NOT exist for Release builds.
Expected string length 0 but was 4970. Strings differ at index 0.
Expected: <string.Empty>
But was:  "Java.Interop.dll\nMicrosoft.CSharp.dll\nMicrosoft.VisualBasic.C..."

This was because a supposed Release build was skipping the _Upload
target completely:

Skipping target "_Upload" because all output files are up-to-date with respect to the input files.
Input files: bin\Debug\UnnamedProject.UnnamedProject-Signed.apk...

It appears that toggling XamarinProject.IsRelease is not triggering
the correct files to save when the tests run under .NET 6.

Under "legacy" Xamarin.Android, the tests simply put this at the top
of the .csproj:

  <Configuration>Debug</Configuration>
...
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />

This won't work in short-form MSBuild projects, because the .csproj
is effectively:

<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />
...
  <Configuration>Debug</Configuration>
...
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />

For things to work properly, we need $(Configuration) to be set
before Microsoft.NET.Sdk/Sdk.props.

So we put $(Configuration) in a Directory.Build.props to solve
this ordering problem. Unfortunately, we were not calling Touch() on
this file when XamarinProject.IsRelease changes.

After making this change, SwitchConfigurationsShouldRedeploy passes.

Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=4422361&view=ms.vss-test-web.build-test-results-tab&runId=18547936&resultId=100086&paneView=debug

We had an MSBuild test failing under .NET 6:

    MSBuildDeviceIntegration On Device - macOS - One .NET > SwitchConfigurationsShouldRedeploy
    fastdev directory should NOT exist for Release builds.
    Expected string length 0 but was 4970. Strings differ at index 0.
    Expected: <string.Empty>
    But was:  "Java.Interop.dll\nMicrosoft.CSharp.dll\nMicrosoft.VisualBasic.C..."

This was because a supposed `Release` build was skipping the `_Upload`
target completely:

    Skipping target "_Upload" because all output files are up-to-date with respect to the input files.
    Input files: bin\Debug\UnnamedProject.UnnamedProject-Signed.apk...

It appears that toggling `XamarinProject.IsRelease` is not triggering
the correct files to save when the tests run under .NET 6.

Under "legacy" Xamarin.Android, the tests simply put this at the top
of the `.csproj`:

      <Configuration>Debug</Configuration>
    ...
    <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />

This won't work in short-form MSBuild projects, because the `.csproj`
is effectively:

    <Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />
    ...
      <Configuration>Debug</Configuration>
    ...
    <Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />

For things to work properly, we need `$(Configuration)` to be set
*before* `Microsoft.NET.Sdk/Sdk.props`.

So we put `$(Configuration)` in a `Directory.Build.props` to solve
this ordering problem. Unfortunately, we were not calling `Touch()` on
this file when `XamarinProject.IsRelease` changes.

After making this change, `SwitchConfigurationsShouldRedeploy` passes.
@jonathanpeppers jonathanpeppers marked this pull request as ready for review January 30, 2021 00:50
@dellis1972
Copy link
Contributor

Failing test is ApplicationRunsWithoutDebugger. The problem is it can't load libmonosgen.

Adding native library: obj/Debug/app_shared_libraries/x86/libxamarin-app.so (APK path: lib/x86/libxamarin-app.so) (TaskId:319)
                     	Adding /Users/runner/.nuget/packages/microsoft.netcore.app.runtime.android-arm64/6.0.0-alpha.1.21063.13/runtimes/android-arm64/native/libSystem.IO.Compression.Native.so (TaskId:319)
                     	Adding /Users/runner/.nuget/packages/microsoft.netcore.app.runtime.android-arm64/6.0.0-alpha.1.21063.13/runtimes/android-arm64/native/libSystem.Native.so (TaskId:319)
                     	Adding /Users/runner/.nuget/packages/microsoft.netcore.app.runtime.android-arm64/6.0.0-alpha.1.21063.13/runtimes/android-arm64/native/libSystem.Security.Cryptography.Native.OpenSsl.so (TaskId:319)
                     	Adding /Users/runner/.nuget/packages/microsoft.netcore.app.runtime.android-arm64/6.0.0-alpha.1.21063.13/runtimes/android-arm64/native/libmonosgen-2.0.so (TaskId:319)
                     	Adding /Users/runner/.nuget/packages/microsoft.android.runtime.android.21-arm64/11.0.200-ci.pr.gh5571.65/runtimes/android.21-arm64/native/libmono-android.debug.so (TaskId:319)
                     	Adding /Users/runner/.nuget/packages/microsoft.android.runtime.android.21-arm64/11.0.200-ci.pr.gh5571.65/runtimes/android.21-arm64/native/libxa-internal-api.so (TaskId:319)
                     	Adding /Users/runner/.nuget/packages/microsoft.android.runtime.android.21-arm64/11.0.200-ci.pr.gh5571.65/runtimes/android.21-arm64/native/libxamarin-debug-app-helper.so (TaskId:319)
                     	Adding /Users/runner/.nuget/packages/microsoft.netcore.app.runtime.android-x86/6.0.0-alpha.1.21063.13/runtimes/android-x86/native/libSystem.IO.Compression.Native.so (TaskId:319)
                     	Adding /Users/runner/.nuget/packages/microsoft.netcore.app.runtime.android-x86/6.0.0-alpha.1.21063.13/runtimes/android-x86/native/libSystem.Native.so (TaskId:319)
                     	Adding /Users/runner/.nuget/packages/microsoft.netcore.app.runtime.android-x86/6.0.0-alpha.1.21063.13/runtimes/android-x86/native/libSystem.Security.Cryptography.Native.OpenSsl.so (TaskId:319)
                     	Adding /Users/runner/.nuget/packages/microsoft.netcore.app.runtime.android-x86/6.0.0-alpha.1.21063.13/runtimes/android-x86/native/libmonosgen-2.0.so (TaskId:319)
                     	Adding /Users/runner/.nuget/packages/microsoft.android.runtime.android.21-x86/11.0.200-ci.pr.gh5571.65/runtimes/android.21-x86/native/libmono-android.debug.so (TaskId:319)
                     	Adding /Users/runner/.nuget/packages/microsoft.android.runtime.android.21-x86/11.0.200-ci.pr.gh5571.65/runtimes/android.21-x86/native/libxa-internal-api.so (TaskId:319)
                     	Adding /Users/runner/.nuget/packages/microsoft.android.runtime.android.21-x86/11.0.200-ci.pr.gh5571.65/runtimes/android.21-x86/native/libxamarin-debug-app-helper.so (TaskId:319)

The logcat

01-29 23:02:01.125  7141  7141 D debug-app-helper: Checking if libmonodroid was unpacked to /data/app/UnnamedProject.UnnamedProject-q6zCXZc0nRS0o6rFizN_Jw==/lib/x86/libmonodroid.so
01-29 23:02:01.125  7141  7141 D debug-app-helper: /data/app/UnnamedProject.UnnamedProject-q6zCXZc0nRS0o6rFizN_Jw==/lib/x86/libmonodroid.so not found, assuming application/android:extractNativeLibs == false
01-29 23:02:01.125  7141  7141 I debug-app-helper: Setting up for DSO lookup directly in the APK
01-29 23:02:01.125  7141  7141 D debug-app-helper: Added APK DSO lookup location: /data/app/UnnamedProject.UnnamedProject-q6zCXZc0nRS0o6rFizN_Jw==/base.apk!/lib/x86
01-29 23:02:01.125  7141  7141 W debug-app-helper: Using runtime path: /data/app/UnnamedProject.UnnamedProject-q6zCXZc0nRS0o6rFizN_Jw==/lib/x86
01-29 23:02:01.125  7141  7141 W debug-app-helper: checking directory: `/data/user/0/UnnamedProject.UnnamedProject/files/.__override__/lib`
01-29 23:02:01.125  7141  7141 W debug-app-helper: directory does not exist: `/data/user/0/UnnamedProject.UnnamedProject/files/.__override__/lib`
01-29 23:02:01.125  7141  7141 W debug-app-helper: Trying to load sgen from: /data/app/UnnamedProject.UnnamedProject-q6zCXZc0nRS0o6rFizN_Jw==/lib/x86/libmonosgen-32bit-2.0.so
01-29 23:02:01.125  7141  7141 W debug-app-helper: Checking whether Mono runtime exists at: /system/lib/libmonosgen-2.0.so
01-29 23:02:01.125  7141  7141 F debug-app-helper: Cannot find 'libmonosgen-2.0.so'. Looked in the following locations:
01-29 23:02:01.125  7141  7141 F debug-app-helper:   /data/app/UnnamedProject.UnnamedProject-q6zCXZc0nRS0o6rFizN_Jw==/base.apk!/lib/x86
01-29 23:02:01.125  7141  7141 F debug-app-helper: Do you have a shared runtime build of your app with AndroidManifest.xml android:minSdkVersion < 10 while running on a 64-bit Android 5.0 target? This combination is not supported.
01-29 23:02:01.126  7141  7141 F debug-app-helper: Please either set android:minSdkVersion >= 10 or use a build without the shared runtime (like default Release configuration).

This fails on both Legacy and One. net. So I assume its not related. So I will merge this one

@dellis1972 dellis1972 merged commit 4bf39c3 into dotnet:master Feb 1, 2021
@grendello
Copy link
Contributor

To keep the link here for future reference. This may help in debugging dlopen behavior on Android O and newer: https://android.googlesource.com/platform/bionic/+/master/android-changes-for-ndk-developers.md#enable-logging-of-dlopen_dlsym-and-library-loading-errors-for-apps-available-in-android-o

@jonathanpeppers jonathanpeppers deleted the dotnet-tests-isrelease branch February 1, 2021 14:10
jonpryor pushed a commit to jonpryor/xamarin-android that referenced this pull request Mar 30, 2021
…5571)

Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=4422361&view=ms.vss-test-web.build-test-results-tab&runId=18547936&resultId=100086&paneView=debug

We had an MSBuild test failing under .NET 6:

    MSBuildDeviceIntegration On Device - macOS - One .NET > SwitchConfigurationsShouldRedeploy
    fastdev directory should NOT exist for Release builds.
    Expected string length 0 but was 4970. Strings differ at index 0.
    Expected: <string.Empty>
    But was:  "Java.Interop.dll\nMicrosoft.CSharp.dll\nMicrosoft.VisualBasic.C..."

This was because a supposed `Release` build was skipping the `_Upload`
target completely:

    Skipping target "_Upload" because all output files are up-to-date with respect to the input files.
    Input files: bin\Debug\UnnamedProject.UnnamedProject-Signed.apk...

It appears that toggling `XamarinProject.IsRelease` is not triggering
the correct files to save when the tests run under .NET 6.

Under "legacy" Xamarin.Android, the tests simply put this at the top
of the `.csproj`:

      <Configuration>Debug</Configuration>
    ...
    <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />

This won't work in short-form MSBuild projects, because the `.csproj`
is effectively:

    <Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />
    ...
      <Configuration>Debug</Configuration>
    ...
    <Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />

For things to work properly, we need `$(Configuration)` to be set
*before* `Microsoft.NET.Sdk/Sdk.props`.

So we put `$(Configuration)` in a `Directory.Build.props` to solve
this ordering problem. Unfortunately, we were not calling `Touch()` on
this file when `XamarinProject.IsRelease` changes.

After making this change, `SwitchConfigurationsShouldRedeploy` passes.
jonpryor pushed a commit that referenced this pull request Mar 30, 2021
Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=4422361&view=ms.vss-test-web.build-test-results-tab&runId=18547936&resultId=100086&paneView=debug

We had an MSBuild test failing under .NET 6:

    MSBuildDeviceIntegration On Device - macOS - One .NET > SwitchConfigurationsShouldRedeploy
    fastdev directory should NOT exist for Release builds.
    Expected string length 0 but was 4970. Strings differ at index 0.
    Expected: <string.Empty>
    But was:  "Java.Interop.dll\nMicrosoft.CSharp.dll\nMicrosoft.VisualBasic.C..."

This was because a supposed `Release` build was skipping the `_Upload`
target completely:

    Skipping target "_Upload" because all output files are up-to-date with respect to the input files.
    Input files: bin\Debug\UnnamedProject.UnnamedProject-Signed.apk...

It appears that toggling `XamarinProject.IsRelease` is not triggering
the correct files to save when the tests run under .NET 6.

Under "legacy" Xamarin.Android, the tests simply put this at the top
of the `.csproj`:

      <Configuration>Debug</Configuration>
    ...
    <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />

This won't work in short-form MSBuild projects, because the `.csproj`
is effectively:

    <Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />
    ...
      <Configuration>Debug</Configuration>
    ...
    <Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />

For things to work properly, we need `$(Configuration)` to be set
*before* `Microsoft.NET.Sdk/Sdk.props`.

So we put `$(Configuration)` in a `Directory.Build.props` to solve
this ordering problem. Unfortunately, we were not calling `Touch()` on
this file when `XamarinProject.IsRelease` changes.

After making this change, `SwitchConfigurationsShouldRedeploy` passes.
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants