-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Essentials.cs
54 lines (46 loc) · 1.86 KB
/
Essentials.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using EventBuilder.NuGet;
using NuGet.Packaging.Core;
using NuGet.Versioning;
using Serilog;
namespace EventBuilder.Platforms
{
/// <summary>
/// Xamarin Essentials platform.
/// </summary>
/// <seealso cref="EventBuilder.Platforms.BasePlatform" />
public class Essentials : BasePlatform
{
private readonly PackageIdentity[] _packageNames = new[]
{
new PackageIdentity("Xamarin.Essentials", new NuGetVersion("1.0.1")),
new PackageIdentity("NetStandard.Library", new NuGetVersion("2.0.0")),
};
/// <inheritdoc />
public override AutoPlatform Platform => AutoPlatform.Essentials;
/// <inheritdoc />
public override async Task Extract()
{
var packageUnzipPath = await NuGetPackageHelper.InstallPackages(_packageNames, Platform).ConfigureAwait(false);
Log.Debug($"Package unzip path is {packageUnzipPath}");
var xamarinForms =
Directory.GetFiles(
packageUnzipPath,
"Xamarin.Essentials.dll",
SearchOption.AllDirectories);
var latestVersion = xamarinForms.First(x => x.Contains("netstandard2.0", StringComparison.InvariantCulture));
Assemblies.Add(latestVersion);
foreach (var directory in Directory.GetDirectories(packageUnzipPath, "*.*", SearchOption.AllDirectories))
{
CecilSearchDirectories.Add(directory);
}
}
}
}