You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context: dotnet/android#7068
When attempting to build xamarin/xamarin-android *without* using
`dotnet build -m:1` -- *with* parallel builds enabled -- the build
can randomly fail:
'"C:\a\_work\1\s\external\Java.Interop\bin\BuildRelease\jnienv-gen.exe"' is not recognized as an internal or external command, operable program or batch file.
or
…/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop.targets(19,5):
error MSB3073: The command "mono "…/xamarin-android/external/Java.Interop/bin/BuildDebug/jnienv-gen.exe" Java.Interop/JniEnvironment.g.cs obj/Debug/jni.c" exited with code 2.
[…/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop-MonoAndroid.csproj]
The cause of the error is that xamarin-android's `Mono.Android.targets`
[uses `<MSBuild/>` to build `Java.Interop-MonoAndroid.csproj`][0],
and `Java.Interop-MonoAndroid.csproj` does not have a
`@(ProjectReference)` to `build-tools/jnienv-gen/jnienv-gen.csproj`.
Consequently, when `Java.Interop-MonoAndroid.csproj` is built,
`jnienv-gen.exe` *may not exist*, resulting in the MSB3073 errors.
Fix this usage scenario by updating `Java.Interop-MonoAndroid.csproj`
to have a `@(ProjectReference)` to
`build-tools/jnienv-gen/jnienv-gen.csproj`. This ensures that
`jnienv-gen.exe` exists before the `BuildJniEnvironment_g_cs` target
in `Java.Interop.targets` is executed.
Additionally, move some of the "property overrides" defined in
`Mono.Android.targets` (for use by `Java.Interop-MonoAndroid.csproj`)
into `Java.Interop-MonoAndroid.csproj`. The problem with having them
in `Mono.Android.targets` is that the invocation worked as a *global*
override, overriding `$(TargetFrameworkVersion)`/etc. when
*`build-tools/jnienv-gen/jnienv-gen.csproj`* is built, causing the
resulting `jnienv-gen.exe` to possibly be a "monoandroid10" app,
*not* a net472 app. Moving these properties into
`Java.Interop-MonoAndroid.csproj` means that `Mono.Android.targets`
*doesn't* need to specify them, which means the `jnienv-gen.csproj`
build won't inadvertently use them.
[0]: https://github.com/xamarin/xamarin-android/blob/6b43af37bc57b7eea2a213ee15de037e61784a1c/src/Mono.Android/Mono.Android.targets#L23-L50
0 commit comments