[xabuild] Multiple Symlinking xabuilds (#940)
This commit fixes a couple of issues which appeared when using `xabuild.exe` on macOS. Firstly if the symlink exists already the SymbolicLink code will error out and fail the build completely. This happens because if you run two or more `xabuild.exe` instances at the same time they trip over each other trying to create the symlink. So rather than error'ing completely we should only error if the link does NOT exist. If it does exist after an attempted creation we should ignore the exception. The other is about where we look for extensions. Xamarin.Android is installed on macOS into /Library/Frameworks/Mono.framework/External/xbuild this was not included in the search path for MSBuild, so it never manages to find the required `.targets` files.
This commit is contained in:
Родитель
d6ac14ff7a
Коммит
b529d17617
|
@ -16,15 +16,21 @@ namespace Xamarin.Android.Build
|
|||
if (!CreateSymbolicLink (source, target, SymbolLinkFlag.Directory | SymbolLinkFlag.AllowUnprivilegedCreate) &&
|
||||
!CreateSymbolicLink (source, target, SymbolLinkFlag.Directory)) {
|
||||
var error = new Win32Exception ().Message;
|
||||
var result = Directory.Exists (source);
|
||||
if (!result)
|
||||
Console.Error.WriteLine ($"Unable to create symbolic link from `{source}` to `{target}`: {error}");
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
var sourceInfo = new UnixFileInfo (source);
|
||||
var fileInfo = new UnixFileInfo (target);
|
||||
fileInfo.CreateSymbolicLink (source);
|
||||
} catch (Exception exc) {
|
||||
Console.Error.WriteLine ($"Unable to create symbolic link from `{source}` to `{target}`: {exc.Message}");
|
||||
} catch (UnixIOException exc) {
|
||||
if (exc.ErrorCode == Mono.Unix.Native.Errno.EEXIST) {
|
||||
return true;
|
||||
}
|
||||
Console.Error.WriteLine ($"Unable to create symbolic link from `{source}` to `{target}`: {exc}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,10 +114,11 @@ namespace Xamarin.Android.Build
|
|||
SearchPathsOS = "windows";
|
||||
} else {
|
||||
string mono = IsMacOS ? "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono" : "/usr/lib/mono";
|
||||
string monoExternal = IsMacOS ? "/Library/Frameworks/Mono.framework/External/" : "/usr/lib/mono";
|
||||
MSBuildPath = Path.Combine (mono, "msbuild");
|
||||
MSBuildBin = Path.Combine (MSBuildPath, "15.0", "bin");
|
||||
MSBuildConfig = Path.Combine (MSBuildBin, "MSBuild.dll.config");
|
||||
ProjectImportSearchPaths = new [] { MSBuildPath, Path.Combine (mono, "xbuild") };
|
||||
ProjectImportSearchPaths = new [] { MSBuildPath, Path.Combine (mono, "xbuild"), Path.Combine (monoExternal, "xbuild") };
|
||||
SystemProfiles = Path.Combine (mono, "xbuild-frameworks");
|
||||
XABuildConfig = Path.Combine (XABuildDirectory, "MSBuild.dll.config");
|
||||
SearchPathsOS = IsMacOS ? "osx" : "unix";
|
||||
|
|
Загрузка…
Ссылка в новой задаче