Bug 20942 - Provide way to detect building under xbuild vs. msbuild
Summary: Provide way to detect building under xbuild vs. msbuild
Alias: None
Product: Tools
Classification: Mono
Component: xbuild ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2014-06-27 07:08 UTC by Shay Rojansky
Modified: 2014-06-27 12:47 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 Shay Rojansky 2014-06-27 07:08:03 UTC
There are several incompatibilities between MSBuild and XBuild. Some projects add a check for $(OS) == 'Windows' in their csproj as a mechanism for detecting mono, but this breaks when building on mono/Windows.

A good example is the nuget package restore support which has several such conditions (e.g. http://nuget.codeplex.com/workitem/3435, there are others).

This could be easily solved by having xbuild define a standard environment variable that could be checked from within the csproj. For example, an XBUILD environment variable could contain the version of the XBUILD tool.
Comment 1 Mikayla Hutchinson [MSFT] 2014-06-27 12:47:21 UTC
Incompatibilities in xbuild are bugs, and likely depend on the *version* of xbuild. They need to be reported and fixed.

Since the bugs are version dependent, simply checking whether it's xbuild isn't really any better than checking for the OS. We don't recommend use of xbuild on Windows, anyway, so checking the OS is an acceptable temporary workaround IMO.