cake-build / cake

:cake: Cake (C# Make) is a cross platform build automation system.
https://cakebuild.net
MIT License
3.85k stars 724 forks source link

Cannot specify empty properties when using DotNetBuild #4158

Open Zulu-Inuoe opened 1 year ago

Zulu-Inuoe commented 1 year ago

Prerequisites

Cake runner

Cake .NET Tool

Cake version

3.0.0

Operating system

Windows

Operating system architecture

64-Bit

CI Server

Jenkins

What are you seeing?

And I receive the error that A property must have at least one non-empty value

In my build.cake file I have the following:

DotNetBuild("./My.sln", new DotNetBuildSettings() {
    MSBuildSettings = new DotNetMSBuildSettings() {
    }
    .WithProperty("PackageCertificateThumbprint", "")
});

Looking at the source https://github.com/cake-build/cake/blob/b55239f748f921edc303d644839183e9727e00a4/src/Cake.Common/Tools/DotNet/MSBuild/MSBuildArgumentBuilderExtensions.cs#LL58C1-L61C18

this is presumably intentional. However, setting this property as empty is in fact desired. see https://learn.microsoft.com/en-us/windows/uwp/packaging/auto-build-package-uwp-apps

Specifically:

The PackageCertificateThumbprint argument is intentionally set to an empty string as a precaution. If the thumbprint is set in the project but does not match the signing certificate, the build will fail with the error: Certificate does not match supplied signing thumbprint.

Is there any reason why we cannot set empty properties? Note that this problem is not there when using the MSBuild tool, rather than DotNetBuild

Seems like an easy fix but it's odd this check is in there to begin with

What is expected?

That I build and end up with /p:PackageCertificateThumbprint ""

Steps to Reproduce

DotNetBuild("./My.sln", new DotNetBuildSettings() {
    MSBuildSettings = new DotNetMSBuildSettings() {
    }
    .WithProperty("PackageCertificateThumbprint", "")
});

Output log

No response

augustoproiete commented 1 year ago

Thanks @Zulu-Inuoe for reporting. It makes sense to allow for empty string values set explicitly. Let us know if you'll submit a PR or if we should leave this up-for-grabs

Zulu-Inuoe commented 1 year ago

Hey @augustoproiete sorry for the delay - Yes I will take a look at this while I can and open up a PR either today or tomorrow. But I won't complain if somebody else gets it done before I do!