-
Notifications
You must be signed in to change notification settings - Fork 533
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy FSharp support assemblies from nuget
Instead of building F# from sources as we've been doing so far, we'll now use a nuget to get the binaries we require. This makes the build time much shorter.
- Loading branch information
Showing
4 changed files
with
106 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 string 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 = 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; | ||
} | ||
} | ||
} |