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 3809 [details]
Project and solution which fails to build because of this bug
I'm trying to import a .targets file in my project conditionally depending on whether Xamarin.Android is installed. Here's what I'm trying in my .csproj:
<Import Project=".\MyTest.targets" Condition="!Exists('$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets')"/>
However in Xamarin Studio on Mac when Xamarin.Android is installed (and presumably the Novell.MonoDroid.CSharp.targets file exists), MyTest.targets is still getting imported. I've verified this by inserting an error in MyTest.targets and noticing that the build fails with that error.
The Condition feature does seem to work in general (I've tried it with some absolute paths). It just seems to break down when I add the MSBuildExtensionsPath variable to my path.
I've attached a sample project that illustrates the issue. This is also reported in the Xamarin forum here:
I ran into this issue with Xamarin Studio 4.2 (our previous version was 4.0.5 which used mdtool by default).
We have conditions like the following that shouldn't be run on our Mono builds on Mac, but should work when using MSBuild on Windows.
<Import Project="$(ProjectPath)\..\..\..\tools\SourceAnalysis\StyleCop.Targets" Condition=" '$(Platform)' != 'MacOSX' " />
mdtool simply ignored <Import> elements AFAICT, but xbuild only partially implements them.
@Jesse: xbuild special cases the MSBuildExtensionsPath property in the Import element Project attribute so that it represents multiple locations. This special casing is not done for any other elements or attributes.
@Tom: xbuild implements them just fine. Are you certain the Platform property is what you want? It's set by your solution configuration. I imagine what you actually want is "'$(Os)'!='Unix'" (see also bug 15974 comment 1).
Fixed in master