-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Java.Interop] Target .NET Standard 2.0
We would like to be able to build [xamarin-android][0]'s `Xamarin.Android.sln` within Visual Studio (Windows). @joj believes that the difficulty is "caused" by `src/Java.Interop/Java.Interop.csproj` being a PCL project, and thus if we migrated our PCL projects to instead use .NET Standard the difficulties would be resolved. Update `Java.Interop`, `Java.Interop.Dynamic`, `Java.Interop.Export`, and `Java.Interop.GenericMarshaler` to be .NET Standard 2.0 projects instead of PCL projects. This in turn requires updating *every other project* to have a `$(TargetFrameworkVersion)` value of v4.6.1 (or later) so that they can reference .NET Standard 2.0 libraries. Additionally, `make fxcop` and related need to be updated, as the output paths for .NET Standard 2.0 builds has changed. Migrating to .NET Standard 2 *also* impacts the downstream xamarin-android repo: building `xamarin-android/src/Mono.Android` would fail: Microsoft.NuGet.targets(184,5): error : Your project is not referencing the "MonoAndroid,Version=v1.0" framework. Add a reference to "MonoAndroid,Version=v1.0" in the "frameworks" section of your project.json, and then re-run NuGet restore. The fix for this is twofold: 1. Provide a new `Java.Interop-MonoAndroid.csproj` file for use by the `xamarin-android/src/Mono.Android` build [^1], and 2. *Override* the `$(BaseIntermediateOutputPath)` MSBuild property. `$(BaseIntermediateOutputPath)` is used to find the `project*.json` files within `Microsoft.NuGet.targets`, and altering `$(BaseIntermediateOutputPath)` thus prevents the `project*.json` files from being found, allowing the build to succeed. Finally, building .NET Standard 2 projects often requires that the `msbuild /restore` or `msbuild /t:Restore` commands be used. Integrate `msbuild /t:Restore` into `make prepare`, and fix the `src/java-interop` project so that `msbuild /t:Restore` works without emitting errors. [0]: https://github.com/xamarin/xamarin-android/ [^1]: The following patch needs to be applied to `xamarin-android` when performing the next `Java.Interop` submodule bump: diff --git a/src/Mono.Android/Mono.Android.targets b/src/Mono.Android/Mono.Android.targets index 1d7e0c1a..848a3f63 100644 --- a/src/Mono.Android/Mono.Android.targets +++ b/src/Mono.Android/Mono.Android.targets @@ -20,7 +20,7 @@ </_GlobalProperties> </PropertyGroup> <MSBuild - Projects="$(JavaInteropFullPath)\src\Java.Interop\Java.Interop.csproj" + Projects="$(JavaInteropFullPath)\src\Java.Interop\Java.Interop-MonoAndroid.csproj" Properties="$(_GlobalProperties)" /> <ItemGroup>
- Loading branch information
1 parent
706e4cc
commit 85be94f
Showing
43 changed files
with
265 additions
and
428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
36 changes: 7 additions & 29 deletions
36
src/Java.Interop.GenericMarshaler/Java.Interop.GenericMarshaler.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
src/Java.Interop.GenericMarshaler/Properties/AssemblyInfo.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
Java.Interop/JniEnvironment.g.cs | ||
obj-MonoAndroid |
Oops, something went wrong.