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.
A project configuration has a before build command to run a script which copies some files around. This does not appear to be executed anymore when building from the command line with xbuild (switch from mdtool because of Unified API).
The command being ran is:
> xbuild /v:diagnostic '/property:Configuration=PROD Ad-Hoc' MyProject.iOS.sln
The logs show:
>CustomCommands = <CustomCommands xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><Command type="Build" command="/bin/bash ./setup.sh Release PROD"/></CustomCommands>
That is the script that is supposed to run, but it does not seem to actually be execute.
**Steps to Reproduce:**
Add a before build command to a configuration to run a script (iOS)
Use xbuild from the command line to build the project
The script is not executed
The script should be executed
Originally, mdtool was being used:
> mdtool' build '--configuration:PROD Ad-Hoc|iPhone’ MyProject.iOS.sln
After switching to Unified, xbuild was needed, so this was tried
> xbuild /v:diagnostic '/property:Configuration=PROD Ad-Hoc|iPhone’ MyProject.iOS.sln
This failed and resulted in this error:
> /Volumes/DataDrive/username/MyProjectSolution.iOS/Apps/Projects/iOS/MyProject.iOS.sln: error : Invalid solution configuration and platform: "PROD Ad-Hoc|iPhone|iPhone".
It seems to add an additional "|iPhone"
=== Xamarin Studio ===
Version 5.7 (build 661)
Installation UUID: 0d980f6f-57aa-44e5-8995-12c9e34764af
Mono 3.12.0 ((detached/a813491)
GTK+ 2.24.23 (Raleigh theme)
Package version: 312000068
=== Apple Developer Tools ===
Xcode 6.1.1 (6611)
=== Xamarin.iOS ===
Version: 22.214.171.124 (Enterprise Edition)
Build date: 2015-01-08 13:39:32-0500
=== Xamarin.Android ===
Android SDK: Not found
=== Xamarin.Mac ===
=== Build Information ===
Release ID: 507000661
Git revision: b70bab61da996da29045ea8ee8aed1a6faedbe78
Build date: 2015-01-05 16:31:31-05
Xamarin addins: 82f6c71490562d6cd125a09287f441902fdac3d7
=== Operating System ===
Mac OS X 10.10.2
Darwin Neils-MBP.home 14.1.0 Darwin Kernel Version 14.1.0
Mon Dec 22 23:10:38 PST 2014
That sounds more like `xbuild` itself (i.e. it ships with mono, not XI), c.c. the best people for this
Updated component. Please let me know if that is not the right place.
This might be invalid MSBuild syntax (but it works in mdtool/XS).
Jeff, can you comment if this is the case?
it's a syntax that is monodevelop-specific (i.e. it's non-standard MSBuild XML stuff that MSBuild cannot interpret).
If you want to use those features, then you need to use mdtool (as Rolf discovered works fine).
Either that or you need to use the MSBuild XML syntax to hook into the build process in the .csproj file (or in your own targets that you import in the .csproj).
I'll /cc Michael Hutchinson to make sure I'm correct (he knows more about this than I do), but I'm pretty sure I'm right.
#1 The MSBuild properties for the platform and configuration are separate: '/property:Configuration=PROD Ad-Hoc' '/property:Platform=iPhone'. mdtool parses the "combined" configuration, but MSBuild/xbuild does not.
#2 CustomCommands items are specific to the old MonoDevelop build engine, which will be deprecated soon.
If you build inside XS, or with mdtool, it will use a sort of hybrid model, i.e. it will build xbuild-compatible projects with the xbuild engine, but will still respect the CustomCommands from the old engine.
If you build with xbuild, MSBuild or Visual Studio, these CustomCommands will not work, since they do not understand the MD-specific commands.
However, you can manually edit the csproj file to add arbitrary MSBuild syntax which should work in all of these environments.
A simple example, overriding the BeforeBuild target:
<Exec Command="some shell command" />
For more info, see https://msdn.microsoft.com/en-us/library/ms366724.aspx
I have a Xamarin Studio (Mac) project that I recently modified so it would generate the Info.plist (which contains version info). The problem is that the 'Before Build' command does not execute before the Info.plist is checked. This sounds similar to the problem discussed here:
Have not tested in Visual Studio for Mac yet.
Will try the workaround listed above by Mikayla Hutchinson.
Sadly, that workaround does not work. I believe that's mentioned in the forum post linked. My workaround is to use a separate generic project to do this instead, and ensure it builds first.