-
Notifications
You must be signed in to change notification settings - Fork 564
[xabuild.exe] cross-platform form of tools/scripts/xabuild #910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@jonathanpeppers, |
c3ff372 to
7314265
Compare
tools/scripts/xabuild
Outdated
| CONFIGURATION=$word | ||
| break | ||
| done | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed a slight issue here. If you run the command:
tools/scripts/xabuild /p:Configuration=Release someProjectOrSolution.csproj
Then $CONFIGURATION was coming out set to Release someProjectOrSolution.csproj.
Let me know if there is a better way to fix this, I'm not exactly a bash expert. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the actual problem is line 46: it should use "$@", not "$*":
tools/scripts/xabuild
Outdated
| done | ||
| fi | ||
|
|
||
| if [[ "$MSBUILD" == "msbuild" ]] ; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This "block" should be moved to ~line 84, after $prefix is set. $prefix contains the $CONFIGURATION to use.
tools/scripts/xabuild
Outdated
| fi | ||
|
|
||
| if [[ "$MSBUILD" == "msbuild" ]] ; then | ||
| if [ -z "$CONFIGURATION" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...by using $prefix, this check is superfluous.
tools/scripts/xabuild
Outdated
| if [ -z "$CONFIGURATION" ]; then | ||
| CONFIGURATION="Debug" | ||
| fi | ||
| exec mono "$prefix/../../bin/$CONFIGURATION/bin/xabuild.exe" "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would need to then become $prefix/bin/xabuild.exe.
Context: https://github.com/jonathanpeppers/xabuild 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 modify your system. xabuild.exe works by doing the following: - Reference `MSBuild.exe` or `MSBuild.dll` depending on the platform - Overrides the `app.config` file of MSBuild to set various properties - This allows `xabuild.exe` to build Xamarin.Android projects using local Xamarin.Android build output - Creates symbolic links to `.NETPortable` and `.NETFramework` directories inside the Xamarin.Android build output directory - Run MSBuild’s `Main()` method Changes: - Added `xabuild.csproj` to Xamarin.Android.sln - `tools/scripts/xabuild` now runs `xabuild.exe` if `MSBUILD=msbuild` - Xamarin.Android.Build.Tests run `tools/scripts/xabuild` on Unix and `xabuild.exe` on Windows
7314265 to
0754ba8
Compare
Context in dotnet#910 When switching to `xabuild.exe`, two mistakes were made: - `xabuild.exe` shouldn’t set `AndroidSdkDirectory` or `AndroidNdkDirectory` - Xamarin.Android.Build.Tests should pass these values to xabuild This restores some of the code in `Builder.cs` removed in f9d15dd
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`.
Context: https://github.com/jonathanpeppers/xabuild
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 modify your system.
xabuild.exe works by doing the following:
MSBuild.exeorMSBuild.dlldepending on the platformapp.configfile of MSBuild to set various propertiesxabuild.exeto build Xamarin.Android projects usinglocal Xamarin.Android build output
.NETPortableand.NETFrameworkdirectories inside the Xamarin.Android build output directory
Main()methodChanges
xabuild.csprojto Xamarin.Android.slntools/scripts/xabuildnow runsxabuild.exeifMSBUILD=msbuildtools/scripts/xabuildon Unixand
xabuild.exeon WindowsUsage
An example on MacOS:
An example on Windows (msbuild should be 15.3 from VS 2017):
Note, these tests are not all passing on Windows yet. See here for latest results.