-
Notifications
You must be signed in to change notification settings - Fork 541
Copy FSharp support assemblies from nuget #21
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...roid.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/GetNugetPackageBasePath.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Xml; | ||
|
||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
|
||
namespace Xamarin.Android.Tools.BootstrapTasks | ||
{ | ||
public class GetNugetPackageBasePath : Task | ||
{ | ||
[Required] | ||
public ITaskItem [] PackageConfigFiles { get; set; } | ||
|
||
[Required] | ||
public string PackageName { get; set; } | ||
|
||
[Output] | ||
public ITaskItem BasePath { get; set; } | ||
|
||
public override bool Execute () | ||
{ | ||
Log.LogMessage (MessageImportance.Low, "Task GetNugetPackageBasePath"); | ||
Log.LogMessage (MessageImportance.Low, "\tPackageName : {0}", PackageName); | ||
Log.LogMessage (MessageImportance.Low, "\tPackageConfigFiles : "); | ||
foreach (ITaskItem file in PackageConfigFiles) { | ||
Log.LogMessage (MessageImportance.Low, "\t\t{0}", file.ItemSpec); | ||
} | ||
|
||
Version latest = null; | ||
foreach (string file in PackageConfigFiles.Select (x => Path.GetFullPath (x.ItemSpec)).Distinct ().OrderBy (x => x)) { | ||
if (!File.Exists (file)) { | ||
Log.LogWarning ("\tPackages config file {0} not found", file); | ||
continue; | ||
} | ||
|
||
Version tmp = GetPackageVersion (file); | ||
if (latest != null && latest >= tmp) | ||
continue; | ||
latest = tmp; | ||
} | ||
|
||
if (latest == null) | ||
Log.LogError ("NuGet Package '{0}' not found", PackageName); | ||
else | ||
BasePath = new TaskItem (Path.Combine ("packages", $"{PackageName}.{latest}")); | ||
Log.LogMessage (MessageImportance.Low, $"BasePath == {BasePath}"); | ||
return !Log.HasLoggedErrors; | ||
} | ||
|
||
Version GetPackageVersion (string packageConfigFile) | ||
{ | ||
Version ret = null; | ||
var doc = new XmlDocument (); | ||
doc.Load (packageConfigFile); | ||
|
||
XmlNodeList nodes = doc.DocumentElement.SelectNodes ($"./package[@id='{PackageName}']"); | ||
foreach (XmlNode n in nodes) { | ||
var e = n as XmlElement; | ||
if (e == null) | ||
continue; | ||
|
||
Version tmp; | ||
if (!Version.TryParse (e.GetAttribute ("version"), out tmp)) | ||
continue; | ||
if (ret != null && ret >= tmp) | ||
continue; | ||
ret = tmp; | ||
} | ||
|
||
return ret; | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why introduce and use
$(_SourceTopDir)
?Related: as part of monodroid integration, we may want to create a "toplevel"
$(MonoPath)
property that is the path to the Mono checkout to use, in lieu of usinggit submodule update
, along with Java.Interop, so that we can bump mono/etc. without axamarin-android
commit. (Useful for a "rebuild xamarin-android with mono/master..." lane.)As such, we may want to just do that now, possibly by altering
Condfiguration.props
with:so that we have an absolute path.
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.
$(_SourceTopDir)
- I don't like hard-coded constants all over the "code", makes it error prone should the value had to be changed. Plus, it makes reading the code easier.I thought about MonoPath, just didn't want to introduce it in this diff as it is unrelated. I will open a separate PR for this.