diff --git a/source/Nuke.Build/Execution/DelegateRequirementService.cs b/source/Nuke.Build/Execution/DelegateRequirementService.cs index 641a6117e..851b8834a 100644 --- a/source/Nuke.Build/Execution/DelegateRequirementService.cs +++ b/source/Nuke.Build/Execution/DelegateRequirementService.cs @@ -25,8 +25,8 @@ public static void ValidateRequirements(INukeBuild build, IReadOnlyCollection> boolExpression) // TODO: same as HasSkippingCondition.GetSkipReason Assert.True(boolExpression.Compile().Invoke(), $"Target '{target.Name}' requires '{requirement.Body}'"); - else if (IsMemberNull(requirement.GetMemberInfo(), build, target)) - Assert.Fail($"Target '{target.Name}' requires member '{GetMemberName(requirement.GetMemberInfo())}' to be not null"); + else if (IsMemberNullOrEmpty(requirement.GetMemberInfo(), build, target)) + Assert.Fail($"Target '{target.Name}' requires member '{GetMemberName(requirement.GetMemberInfo())}' to be not null or empty"); } var requiredMembers = ValueInjectionUtility.GetInjectionMembers(build.GetType()) @@ -34,12 +34,12 @@ public static void ValidateRequirements(INukeBuild build, IReadOnlyCollection x.HasCustomAttribute()); foreach (var member in requiredMembers) { - if (IsMemberNull(member, build)) - Assert.Fail($"Member '{GetMemberName(member)}' is required to be not null"); + if (IsMemberNullOrEmpty(member, build)) + Assert.Fail($"Member '{GetMemberName(member)}' is required to be not null or empty"); } } - private static bool IsMemberNull(MemberInfo member, INukeBuild build, ExecutableTarget target = null) + private static bool IsMemberNullOrEmpty(MemberInfo member, INukeBuild build, ExecutableTarget target = null) { member = member.DeclaringType != build.GetType() ? build.GetType().GetMember(member.Name).SingleOrDefault() ?? member @@ -52,7 +52,9 @@ private static bool IsMemberNull(MemberInfo member, INukeBuild build, Executable if (build.Host is Terminal) TryInjectValueInteractive(member, build); - return member.GetValue(build) == null; + return member.GetMemberType() != typeof(string) + ? member.GetValue(build) == null + : member.GetValue(build).IsNullOrWhiteSpace(); } private static void TryInjectValueInteractive(MemberInfo member, INukeBuild build)