Bug 43498 - Neither xbuild nor MSBuild can build Java.Interop
Summary: Neither xbuild nor MSBuild can build Java.Interop
Alias: None
Product: Tools
Classification: Mono
Component: xbuild ()
Version: 4.6.0 (C8)
Hardware: PC Mac OS
: Highest blocker
Target Milestone: (C8)
Assignee: Ankit Jain
Depends on:
Reported: 2016-08-18 00:31 UTC by Jonathan Pryor
Modified: 2016-08-18 22:05 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jonathan Pryor 2016-08-18 00:31:03 UTC
Mono 4.4 (Cycle 7) is able to build Java.Interop:


Mono 4.6 (Cycle 8) is *not* able to build Java.Interop. It fails when trying to build Mono.Linq.Expressions:

>     /Library/Frameworks/Mono.framework/Versions/4.6.0/lib/mono/xbuild/Microsoft/Portable/Microsoft.Portable.Core.targets:
> error : The TargetFrameworkProfile property is not set for project 'Mono.Linq.Expressions.csproj'.
> Portable projects must specify a profile.

This is lunacy, as the project *does* define that property:


Furthermore, `msbuild` also fails to build the project, with the same error.

Finally, if we "force" the property to be set by providing it on the command-line:

> $ msbuild /p:TargetFrameworkProfile=Profile92

It fails with incomprehensible errors:


In particular, why is it referencing files from the GAC?!

> /Library/Frameworks/Mono.framework/Versions/4.6.0/lib/mono/4.5/mcs.exe /noconfig
> /nowarn:1701,1702 /nostdlib+ /platform:x86 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva- 
> /reference:/Library/Frameworks/Mono.framework/Versions/4.6.0/lib/mono/gac/Microsoft.CSharp/ 
> /reference:/Users/jon/Dropbox/Developer/Java.Interop/lib/mono.linq.expressions/bin/Debug/Mono.Linq.Expressions.dll 
> /reference:/Library/Frameworks/Mono.framework/Versions/4.6.0/lib/mono/msbuild/14.1/bin/mscorlib.dll 
> /reference:/Library/Frameworks/Mono.framework/Versions/4.6.0/lib/mono/gac/System.Core/ 
> /reference:/Library/Frameworks/Mono.framework/Versions/4.6.0/lib/mono/gac/System/
> ...
Comment 1 Ankit Jain 2016-08-18 22:05:57 UTC
The project file Mono.Linq.Expressions.csproj actually *unsets* `TargetFrameworkProfile`:


The `TargetFrameworkProfile` check is done in a target called `_CheckForInvalidTargetFrameworkProfile` which comes from `Microsoft.Portable.Core.targets`. This target depends on a target named `_CheckForInvalidConfigurationAndPlatform` to be present, in `Microsoft.Common.targets`. In 4.4.x, there was no target with that name (we had a target that did the same job, but with a different name). As a result the `TargetFrameworkProfile` check from portable targets wouldn’t run at all. But in 4.6.x, we fixed the naming and as a result that target runs now and it errors out because of the missing `$(TargetFrameworkProfile)` property.

So, the project with stable mono (4.4.x) in absence of `$(TargetFrameworkProfile)` got compiled with `/Library/Frameworks/Mono.framework/Versions/4.4.2/lib/mono/xbuild-frameworks/.NETPortable/v4.0/*.dll` instead of `Profile92`. And removing the "unset-TargetFrameworkProfile" from the csproj fixes this issue for both xbuild and msbuild.

- I have opened a PR upstream for this - https://github.com/jbevain/mono.linq.expressions/pull/14 .

- This is not a bug in xbuild/msbuild