From 89a4daec59521c794ba5b7a457697af41059a2e6 Mon Sep 17 00:00:00 2001 From: Danny Song Date: Tue, 24 Sep 2024 15:11:37 -0700 Subject: [PATCH] Fix bug to allow params to be toggled off Update ChangeLog --- src/Websites/Websites/ChangeLog.md | 1 + .../Websites/Cmdlets/WebApps/PublishAzureWebApp.cs | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Websites/Websites/ChangeLog.md b/src/Websites/Websites/ChangeLog.md index 6ef53d1ce93f..36ce443a5738 100644 --- a/src/Websites/Websites/ChangeLog.md +++ b/src/Websites/Websites/ChangeLog.md @@ -18,6 +18,7 @@ - Additional information about change #1 --> ## Upcoming Release +* Fix bug where parameters could not be set to false for `Publish-AzWebApp` ## Version 3.2.1 * Introduced secrets detection feature to safeguard sensitive data. diff --git a/src/Websites/Websites/Cmdlets/WebApps/PublishAzureWebApp.cs b/src/Websites/Websites/Cmdlets/WebApps/PublishAzureWebApp.cs index 1c840fc458d6..d18da15506c1 100644 --- a/src/Websites/Websites/Cmdlets/WebApps/PublishAzureWebApp.cs +++ b/src/Websites/Websites/Cmdlets/WebApps/PublishAzureWebApp.cs @@ -119,33 +119,34 @@ public override void ExecuteCmdlet() paramValues.Add("path", TargetPath); + // Purposely using IsParameterBound to check if the parameter is passed or not. In this case we want to return true if $false is passed. + // We only want to set the parameter if a value is passed. // default async to true if not provided to match old behavior - if (Async.IsPresent) + if (this.IsParameterBound(c => c.Async)) { paramValues.Add("async", Async.ToString()); } - else { paramValues.Add("async", "true"); } - if (Restart.IsPresent) + if (this.IsParameterBound(c => c.Restart)) { paramValues.Add("restart", Restart.ToString()); } - if (Clean.IsPresent) + if (this.IsParameterBound(c => c.Clean)) { paramValues.Add("clean", Clean.ToString()); } - if (IgnoreStack.IsPresent) + if (this.IsParameterBound(c => c.IgnoreStack)) { paramValues.Add("ignorestack", IgnoreStack.ToString()); } - if (Reset.IsPresent) + if (this.IsParameterBound(c => c.Reset)) { paramValues.Add("reset", Reset.ToString()); }