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 for Bug 25353 on
Developer Community or GitHub 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
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
Before building a project, the MSBuild 4.0+ project builder uses project.SetProperty to set the solution-mapped Configuration and Platform values on each Project in the ProjectCollection. It then creates a ProjectInstance and builds it.
This is incorrect. SetProperty inserts a property on the first PropertyGroup in the project that already contains a value for that property, which means anything that checks the value before that property (e.g. an imported pros file) will not see the value.
This can be demonstrated by adding the following project to a solution and building it. This fails in XS/MD and succeeds in VS.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Fail Condition="'$(Configuration)' == ''">true</Fail>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Error Condition="$(Fail)=='true'" Text="Configuration not set" />
Unfortunately the fix is not as simple as using SetGlobalProperty.
I think we may need to use Microsoft.Build.Execution.BuildManager. We'd build each project, only setting the Configuration/Platform for each individual project as we built it. If we build each project's dependencies before it, then the BuildManager would re-use the existing ProjectInstances with the property values that we already set on it.