Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for empty properties in dotnet msbuild #4165

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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
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