The “JNBBuildTask” task failed unexpectedly

When you are building, rebuilding, or cleaning a JNBridgePro .NET-to-Java proxies project, you might see a message “The ‘JNBBuildTask’ task failed unexpectedly.” This can sometimes happen when the .NET-to-Java proxy project was created in an earlier version of Visual Studio (2015 or earlier), but is currently being built using Visual Studio 2017 or later. If you encounter this problem, do the following:

  • Unload the proxy project by right-clicking on the proxy project’s node in the Solution Explorer and selecting “Unload Project”.
  • Open the proxy project file for editing by right-clicking on the proxy project’s node in the Solution Explorer and selecting “Edit projectName.jnbproj”.
  • Locate the following lines in the project (note that the line breaks might be different):

    <UsingTask TaskName=”com.jnbridge.plugin.JNBBuildTask”
    Condition=” ‘$(TargetFrameworkVersion)’ == ‘4.0’ ”
    AssemblyFile=”$(JNBPLUGIN_PATH_40)\JNBridgePlugin.dll” />
    <UsingTask TaskName=”com.jnbridge.plugin.JNBBuildTask”
    Condition=” ‘$(TargetFrameworkVersion)’ == ‘v4.0’ ”
    AssemblyFile=”$(JNBPLUGIN_PATH_40)\JNBridgePlugin.dll” />

  • Edit those lines so that they now read (note the changes in bold):

    <UsingTask TaskName=”com.jnbridge.plugin.JNBBuildTask”
    Condition=” ‘$(TargetFrameworkVersion)’ == ‘4.0’ ”
    AssemblyFile=”$(JNBPLUGIN_PATH_40)\JNBridgePlugin2017.dll” />
    <UsingTask TaskName=”com.jnbridge.plugin.JNBBuildTask”
    Condition=” ‘$(TargetFrameworkVersion)’ == ‘v4.0’ ”
    AssemblyFile=”$(JNBPLUGIN_PATH_40)\JNBridgePlugin2017.dll” />

  • Save the file away, right-click on the proxy project’s node in the Solution Explorer, and select “Reload project”.
  • When you build your solution, you should no longer see the error.

Alternatively, you can re-create the proxy generation project in Visual Studio 2017.