-
Notifications
You must be signed in to change notification settings - Fork 564
[Xamarin.Android.Build.Tasks] Use correct Mono.Android.dll #147
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| using System; | ||
| using System.IO; | ||
| using System.Linq; | ||
|
|
||
| using Microsoft.Build.Utilities; | ||
| using Microsoft.Build.Framework; | ||
|
|
||
| namespace Xamarin.Android.Tasks | ||
| { | ||
| public sealed class SetMSBuildExtensionsPath : Task | ||
| { | ||
| const string MSBuildExtensionsPath = "MSBuildExtensionsPath"; | ||
| const string XBUILD_FRAMEWORK_FOLDERS_PATH = "XBUILD_FRAMEWORK_FOLDERS_PATH"; | ||
| public override bool Execute () | ||
| { | ||
| var frameworksPath = Path.GetDirectoryName (typeof (SetMSBuildExtensionsPath).Assembly.Location); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is this task being loaded from? Can this path that we are trying to determine here, be computed in the targets and passed as input here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The task is being loaded from wherever |
||
| if (Path.DirectorySeparatorChar == '\\') { | ||
| // TODO: Default Windows search location | ||
| } else { | ||
| // e == $prefix/lib/xbuild/Xamarin/Android | ||
| // Want: $prefix/lib/xbuild-frameworks | ||
| if (!frameworksPath.EndsWith ("xbuild/Xamarin/Android", StringComparison.OrdinalIgnoreCase)) { | ||
| throw new NotSupportedException ("Cannot determine path to xbuild-frameworks!"); | ||
| } | ||
| frameworksPath = Path.GetDirectoryName (Path.GetDirectoryName (Path.GetDirectoryName (frameworksPath))); | ||
| frameworksPath = Path.Combine (frameworksPath, "xbuild-frameworks"); | ||
| } | ||
|
|
||
| UpdateEnvironmentVariable (MSBuildExtensionsPath, frameworksPath); | ||
| UpdateEnvironmentVariable (XBUILD_FRAMEWORK_FOLDERS_PATH, frameworksPath); | ||
|
|
||
| return !Log.HasLoggedErrors; | ||
| } | ||
|
|
||
| void UpdateEnvironmentVariable (string environmentVariable, string newPath) | ||
| { | ||
| var p = (Environment.GetEnvironmentVariable (environmentVariable) ?? "") | ||
| .Split (new [] { Path.PathSeparator }, StringSplitOptions.RemoveEmptyEntries); | ||
| if (p.Any (x => string.Equals (x, newPath, StringComparison.OrdinalIgnoreCase))) { | ||
| return; | ||
| } | ||
|
|
||
| var newValue = string.Join (Path.PathSeparator.ToString (), new [] { newPath }.Concat (p)); | ||
| Log.LogMessage (MessageImportance.Low, $" Setting environment variable `{environmentVariable}`='{newValue}'."); | ||
| Environment.SetEnvironmentVariable (environmentVariable, newValue); | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name seems to suggest that it sets the path to some given path. Since, it's trying to compute it internally, maybe it should renamed to indicate what it is doing or setting the path to?