From 5301bb4e1dc651b13e84152e065838152574b81b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilfredo=20Vel=C3=A1zquez-Rodr=C3=ADguez?= Date: Sat, 3 Jun 2023 21:56:41 -0400 Subject: [PATCH] Allow for empty properties in dotnet msbuild Fixes #4158 --- .../MSBuildArgumentBuilderExtensions.cs | 5 ----- .../Tools/DotNet/DotNetAliases.cake | 20 +++++++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/Cake.Common/Tools/DotNet/MSBuild/MSBuildArgumentBuilderExtensions.cs b/src/Cake.Common/Tools/DotNet/MSBuild/MSBuildArgumentBuilderExtensions.cs index 68156d416b..cdd25b132b 100644 --- a/src/Cake.Common/Tools/DotNet/MSBuild/MSBuildArgumentBuilderExtensions.cs +++ b/src/Cake.Common/Tools/DotNet/MSBuild/MSBuildArgumentBuilderExtensions.cs @@ -55,11 +55,6 @@ public static void AppendMSBuildSettings(this ProcessArgumentBuilder builder, Do // Got any properties? foreach (var property in settings.Properties) { - if (property.Value == null || property.Value.All(string.IsNullOrWhiteSpace)) - { - throw new ArgumentException("A property must have at least one non-empty value", nameof(settings.Properties)); - } - msBuilder.AppendMSBuildSwitch("property", $"{property.Key}={property.BuildMSBuildPropertyParameterString()}"); } diff --git a/tests/integration/Cake.Common/Tools/DotNet/DotNetAliases.cake b/tests/integration/Cake.Common/Tools/DotNet/DotNetAliases.cake index 68b058a6d6..674d342a4d 100644 --- a/tests/integration/Cake.Common/Tools/DotNet/DotNetAliases.cake +++ b/tests/integration/Cake.Common/Tools/DotNet/DotNetAliases.cake @@ -223,6 +223,26 @@ Task("Cake.Common.Tools.DotNet.DotNetAliases.DotNetMSBuild") Assert.True(System.IO.File.Exists(assembly.FullPath)); }); +Task("Cake.Common.Tools.DotNet.DotNetAliases.DotNetMSBuildEmptyParametersAllowed") + .IsDependentOn("Cake.Common.Tools.DotNet.DotNetAliases.DotNetClean") + .Does(() => +{ + // Given + var path = Paths.Temp.Combine("./Cake.Common/Tools/DotNet"); + var project = path.CombineWithFilePath("hwapp/hwapp.csproj"); + var assembly = path.CombineWithFilePath("hwapp/bin/Debug/net7.0/hwapp.dll"); + + // When + DotNetMSBuild(project.FullPath, new DotNetBuildSettings() { + MSBuildSettings = new DotNetMSBuildSettings(){ + } + .WithProperty("APropertyIWantTobeBlank", "") + }); + + // Then + Assert.True(true); +}); + Task("Cake.Common.Tools.DotNet.DotNetAliases.DotNetTest.Fail") .IsDependentOn("Cake.Common.Tools.DotNet.DotNetAliases.DotNetTest") .Does(() =>