Bug 12732 - XBuild doesn't respect project references
Summary: XBuild doesn't respect project references
Status: NEW
Alias: None
Product: Tools
Classification: Mono
Component: xbuild ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2013-06-18 09:21 UTC by Stephen Shaw
Modified: 2013-10-08 04:02 UTC (History)
3 users (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 for Bug 12732 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Stephen Shaw 2013-06-18 09:21:33 UTC
If I use the solution to build it will fail because it doesn't include any of the project references -r:X.dll.
For example, it might fail on Project.X because it depends on Project.Y and Project.Z and it doesn't have -rProject.Y or -rProject.Z in the csc (smcs) command. However, if I go into Project.X and run xbuild with the same arguments (/p:Configuration/Release /v:diag) it builds just fine.
Comment 1 Stephen Shaw 2013-06-18 09:22:36 UTC
The same solution and csproj files build in VS2010, msbuild (cmd.exe), and XS. My guess is that there is something in there that all the others are tripped up by, but xbuild can't handle.
Comment 2 Stephen Shaw 2013-06-18 10:04:34 UTC
I can build every csproj by itself and it builds just fine.

I did a git clean -fdx and git checkout . - so that I it appeared as a fresh checkout of the code.
I then built the main startup app from the csproj file and it seemed to build just fine.

This appears to only fail if I use the solution file.
Comment 3 Jonathan Pryor 2013-06-18 11:09:15 UTC
As discussed on IRC, I _suspect_ that the problem is due to circular dependencies, or circular-like dependencies.

The Project.csproj contains <ProjectReference/>s. The Microsoft.Common.targets!AssignProjectConfigurations target takes @(ProjectReference) and splits into @(ProjectReferenceWithConfiguration) with the AssignProjectConfiguration task:


@(ProjectReferenceWithConfiguration) is then split into @(ProjectReferenceWithConfigurationExistent) and @(ProjectReferenceWithConfigurationNonExistent) in Microsoft.Common.targets!SplitProjectReferencesByExistent target.

@(ProjectReferenceWithConfigurationExistent) is then translated into @(ChildProjectReferences) by the Microsoft.Common.targets!ResolveProjectReferences target, by recursively using the MSBuild task.

@(ChildProjectReferences) is then translated into @(ProjectReference) in the Microsoft.Common.targets!ResolveAssemblyReferences target with the ResolveAssemblyReference task.

Finally, the Microsoft.CSharp.targets!CoreCompile target uses the Csc task to compile the code, and uses @(ReferencePath).

My (entirely untested!) suspicion is that the recursive MSBuild invocation isn't properly filling in @(ChildProjectReference), though things could be getting screwed up anywhere else.
Comment 4 Jonathan Pryor 2013-06-18 11:10:22 UTC
To help narrow this down, I would suggest editing Microsoft.Common.targets and adding <Message/> elements to print out the contents of the various properties within the above mentioned targets, just to further determine what's going on.
Comment 5 Stephen Shaw 2013-06-18 11:44:23 UTC
Just a quick note, this actually fails in release mode in XS the same as with xbuild.

Going to test out jonp's comments.