Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NETSDK1139: The target platform identifier android was not recognized on windows-2022 image version 20241113.3.0 #3578

Open
jamescrosswell opened this issue Nov 18, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@jamescrosswell
Copy link

jamescrosswell commented Nov 18, 2024

Describe the bug

We started getting this error when running dotnet restore on our Windows runners for any projects targeting net8.0-android 2 days ago:

C:\Program Files\dotnet\sdk\8.0.404\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(117,5): error NETSDK1139: The target platform identifier android was not recognized. [D:\a\sentry-dotnet\sentry-dotnet\src\Sentry\Sentry.csproj::TargetFramework=net8.0-android]

To Reproduce

We don't consistently get this error for the same commit. For example in this build run you can see that in Attempt 1, dotnet restore succeeded. However dotnet restore failed a second attempt on exactly the same commit.

As @bdach pointed out, the difference appears to be in the specific image version:

Successful Run Failed Run
Runner image version 20241021.1.0 20241113.3.0

Expected behavior

I'd expect the build runs to be deterministic. If we run the same GitHub Actions workflow with the same commit on the same runner, we should get the same result.

.NET 8 is definitely installed on the runner as are the maui workloads. So the error itself seems erroneous and misleading.

Runner Version and Platform

windows-latest version: '2.320.0'`

What's not working?

Here's an example of a run that (would have) succeeded... you can see the Restore .NET dependencies step has succeeded. This just runs dotnet restore against our solution (which has some projects that target net8.0-android).

image

After I saw that step had succeeded, I cancelled the run and tried again. Here's a retry of exactly the same commit that failed:

image

And here's a small sample of the log output for that step on the failed attempt:

Run dotnet restore Sentry-CI-Build-Windows.slnf --nologo
  dotnet restore Sentry-CI-Build-Windows.slnf --nologo
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
  env:
    XCODE_VERSION: 16
    DOTNET_CLI_TELEMETRY_OPTOUT: 1
    DOTNET_NOLOGO: 1
    JAVA_HOME: C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.[2](https://github.com/getsentry/sentry-dotnet/actions/runs/11883719343/job/33112101638#step:11:2)5-9\x64
    JAVA_HOME_17_X64: C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\17.0.1[3](https://github.com/getsentry/sentry-dotnet/actions/runs/11883719343/job/33112101638#step:11:3)-11\x64
    ANDROID_HOME: C:\Android\android-sdk
    ANDROID_SDK_ROOT: C:\Android\android-sdk
    JAVA_HOME_11_X6[4](https://github.com/getsentry/sentry-dotnet/actions/runs/11883719343/job/33112101638#step:11:4): C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.2[5](https://github.com/getsentry/sentry-dotnet/actions/runs/11883719343/job/33112101638#step:11:5)-9\x64
    DOTNET_ROOT: C:\Program Files\dotnet
    JAVA_HOME_11: C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.25-9\x[6](https://github.com/getsentry/sentry-dotnet/actions/runs/11883719343/job/33112101638#step:11:6)4
  Determining projects to restore...
  Downloading from "https://downloads.sentry-cdn.com/sentry-cli/2.38.2/sentry-cli-Windows-x86_64.exe" to "D:\a\sentry-dotnet\sentry-dotnet\tools\sentry-cli\2.38.2\sentry-cli-Windows-x86_64.exe" (8[7](https://github.com/getsentry/sentry-dotnet/actions/runs/11883719343/job/33112101638#step:11:7)79264 bytes).
  Downloading from "https://repo1.maven.org/maven2/io/sentry/sentry-android-core/7.17.0/sentry-android-core-7.17.0.aar" to "D:\a\sentry-dotnet\sentry-dotnet\src\Sentry.Bindings.Android\obj\sdks\Sentry\Android\7.17.0\sentry-android-core-7.17.0.aar" (279716 bytes).
  Downloading from "https://repo1.maven.org/maven2/io/sentry/sentry-android-ndk/7.17.0/sentry-android-ndk-7.17.0.aar" to "D:\a\sentry-dotnet\sentry-dotnet\src\Sentry.Bindings.Android\obj\sdks\Sentry\Android\7.17.0\sentry-android-ndk-7.17.0.aar" (1632731 bytes).
  Downloading from "https://repo1.maven.org/maven2/io/sentry/sentry-android-replay/7.17.0/sentry-android-replay-7.17.0.aar" to "D:\a\sentry-dotnet\sentry-dotnet\src\Sentry.Bindings.Android\obj\sdks\Sentry\Android\7.17.0\sentry-android-replay-7.17.0.aar" (253397 bytes).
  Downloading from "https://repo1.maven.org/maven2/io/sentry/sentry/7.17.0/sentry-7.17.0.jar" to "D:\a\sentry-dotnet\sentry-dotnet\src\Sentry.Bindings.Android\obj\sdks\Sentry\Android\7.17.0\sentry-7.17.0.jar" (924646 bytes).
Error: C:\Program Files\dotnet\sdk\[8](https://github.com/getsentry/sentry-dotnet/actions/runs/11883719343/job/33112101638#step:11:8).0.404\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(117,5): error NETSDK113[9](https://github.com/getsentry/sentry-dotnet/actions/runs/11883719343/job/33112101638#step:11:9): The target platform identifier android was not recognized. [D:\a\sentry-dotnet\sentry-dotnet\samples\Sentry.Samples.Maui\Sentry.Samples.Maui.csproj::TargetFramework=net8.0-android]
Error: C:\Program Files\dotnet\sdk\8.0.404\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets([11](https://github.com/getsentry/sentry-dotnet/actions/runs/11883719343/job/33112101638#step:11:11)7,5): error NETSDK1139: The target platform identifier android was not recognized. [D:\a\sentry-dotnet\sentry-dotnet\test\Sentry.Testing\Sentry.Testing.csproj::TargetFramework=net8.0-android]
Error: C:\Program Files\dotnet\sdk\8.0.404\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(117,5): error NETSDK1[13](https://github.com/getsentry/sentry-dotnet/actions/runs/11883719343/job/33112101638#step:11:13)9: The target platform identifier android was not recognized. [D:\a\sentry-dotnet\sentry-dotnet\src\Sentry.Maui\Sentry.Maui.csproj::TargetFramework=net8.0-android]
Error: C:\Program Files\dotnet\sdk\8.0.404\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(1[17](https://github.com/getsentry/sentry-dotnet/actions/runs/11883719343/job/33112101638#step:11:18),5): error NETSDK1139: The target platform identifier android was not recognized. [D:\a\sentry-dotnet\sentry-dotnet\src\Sentry\Sentry.csproj::TargetFramework=net8.0-android]
@bdach
Copy link

bdach commented Nov 18, 2024

For example in this build run you can see that in Attempt 1, dotnet restore succeeded. I assumed at that point that the most recent change I had made was significant. This turned out to be false - dotnet restore failed a second attempt on exactly the same commit.

For reference, the difference between the two seems to be the "runner image" specifically. The fail happened on 20241113.3.0, while the pass happened on 20241021.1.0.

This is visible both in the "setup job" step after you expand the "Runner Image" subhead, or when viewing the raw logs.

See also: actions/runner-images#10978

@jamescrosswell jamescrosswell changed the title Intermittent error on windows-latest runner: NETSDK1139: The target platform identifier android was not recognized NETSDK1139: The target platform identifier android was not recognized on windows-2022 image version 20241113.3.0 Nov 18, 2024
@jamescrosswell
Copy link
Author

For reference, the difference between the two seems to be the "runner image" specifically. The fail happened on 20241113.3.0, while the pass happened on 20241021.1.0.

Awesome, thanks @bdach - I didn't spot that. That at least gives me a path to explore.

As is pointed out in the other issue you referenced, it's a bit frustrating that the runners aren't versioned and we can't pin a specific version to ensure deterministic builds. Ideally I'd like every change in the build system to be reflected by a corresponding change in our repository. The runners themselves seem to change frequently and in major ways however, so sometimes things work and sometimes things break, without our having made any changes.

@albyrock87
Copy link

Does anyone have a workaround for this?

I even tried using a specific version of dotnet SDK, but it still complains about android not being recognized.

https://github.com/nalu-development/nalu/actions/runs/11950637082/job/33312535560

      - name: "Setup .NET SDK"
        uses: actions/setup-dotnet@v3
        with:
          dotnet-version: '8.0.401'
      - name: "Ensure all workloads are installed" # https://github.com/actions/runner/issues/3578
        run: dotnet workload install maui
        shell: pwsh

@enclave-marc-barry
Copy link

enclave-marc-barry commented Nov 25, 2024

This is breaking our android builds too.

@twofingerrightclick
Copy link

twofingerrightclick commented Nov 26, 2024

Does anyone have a workaround for this?

I even tried using a specific version of dotnet SDK, but it still complains about android not being recognized.

https://github.com/nalu-development/nalu/actions/runs/11950637082/job/33312535560

      - name: "Setup .NET SDK"
        uses: actions/setup-dotnet@v3
        with:
          dotnet-version: '8.0.401'
      - name: "Ensure all workloads are installed" # https://github.com/actions/runner/issues/3578
        run: dotnet workload install maui
        shell: pwsh

You might try manually specifying the dotnet version via the --version flag to the workload install command. Or specify the version in a global.json file for your solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants