Skip to content

Commit

Permalink
Allow for empty properties in dotnet msbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
Zulu-Inuoe committed Jun 4, 2023
1 parent b55239f commit 5301bb4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()}");
}

Expand Down
20 changes: 20 additions & 0 deletions tests/integration/Cake.Common/Tools/DotNet/DotNetAliases.cake
Original file line number Diff line number Diff line change
Expand Up @@ -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(() =>
Expand Down

0 comments on commit 5301bb4

Please sign in to comment.