Skip to content

Commit

Permalink
[xabuild] Improve Configuration detection (#671)
Browse files Browse the repository at this point in the history
`xabuild` determines the xamarin-android installation prefix by
looking at the `bin/Debug` and `bin/Release` directories, in that
specific order. If one wants to build a project in the `Release`
configuration and both `bin/Debug` and `bin/Release` are present,
`xabuild` will use `bin/Debug` as the prefix regardless of the
configuration passed to `{ms,x}build` with `/p:Configuration=Name`.
Your project will still be built in the specified configuration but
xamarin-android assemblies/etc. will come from the `Debug` build --
probably not the desired outcome. To work around it you would need
to invoke `xabuild` as follows:

   CONFIGURATION=Release xabuild /p:Configuration=Release my.csproj

which is unnecessarily verbose. This commit makes `xabuild` slightly
smarter by making it understand the `/p:Configuration` parameter and
extracting the configuration name from it and setting `CONFIGURATION`
to this value for you. This is done *only* if `CONFIGURATION` is not
set when invoking `xabuild`
  • Loading branch information
grendello authored and jonpryor committed Jun 28, 2017
1 parent 5432746 commit 91e0ba7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tools/scripts/xabuild
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ if [ -z "$MSBUILD" ] ; then
MSBUILD=xbuild
fi

if [ -z "$CONFIGURATION" ]; then
for p in "$*"; do
case $p in
/property:Configuration=*| \
/p:Configuration=*| \
-p:Configuration=*| \
--property:Configuration=*) CONFIGURATION="`echo $p | cut -d '=' -f 2`" ;;
esac

if [ -n "$CONFIGURATION" ]; then
break
fi
done
fi

if [[ "$prefix" == */tools/scripts ]] ; then
Paths_targets="$prefix/../../build-tools/scripts/Paths.targets"
for c in "$CONFIGURATION" Debug Release ; do
Expand Down

0 comments on commit 91e0ba7

Please sign in to comment.