Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
Created attachment 2416 [details]
Proposed patch to fix the problem
xbuild adds dependencies of references to the command line when it builds a project. Neither MonoDevelop nor msbuild on Windows does this. This can cause problems if there's a clash between static classes and namespaces revealed by loading a dependent assembly that isn't otherwise referenced directly.
I don't think it's that simple, IIRC the MS targets sets FindDependencies true in most cases.
I think Alan looked at this already - any comments?
I attempted a similar fix a few weeks ago but when I checked against msbuild, i realised that it was incorrect. The value of 'FindDependencies' should (and is) set to true in this case.
I've been trying to find a small sample which demonstrates the incorrect behavior which can be turned into an xbuild unit test, but I have been unable to create a failing unit test so far. If you can figure out a small testcase which demonstrates the issue, that'd be the best way to get this fixed.
I know the fixes to the .targets file were rather simplistic (but the setting to true was also rather simplistic compared to what msbuild has), but I think the code change to the .cs file is good. I'll try to simplify our code down to a reasonable test case to demonstrate the problem in practice.
Created attachment 2418 [details]
test program to demonstrate the bug
The attached zip file contains a set of four projects with a master project file (BugTest.proj) that demonstrates the bug. This project file builds perfectly fine on Windows using msbuild.exe, but fails using xbuild (on Linux).
The attached solution does not compile with msbuild or xbuild. Are you sure you attached the right thing?
Maybe I'm just building it wrong. What command should I be running to replicate the correct failure?
The solution file (XbuildReferenceBugTest.sln) won't work to build the attached project with either msbuild or xbuild because I created it using MonoDevelop, and MonoDevelop doesn't allow you to specify dependencies. It compiled fine for me on Windows using msbuild from VS 10 using the BugTest.proj file explicitly like this:
But building the projects fails using xbuild on Linux:
The solution file perhaps should be deleted since it doesn't help with tracing the xbuild bug.
Since our build process involves almost 200 projects, with both C# and C++ code, and a number of specialized operations, we don't try to create a solution file per se, but instead create a master project file to control building the whole system.
I have the testcase reduced down to the bare minimum now and have tracked down the exact variable which is incorrect. If all goes well I should have the correct fix in a little while. Thanks a lot for the attached solution, it was perfect!
Fixed in commit 2e7acd75fda3a3cf5fddca4bd71743caf43aa06c in mono/master. I took the compiled binaries from the solution you provided and created a few unit tests out of them to validate the fix. There are still some issues with gathering LocalCopy files, specifically pdb/mdb debug files, but I'll fix that separately.