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 21521 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
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
Add the following before build task to an Android or iOS project:
<Exec Command="echo executing beforebuild for $(ProjectName) on mac os" Condition=" '$(OS)' == 'Unix' " />
<Exec Command="echo executing beforebuild for $(ProjectName) on windows" Condition=" '$(OS)' == 'Windows_NT' " />
Output in Visual Studio or Xamarin Studio in Windows (where App.Android was the name of the project being built):
executing beforebuild for App1.Android on windows
Output in Xamarin Studio on a Mac:
executing beforebuild for on mac os
$(ProjectName) is being replaced with an empty string. I am seeing this same behavior across both Android and iOS projects.
Is this before or after importing the common targets?
After the imports. If I move the BeforeBuild target to before the imports it doesn't execute. Also a correction, I am not seeing this with iOS projects on the Mac. I can't even get iOS projects to execute any before build / prebuild tasks in Mac OS but that's a separate issue.
Looks like xbuild's version of Microsoft.Common.targets doesn't define the ProjectFile property.
As a workaround, you could use MSBuildProjectFile, which is defined by the engine.
The MS version of the targets defines ProjectName as MSBuildProjectName if it's not explicitly set, anyway.