Skip to content
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

[Xamarin.Android.Build.Tasks] Updates for xabuild.exe #940

Merged
merged 1 commit into from
Oct 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions tools/xabuild/SymbolicLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,21 @@ public static bool Create (string source, string target)
if (!CreateSymbolicLink (source, target, SymbolLinkFlag.Directory | SymbolLinkFlag.AllowUnprivilegedCreate) &&
!CreateSymbolicLink (source, target, SymbolLinkFlag.Directory)) {
var error = new Win32Exception ().Message;
Console.Error.WriteLine ($"Unable to create symbolic link from `{source}` to `{target}`: {error}");
return false;
var result = Directory.Exists (source);
if (!result)
Console.Error.WriteLine ($"Unable to create symbolic link from `{source}` to `{target}`: {error}");
return result;
}
} else {
try {
var sourceInfo = new UnixFileInfo (source);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's odd, it sounds like this Directory.Exists check isn't working. Is there a test/app I can try to see this breaking?

Is there a way to do this where the symbolic link is recreated on Windows, too? Is delete directory/recreate the link the only way to do that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea how this would work on windows.
I hit this by running the msbuild unit tests using MSBUILD=msbuild.
so just using MSBUILD=msbuild xabuild should repo the problem.

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;
}
}
Expand Down
3 changes: 2 additions & 1 deletion tools/xabuild/XABuildPaths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,11 @@ public XABuildPaths ()
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";
Expand Down