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
[build] Improve support for building on GitHub Codespaces (#1241)
Context: https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers
Context: https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers#using-the-default-dev-container-configuration
Context: https://github.com/orgs/community/discussions/25429
There are two issues when trying to build `Java.Interop.sln` within
a [GitHub Codespace][0]:
1. `dotnet build -t:Prepare Java.Interop.sln` fails.
2. `mono` was required on Linux environments.
`dotnet build -t:Prepare` fails because `Java.Interop.sln` references
`Xamarin.Android.Tools.AndroidSdk.csproj`, which does not exist
immediately after checkout:
/usr/share/dotnet/sdk/8.0.303/NuGet.targets(414,5): error MSB3202:
The project file "…/java-interop/external/xamarin-android-tools/src/Xamarin.Android.Tools.AndroidSdk/Xamarin.Android.Tools.AndroidSdk.csproj"
was not found.
This apparently happens *before* the `Prepare` target executes, so
the `git submodule update --init --recursive` within that target
doesn't execute.
Fix this by adding a `.devcontainer/devcontainer.json` which contains
a `postCreateCommand` section which runs
`git submodule update --init --recursive`. Additionally, have
`devcontainer.json` use the
`mcr.microsoft.com/devcontainers/universal:2-linux` image, which
supports C#, Java, and C++ development (among others), which is handy
as this repo contains C#, Java, and C++ code to compile.
Once the submodule problem is addressed, `dotnet build -t:Prepare`
fails again because `mono` was required in Linux environments, and
the default environment that GitHub Codespace creates when typing
`.` within dotnet/java-interop has `dotnet` installed, but not `mono`.
This results the error:
…/java-interop/build-tools/Java.Interop.BootstrapTasks/Java.Interop.BootstrapTasks.targets(50,5):
error MSB3073: The command "which mono" exited with code 1.
Update `Java.Interop.BootstrapTasks.targets` so that `mono` is no
longer required on Linux platforms. If `which mono` returns the
empty string, then `bin/Build*/MonoInfo.props` is not created.
Finally, the `mcr.microsoft.com/devcontainers/universal:2-linux`
image defaults to using JDK 17. The
`JniPeerMembersTests.DoesTheJmethodNeedToMatchDeclaringType()` test
crashes under JDK 17 with:
FATAL ERROR in native method: Wrong object class or methodID passed to JNI call
Update `DoesTheJmethodNeedToMatchDeclaringType()` to skip the test
when running on JDK 17 or later.
With these changes, a new GitHub codespace against dotnet/java-interop
can now build and run tests, a'la:
% dotnet build -t:Prepare Java.Interop.sln
% dotnet build Java.Interop.sln
% dotnet test bin/TestDebug-net8.0/Java.Interop-Tests.dll
…
Passed! - Failed: 0, Passed: 629, Skipped: 3, Total: 632, Duration: 4 s - Java.Interop-Tests.dll (net8.0)
~~ Oddities and annoyances with GitHub Codespaces: ~~
1. On macOS + Safari, "Hamburger menu" > File > Close Editor *says* ⌘W.
However, *using* ⌘W results in closing the
GitHub Codespaces *Safari tab*.
*Oops*.
Pressing ⌘Z will reopen the closed Safari tab.
I don't know how to close a VSCode tab without using the mouse.
Ctrl+W doesn't do it.
2. You make a change, and commit it by using `git commit` within the
Terminal (Ctrl+Shift+Backtick ⌃ ⇧ \`).
A new tab for `COMMIT_EDITMSG` opens. This is good.
If you then *search for text* that appears within that editor
window, and that text appears within the editor window --
e.g. search for "the" -- then the "return" key keeps finding the
next search match, which makes it difficult to enter blank lines.
You must either fully dismiss the search dialog by hitting
Escape ⎋ a few times, or by clicking the close `x` button on the
search panel, or use Ctrl+return ⌃return to enter a newline.
This was "odd", especially as Escape ⎋ doesn't appear to reliably
dismiss the search panel for me.
[0]: https://github.com/features/codespaces
0 commit comments