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
MSBuild is open source -- has been for ages -- and we'd *really* like
to migrate all things Mono to MSBuild and deprecate/remove `xbuild`.
Which means we need to ensure that all of our products build with
`msbuild`. [Which unfortunately isn't the case in `Java.Interop`][0]:
MSB3375: The file "../../bin/Release/Xamarin.Android.Cecil.dll" does not exist.
...
Java.Interop/MarshalMemberBuilder.cs(9,20): error CS0234:
The type or namespace name `Expressions' does not exist in the namespace `Java.Interop'. Are you missing an assembly reference?
...
36 Warning(s)
69 Error(s)
For starters, bring Java.Interop into aligntment/convention with the
[`xamarin-android` repo][1], so that `$(MSBUILD)` is the Make variable
to specify the MSBuild engine to use, not `$(XBUILD)`, and allow
`$(V)` to set `$MONO_OPTIONS` so that line numbers are included in
stack traces from mono.
Which brings us to the build errors. The MSB3375 error happens when
building e.g. `Xamarin.Android.Cecil.csproj` from another directory:
$ msbuild src/Xamarin.Android.Cecil/Xamarin.Android.Cecil.csproj
...
.../src/Xamarin.Android.Cecil/Xamarin.Android.Cecil.targets(33,5):
error MSB3375: The file "../../bin/Debug/Xamarin.Android.Cecil.dll" does not exist.
...
The cause, in turn, is because the nested `<MSBuild/>` invocation
overrides `$(OutputPath)` when building
`external/Cecil/Mono.Cecil.csproj` to be
*`Xamarin.Android.Cecil.csproj`'s* `$(OutputPath)`:
<PropertyGroup>
<CecilOutputPath>$([System.IO.Path]::GetFullPath ('$(OutputPath)'))</CecilOutputPath>
</PropertyGroup>
<MSBuild
Properties="OutputPath=$(CecilOutputPath)"
...
/>
Or rather, it *tries* to. It uses `Path.GetFullPath()` on
`$(OutputPath)` so that `Mono.Cecil.csproj` writes the assembly into
the expected `Xamarin.Android.Cecil.csproj`-specified directory. The
problem is that the `Path.GetFullPath()` call is relative to the
*current working directory*, so when:
1. The current working directory isn't the same directory as the
directory containing `Xamarin.Android.Cecil.csproj`, and
2. We're building `Xamarin.Android.Cecil.csproj`, which defines
`$(OutputPath)` as e.g. `..\..\Debug`
(1) and (2) interplay so that `$(CecilOutputPath)` becomes e.g.
`$CWD/../../bin/Debug`, which is *not* the correct directory, and may
(will!) be outside of the repo checkout directory.
Modify the `$(CecilOutputPath)` definition so that it instead assumes
that `$(OutputPath)` is a directory *relative to*
`$(MSBuildThisFileDirectory)`, equivalent to C#:
var OutputPath = ...
var MSBuildThisFileDirectory = ...
var CecilOutputPath = Path.Combine (MSBuildThisFileDirectory, OutputPath);
CecilOutputPath = Path.GetFullPath (CecilOutputPath);
This fixes the above interplay by "inserting" use of
`$(MSBuildThisFileDirectory)` into the "normal"
`msbuild Xamarin.Android.Cecil.csproj` invocation path, ensuring that
output paths behave as expected.
This in turn allows `Xamarin.Android.Cecil.dll` to be placed into the
correct directory, which in turn fixes all of the other C# errors
(present apparently because `Xamarin.Android.Cecil.dll` couldn't be
resolved).
[0]: https://jenkins.mono-project.com/view/Xamarin.Android/job/Java.Interop-msbuild/5/consoleText
[1]: https://github.com/xamarin/xamarin-android
0 commit comments