Skip to content
This repository was archived by the owner on Jan 10, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Nue/Nue.Core/PackageAtom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public class PackageAdditionalProperties
[JsonProperty("tfm")]
public string TFM { get; set; }

[JsonProperty("includedDlls")]
public List<Regex> IncludedDlls { get; set; }

[JsonProperty("excludedDlls")]
public List<Regex> ExcludedDlls { get; set; }
}
Expand Down
123 changes: 77 additions & 46 deletions Nue/Nue.StandardResolver/Resolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,53 +132,84 @@ public bool CopyBinarySet(
// differently givent that the structure is not at all reflective of what other NuGet packages encompass.
if (package.IsPowerShellPackage)
{
Console.WriteLine($"[info] Treating {package.Name} as a PowerShell package.");

var helpXmlFiles = from c in Directory.GetFiles(pacManPackageLibPath)
where Path.GetFileName(c).ToLower().EndsWith("-help.xml")
select c;

var dllFiles = new List<string>();

foreach (var helpXmlFile in helpXmlFiles)
{
var workingDll = Path.GetFileName(helpXmlFile).ToLower().Replace("-help.xml", "");
if (File.Exists(Path.Combine(pacManPackageLibPath, workingDll)))
{
dllFiles.Add(workingDll);
}
Console.WriteLine($"[info] Treating {package.Name} as a PowerShell package.");

var dllFiles = new List<string>();
if (package.CustomProperties.IncludedDlls != null && package.CustomProperties.IncludedDlls.Count != 0)
{
dllFiles = Directory.GetFiles(pacManPackageLibPath, "*.*", SearchOption.AllDirectories)
.Where(s => s.EndsWith(".dll")).ToList();

foreach (var dll in dllFiles)
{
var test = package.CustomProperties.IncludedDlls.Any(d => d.IsMatch(Path.GetFileName(dll)));

if (package.CustomProperties.IncludedDlls.Any(d => d.IsMatch(Path.GetFileName(dll))) && (
package.CustomProperties.ExcludedDlls == null ||
package.CustomProperties.ExcludedDlls.Count == 0 ||
!package.CustomProperties.ExcludedDlls.Any(d => d.IsMatch(Path.GetFileName(dll)))))
{
File.Copy(dll,
Path.Combine(packageContainerPath, Path.GetFileName(dll)),
true);
}
else
{
if (!Directory.Exists(packageDependencyContainerPath))
{
Directory.CreateDirectory(packageDependencyContainerPath);
}

File.Copy(dll, Path.Combine(packageDependencyContainerPath, Path.GetFileName(dll)), true);
}
}
}

if (dllFiles.Any())
{
foreach (var dll in dllFiles)
{
File.Copy(Path.Combine(pacManPackageLibPath, dll), Path.Combine(packageContainerPath, dll), true);
//File.Copy(Path.Combine(pacManPackageLibPath, dll + "-help.xml"), Path.Combine(packageContainerPath, Path.GetFileNameWithoutExtension(dll) + ".xml"), true);
}

var dependencies = (from c in Directory.GetFiles(pacManPackageLibPath)
where !dllFiles.Contains(Path.GetFileName(c).ToLower()) && Path.GetFileName(c).EndsWith(".dll")
select c).ToList();
if ((tfm.StartsWith("net46") || tfm.StartsWith("net47") || tfm.StartsWith("net48"))
&& Directory.Exists(Path.Combine(pacManPackageLibPath, "PreloadAssemblies")))
{
dependencies.AddRange(Directory.GetFiles(Path.Combine(pacManPackageLibPath, "PreloadAssemblies")));
}
if (tfm.StartsWith("netcoreapp")
&& Directory.Exists(Path.Combine(pacManPackageLibPath, "NetCoreAssemblies")))
{
dependencies.AddRange(Directory.GetFiles(Path.Combine(pacManPackageLibPath, "NetCoreAssemblies")));
}
if (dependencies.Count > 0)
{
Directory.CreateDirectory(packageDependencyContainerPath);

foreach (var dependency in dependencies)
{

File.Copy(dependency, Path.Combine(packageDependencyContainerPath, Path.GetFileName(dependency)), true);
}
else
{
var helpXmlFiles = from c in Directory.GetFiles(pacManPackageLibPath)
where Path.GetFileName(c).ToLower().EndsWith("-help.xml")
select c;

foreach (var helpXmlFile in helpXmlFiles)
{
var workingDll = Path.GetFileName(helpXmlFile).ToLower().Replace("-help.xml", "");
if (File.Exists(Path.Combine(pacManPackageLibPath, workingDll)))
{
dllFiles.Add(workingDll);
}
}

if (dllFiles.Any())
{
foreach (var dll in dllFiles)
{
File.Copy(Path.Combine(pacManPackageLibPath, dll), Path.Combine(packageContainerPath, dll), true);
//File.Copy(Path.Combine(pacManPackageLibPath, dll + "-help.xml"), Path.Combine(packageContainerPath, Path.GetFileNameWithoutExtension(dll) + ".xml"), true);
}

var dependencies = (from c in Directory.GetFiles(pacManPackageLibPath)
where !dllFiles.Contains(Path.GetFileName(c).ToLower()) && Path.GetFileName(c).EndsWith(".dll")
select c).ToList();
if ((tfm.StartsWith("net46") || tfm.StartsWith("net47") || tfm.StartsWith("net48"))
&& Directory.Exists(Path.Combine(pacManPackageLibPath, "PreloadAssemblies")))
{
dependencies.AddRange(Directory.GetFiles(Path.Combine(pacManPackageLibPath, "PreloadAssemblies")));
}
if (tfm.StartsWith("netcoreapp")
&& Directory.Exists(Path.Combine(pacManPackageLibPath, "NetCoreAssemblies")))
{
dependencies.AddRange(Directory.GetFiles(Path.Combine(pacManPackageLibPath, "NetCoreAssemblies")));
}
if (dependencies.Count > 0)
{
Directory.CreateDirectory(packageDependencyContainerPath);

foreach (var dependency in dependencies)
{

File.Copy(dependency, Path.Combine(packageDependencyContainerPath, Path.GetFileName(dependency)), true);
}
}
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions Nue/Nue/Core/Extractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ public static void PreparePropertyBag(IEnumerable<PackageAtom> packages)
package.CustomProperties.CustomFeed = feedVal;
}

if (package.CustomPropertyBag.TryGetValue("includedDlls", out string includedDllVal))
{
if (!string.IsNullOrEmpty(includedDllVal) && package.IsPowerShellPackage)
{
var includedDlls = includedDllVal.Split('|');
package.CustomProperties.IncludedDlls = includedDlls.Select(e => Helpers.WildCardToRegex(e)).ToList();
}
}

if (package.CustomPropertyBag.TryGetValue("excludedDlls", out string excludedDllVal))
{
if (!string.IsNullOrEmpty(excludedDllVal))
Expand Down