Commit 51c3dae
authored
[Java.Interop-MonoAndroid.csproj] Add jnienv-gen ProjectReference (#990)
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-L501 parent d0ef9e3 commit 51c3dae
1 file changed
+12
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
3 | 10 | | |
4 | 11 | | |
5 | 12 | | |
| |||
113 | 120 | | |
114 | 121 | | |
115 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
116 | 128 | | |
117 | 129 | | |
0 commit comments