Xamarim msbuild to use a specific Java version

Viewed 28

We are trying to use a specific Java version on a TFS build pipeline. The build is being done using msbuild. The build server have two Java versions installed (i.e. 8 and 11). The PATH variable point to java 8, but in the msbuild we want to use Java 11 for the Android part.

It is asked to not change the PATH variable because other applications require Java 8, so wanted to know if there is any provision to pass the JDKPath directly to the msbuild using any command-line parameters.

1 Answers

When you use Xamarin msbuild to build Android project, you can define the JDK version in the Xamarin task.

Here is an example:

- task: XamarinAndroid@1
  displayName: 'Build Xamarin.Android project project path'
  inputs:
    projectFile: 'project path'
    target: test
    jdkVersionOption: 1.11

Or you can also define the jdk path in the Xamarin task.

- task: XamarinAndroid@1
  displayName: 'Build Xamarin.Android project project path'
  inputs:
    projectFile: 'project path'
    target: test
    jdkOption: Path
    jdkDirectory: 'JDK path'

For more detailed info, you can refer to this doc: Xamarin.Android task

Related