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

Conversation

dellis1972
Copy link
Contributor

@dellis1972 dellis1972 commented Oct 17, 2017

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 erroring 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 mac 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.

@@ -21,6 +21,10 @@ public static bool Create (string source, string target)
}
} 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.

return Path.GetFullPath (Path.Combine (Root, "..", "..", "tools", "scripts", "xabuild"));
var xaBuildPath = Path.GetFullPath (Path.Combine (Root, "..", "..", "tools", "scripts", "xabuild"));
if (!File.Exists (xaBuildPath))
xaBuildPath = Path.GetFullPath (Path.Combine (Root, "..", "..", "..", "..", "..", "..", "..", "tools", "scripts", "dbuild"));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should fix the unit tests in monodroid.

return true;
}
Console.Error.WriteLine ($"Unable to create symbolic link from `{source}` to `{target}`: {exc}");
return Directory.Exists (source);
Copy link
Member

Choose a reason for hiding this comment

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

I think if we add the same return Directory.Exists (source) for Windows, we're good.

I tested what happens on Windows if you try to create a symlink (and it already exists). It gives a generic error message The system cannot find the file specified, so we don't have a way to check for the specific error condition.

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 erroring 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 mac 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.
@jonpryor jonpryor merged commit b529d17 into dotnet:master Oct 17, 2017
Redth pushed a commit to Redth/xamarin-android that referenced this pull request Oct 30, 2017
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.
@github-actions github-actions bot locked and limited conversation to collaborators Feb 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants