You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[xabuild.exe] cross-platform form of tools/scripts/xabuild (#910)
Context: https://github.com/jonathanpeppers/xabuild
What do we want? A *usable*, *parallel*, build tree.
To elaborate: we want to be able to have a "system" Xamarin.Android
install, and a "parallel" xamarin-android install, and be able to
*easily* switch between the two. (For various definitions of "easy";
here, we mean *command-line* use, not IDE use.)
On macOS, this (more or less) Just Works™, and is extremely handy
for testing bug fixes:
$ xbuild /t:Install Project.csproj
# Verify that some bug is triggered
$ xbuild /t:Uninstall Project.csproj
$ tools/scripts/xabuild /t:Install Project.csproj
# Verify that some bug is *fixed*
There's One Problem™ with this: MSBuild does not make this easy.
(Related: commit aa1db83.) Apps may rely on files located within
`$(MSBuildExtensionsPath)` or `$(TargetFrameworkRootPath)`, files
such as PCL profile assemblies, or 3rd party frameworks.
Meanwhile, on macOS, `xabuild` is *predicated* upon overriding
`$(TargetFrameworkRootPath)` and `$(MSBuildExtensionsPath)` and
`$(XBUILD_FRAMEWORK_FOLDERS_PATH)`, and creating a bunch of symlinks
to "fake out" `msbuild.exe` so that system-installed files such as
PCL assemblies can be found *through* the parallel environment.
It kinda/sorta works on macOS. It completely falls apart when using
Windows. There is no easy "symlink half the world" solution there.
Overriding `$(MSBuildExtensionsPath)` means that
`Microsoft.Common.targets` can't be found. Overriding
`$(TargetFrameworkRootPath)` means PCL files can't be found.
It's a mess.
Fortunately, more recent versions of MSBuild allow for some of these
properties to contain *multiple* directories instead of a single
directory, which means *there is a way* to support our desired
usable parallel install world order. We "just" need to e.g.
force `$(MSBuildExtensionsPath)` to contain *both* the in-tree
directory *and* the system directory:
```xml
<MSBuildExtensionsPath>In-Tree Directory; System Directory</MSBuildExtensionsPath>
```
Unfortunately, *this isn't easy*. Not all of these properties can be
overridden on the `msbuild.exe` command line. Worse, MSBuild doesn't
allow `;` to be part of a property value, as `;` is a property name
[separator char](https://msdn.microsoft.com/en-us/library/ms164311.aspx)
msbuild.exe /property:WarningLevel=2;OutDir=bin\Debug
The way to force MSBuild to accept multiple paths in a property value
is by providing a `.exe.config` file with the appropriate values.
~~ Enter `xabuild.exe` ~~
`xabuild.exe` is a nice wrapper around MSBuild for compiling
Xamarin.Android projects using a locally built version of
Xamarin.Android on your system. It seems to work on Windows, macOS, and
Linux and doesn’t require elevation or modifications to your system.
`xabuild.exe` works by doing the following:
1. Reference `MSBuild.exe` or `MSBuild.dll` depending on the platform
2. Creates symbolic links to `.NETPortable` and `.NETFramework`
directories inside the Xamarin.Android build output directory
3. Overrides MSBuild's `app.config` file to set various properties,
such as `$(MSBuildExtensionsPath)`.
4. Run MSBuild’s `Main()` method
~~ Usage ~~
On macOS, `tools/scripts/xabuild` has been updated to use
`xabuild.exe` when `$MSBUILD` is `msbuild:
$ MSBUILD=msbuild tools/scripts/xabuild /t:SignAndroidPackage samples/HelloWorld/HelloWorld.csproj
When `$MSBUILD` is `xbuild` (the current default), the previous
behavior of overriding `$MSBuildExtensionsPath` and
`$XBUILD_FRAMEWORK_FOLDERS_PATH` is still used.
On Windows, MSBuild 15.3 from Visual Studio 2017 is required.
Simply execute `xabuild.exe`:
> bin\Debug\bin\xabuild.exe Xamarin.Android-Tests.sln /p:XAIntegratedTests=False
Before `xabuild.exe` existed, `setup-windows.exe` would need to be
executed (as Administrator!) in order for `Xamarin.Android-Tests.sln`
to be built using `msbuild.exe`.
0 commit comments