diff --git a/src/NuGetizer.Tasks/EvaluateWildcards.cs b/src/NuGetizer.Tasks/EvaluateWildcards.cs
new file mode 100644
index 00000000..656aedef
--- /dev/null
+++ b/src/NuGetizer.Tasks/EvaluateWildcards.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Build.Framework;
+using Microsoft.Build.Utilities;
+using Minimatch;
+
+namespace NuGetizer.Tasks
+{
+ ///
+ /// Evaluates one or more minimatch expressions against a set of
+ /// items and returns two lists: those that matched and those that
+ /// didn't.
+ ///
+ public class EvaluateWildcards : Task
+ {
+ [Required]
+ public ITaskItem[] Items { get; set; }
+
+ [Required]
+ public string Wildcards { get; set; }
+
+ [Output]
+ public ITaskItem[] MatchingItems { get; set; }
+
+ [Output]
+ public ITaskItem[] NonMatchingItems { get; set; }
+
+ public override bool Execute()
+ {
+ var matching = new List();
+ var nonMatching = new List();
+
+ var options = new Options
+ {
+ AllowWindowsPaths = true,
+ Dot = true,
+ IgnoreCase = true
+ };
+
+ var matchers = Wildcards
+ .Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
+ .Select(wildcard => new Minimatcher(wildcard.Trim(), options))
+ .ToList();
+
+ foreach (var item in Items)
+ {
+ if (matchers.Any(matcher => matcher.IsMatch(item.ItemSpec)))
+ matching.Add(item);
+ else
+ nonMatching.Add(item);
+ }
+
+ MatchingItems = matching.ToArray();
+ NonMatchingItems = nonMatching.ToArray();
+
+ return true;
+ }
+ }
+}
diff --git a/src/NuGetizer.Tasks/Extensions.cs b/src/NuGetizer.Tasks/Extensions.cs
index b8682e4a..1ec4d29a 100644
--- a/src/NuGetizer.Tasks/Extensions.cs
+++ b/src/NuGetizer.Tasks/Extensions.cs
@@ -139,7 +139,7 @@ public static string GetShortFrameworkName(this FrameworkName frameworkName)
public static void LogErrorCode(this TaskLoggingHelper log, string code, string message, params object[] messageArgs) =>
log.LogError(string.Empty, code, string.Empty, string.Empty, 0, 0, 0, 0, message, messageArgs);
- public static void LogWarningCode(this TaskLoggingHelper log, string code, string file, string message, params object[] messageArgs) =>
- log.LogWarning(string.Empty, code, string.Empty, file, 0, 0, 0, 0, message, messageArgs);
+ public static void LogWarningCode(this TaskLoggingHelper log, string code, string message, params object[] messageArgs) =>
+ log.LogWarning(string.Empty, code, string.Empty, string.Empty, 0, 0, 0, 0, message, messageArgs);
}
}
diff --git a/src/NuGetizer.Tasks/NuGetizer.Inference.targets b/src/NuGetizer.Tasks/NuGetizer.Inference.targets
index 6a2a0774..41cd08fb 100644
--- a/src/NuGetizer.Tasks/NuGetizer.Inference.targets
+++ b/src/NuGetizer.Tasks/NuGetizer.Inference.targets
@@ -11,6 +11,7 @@ Copyright (c) .NET Foundation. All rights reserved.
-->
+
@@ -177,9 +178,22 @@ Copyright (c) .NET Foundation. All rights reserved.
-
+
+
+ %(PackInference.PackExclude)
+
+
+
+
+
+
+
+
+
+
+
+
-
true
diff --git a/src/NuGetizer.Tasks/NuGetizer.Tasks.csproj b/src/NuGetizer.Tasks/NuGetizer.Tasks.csproj
index 181f4d27..1a1f7c08 100644
--- a/src/NuGetizer.Tasks/NuGetizer.Tasks.csproj
+++ b/src/NuGetizer.Tasks/NuGetizer.Tasks.csproj
@@ -14,6 +14,7 @@
+
diff --git a/src/NuGetizer.Tests/given_packinference.cs b/src/NuGetizer.Tests/given_packinference.cs
index 15fadba2..6bc3a4fd 100644
--- a/src/NuGetizer.Tests/given_packinference.cs
+++ b/src/NuGetizer.Tests/given_packinference.cs
@@ -541,6 +541,34 @@ public void when_adding_new_inference_then_can_change_defaults()
}));
}
+ [Fact]
+ public void when_updating_inference_then_can_exclude_by_wildcard()
+ {
+ var result = Builder.BuildProject(@"
+
+
+ Library
+ netstandard2.0
+ true
+
+
+
+
+
+
+
+
+
+",
+ "GetPackageContents", output);
+
+ result.AssertSuccess(output);
+ Assert.DoesNotContain(result.Items, item => item.Matches(new
+ {
+ Filename = "grpc_csharp_ext.x86",
+ }));
+ }
+
[Fact]
public void when_direct_and_indirect_packagereference_then_packs_once()
{