[xabuild] Support using msbuild from mono 4.8+ - #637
Conversation
|
Question: one problem with this PR is it basically "hardcodes" |
|
|
As suggested on slack, we can use Which actually runs the default mono and doesn't rely on symlinks or versions. Not pretty, but effective IMO |
|
@grendello wrote:
I don't see how it doesn't rely on symlinks. The reason for the symlinks is so that our "in-tree Mono's |
|
It doesn't rely on symlinks in the sense that there isn't a requirement for them to exist before the |
b4bf5ea to
eca6d9b
Compare
|
PR updated to entirely remove any requirement for symlinks. The "problem" with |
|
...and eca6d9b is wrong. Well, half right. no longer dies while attempting to create the directory Additionally, it is trying to use the appropriate assemblies: However, the targets files are not used: Doh! |
eca6d9b to
ffd6376
Compare
|
Commit ffd6376 allows the in-tree TODO: what happens with the |
I had mistakenly believed that Jenkins would hit the Trying locally, it fails: ...which isn't a good sign. |
`tools/scripts/xabuild` is an MSBuild wrapper to build Xamarin.Android apps from the command-line, using the built in-tree binaries; see commit e20863e. `xabuild` originally invoked `xbuild`; commit 6805d20 extended that to support building with `msbuild` by setting the `MSBUILD` environment variable: MSBUILD=msbuild .../tools/scripts/xabuild SomeProject.csproj This use worked with Mono 4.4 and 4.6, but broke -- unnoticed -- when running under Mono 4.8 and later. When attempting to use `msbuild` from Mono 4.8 and later, the build will fail, cryptically: xamarin-android/bin/Debug/lib/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1007,2): error MSB3191: Unable to create directory "/Debug/". Access to the path "/Debug/" is denied. The directory `/Debug/` is mentioned because the `$(BaseIntermediateOutputPath)` MSBuild property is not being set. *Normally* we'd be creating e.g. `obj/Debug`, but without `$(BaseIntermediateOutputPath)`, this becomes `/Debug`, and everything breaks. `$(BaseIntermediateOutputPath)` isn't set, in turn, because `Microsoft.Common.props` isn't being imported. `Microsoft.Common.props` isn't being imported because `xabuild` overrides the `$MSBuildExtensionsPath` environment variable, and MSBuild is trying to import `$(MSBuildExtensionsPath)\...\Microsoft.Common.props`, which doesn't exist when we've overridden `$MSBuildExtensionsPath` to use our in-tree build location. *A* fix for this *could* be *not overriding `$MSBuildExtensionsPath`* when using `msbuild`. There is one problem with this, though: not overriding `$MSBuildExtensionsPath` means that the `.targets` files in e.g. `bin/Debug/lib/xbuild/Xamarin/Android` *will not be used*. Instead, the *system* files are used, which is undesirable. Unfortunatley, this means we need to continue overriding `$MSBuildExtensionsPath`, *while* allowing e.g. `$(MSBuildExtensionsPath)\...\Microsoft.Common.props` to be found. Square this circle by *symlinking* everything in the *system* `$MSBuildExtensionsPath` directory into our `$prefix/lib/xbuild`. Symlinking all these files raises *another* issue: we *don't* want all of these symlinks, *or their targets*, to be added to the `oss-xamarin.android*.zip` and `Xamarin.Android*.vsix` files. Support this by creating a `$prefix/lib/xbuild/.__sys_links.txt` file, which contains `zip -x` patterns (hence the `/*` suffix for directories), one per line, and update the `make package-oss` target to look for and exclude the contents of these files so that we don't "pollute" the `oss-xamarin.android*.zip` file with unnecessary contents. Similarly, update the `create-vsix` project so that instead of including `$(LibDir)xbuild\**\*.*`, it instead only includes the contents of `$(LibDir)\xbuild\Novell\**\*.*` and `$(LibDir)\xbuild\Xamarin\**\*.*`. Finally, some cleanups: * Only set `$XBUILD_FRAMEWORK_FOLDERS_PATH` when using `xbuild`. * Additionally, specify `$(TargetFrameworkRootPath)` on `msbuild`, as that MSBuild property can actually be overridden w/ `msbuild`. * Always specify `$(MonoAndroidBinDirectory)` and `$(MonoAndroidToolsDirectory)`, as this mirrors the Windows usage instructions. * Don't *require* that `$ANDROID_NDK_PATH` and `$ANDROID_SDK_PATH` be set prior to executing `xabuild`, *or* that we be running in-tree (to use `Paths.targets`). The NDK, in particular, isn't always required, so requiring that it be set is annoying. The build process will error out appropriately if required directories cannot be found.
ffd6376 to
8b8fa5c
Compare
|
|
Changes: dotnet/java-interop@ce8dc40...377c4c7 Fixes: dotnet/java-interop#631 * dotnet/java-interop@377c4c7: Bump to xamarin/xamarin-android-tools/master@f5fcb9fd (dotnet#637) * dotnet/java-interop@857b9a9: [Java.Interop.Export] Begin supporting methods with 14+ params (dotnet#635) * dotnet/java-interop@9876e31: [Java.Interop.BootstrapTasks] Convert to SDK style project (dotnet#609) * dotnet/java-interop@cbb50af: [generator-Tests] Use Roslyn for .NET Core Support (dotnet#638) * dotnet/java-interop@56955d9: [generator] Use custom delegates instead of Func/Action. (dotnet#632) * dotnet/java-interop@0a77166: [Java.Interop.sln] Commit updated automatically generated guids. (dotnet#634)
Changes: dotnet/java-interop@ce8dc40...377c4c7 Fixes: dotnet/java-interop#631 * dotnet/java-interop@377c4c7: Bump to xamarin/xamarin-android-tools/master@f5fcb9fd (dotnet#637) * dotnet/java-interop@857b9a9: [Java.Interop.Export] Begin supporting methods with 14+ params (dotnet#635) * dotnet/java-interop@9876e31: [Java.Interop.BootstrapTasks] Convert to SDK style project (dotnet#609) * dotnet/java-interop@cbb50af: [generator-Tests] Use Roslyn for .NET Core Support (dotnet#638) * dotnet/java-interop@56955d9: [generator] Use custom delegates instead of Func/Action. (dotnet#632) * dotnet/java-interop@0a77166: [Java.Interop.sln] Commit updated automatically generated guids. (dotnet#634)
Changes: dotnet/java-interop@ce8dc40...377c4c7 Fixes: dotnet/java-interop#631 * dotnet/java-interop@377c4c7: Bump to xamarin/xamarin-android-tools/master@f5fcb9fd (#637) * dotnet/java-interop@857b9a9: [Java.Interop.Export] Begin supporting methods with 14+ params (#635) * dotnet/java-interop@9876e31: [Java.Interop.BootstrapTasks] Convert to SDK style project (#609) * dotnet/java-interop@cbb50af: [generator-Tests] Use Roslyn for .NET Core Support (#638) * dotnet/java-interop@56955d9: [generator] Use custom delegates instead of Func/Action. (#632) * dotnet/java-interop@0a77166: [Java.Interop.sln] Commit updated automatically generated guids. (#634)
Changes: dotnet/java-interop@6608c59...e599781 Fixes: dotnet/java-interop#631 * dotnet/java-interop@e599781: Bump to xamarin/xamarin-android-tools/master@f5fcb9fd (#637) * dotnet/java-interop@b7aec95: [Java.Interop.Export] Begin supporting methods with 14+ params (#635) * dotnet/java-interop@eb6202b: [Java.Interop.BootstrapTasks] Convert to SDK style project (#609) * dotnet/java-interop@e078618: [generator-Tests] Use Roslyn for .NET Core Support (#638) * dotnet/java-interop@8e5310b: [generator] Use custom delegates instead of Func/Action. (#632) * dotnet/java-interop@f20f853: [Java.Interop.sln] Commit updated automatically generated guids. (#634)
tools/scripts/xabuildis an MSBuild wrapper to easily buildXamarin.Android apps from the command-line, using the Xamarin.Android
binaries built in-tree; see e20863e.
xabuildoriginally invokedxbuild; commit 6805d20 extended thatto support building with
msbuildby setting theMSBUILDenvironment variable:
This use worked with Mono 4.4 and 4.6, but broke -- unnoticed -- in
Mono 4.8 and later. When attempting to use
msbuildin more recentmono versions, the build will fail, cryptically:
The directory
/Debug/is mentioned because the$(BaseIntermediateOutputPath)MSBuild property is not being set.Normally we'd be creating e.g.
obj/Debug, but without$(BaseIntermediateOutputPath), this becomes/Debug, and everythingbreaks.
$(BaseIntermediateOutputPath)isn't set, in turn, becauseMicrosoft.Common.propsisn't being imported.Microsoft.Common.propsisn't being imported becausexabuildoverrides the
$MSBuildExtensionsPathenvironment variable, andMSBuild is trying to import
$(MSBuildExtensionsPath)\...\Microsoft.Common.props, which doesn'texist when we've overridden
$MSBuildExtensionsPathto use ourin-tree build location.
A fix for this could be not overriding
$MSBuildExtensionsPathwhen using
msbuild. There is one problem with this, though: notoverriding
$MSBuildExtensionsPathmeans that the.targetsfiles ine.g.
bin/Debug/lib/xbuild/Xamarin/Androidwill not be used.Instead, the system files are used, which is undesirable.
Unfortunatley, this means we need to continue overriding
$MSBuildExtensionsPath, while allowing e.g.$(MSBuildExtensionsPath)\...\Microsoft.Common.propsto be found.Square this circle by symlinking everything in the system
$MSBuildExtensionsPathdirectory into our$prefix/lib/xbuild.Symlinking all these files raises another issue: we don't want all
of these symlinks, or their targets, to be added to the
oss-xamarin.android*.zipfiles. Support this by creating a$prefix/lib/xbuild/.__sys_links.txtfile, which containszip -xpatterns (hence the
/*suffix for directories), one per line, andupdate the
make package-osstarget to look for and exclude thecontents of these files so that we don't "pollute" the
oss-xamarin.android*.zipfile with unnecessary contents.Finally, some cleanups:
Only set
$XBUILD_FRAMEWORK_FOLDERS_PATHwhen usingxbuild.Additionally, specify
$(TargetFrameworkRootPath)onmsbuild,as that actually works.
Always specify
$(MonoAndroidBinDirectory)and$(MonoAndroidToolsDirectory), as this mirrors theWindows usage instructions.
Don't require that
$ANDROID_NDK_PATHand$ANDROID_SDK_PATHbeset prior to executing
xabuild, or that we be running in-tree(to use
Paths.targets). The NDK, in particular, isn't alwaysrequired, so forcing that it be set is annoying.
The build process will error out appropriately if required
directories cannot be found.