Skip to content

Commit ac8b4f4

Browse files
committed
refactor: Cleanup code, comments, and messages a bit.
1 parent 4680579 commit ac8b4f4

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

Set-ProjectFilesClickOnceVersion.ps1

+15-17
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
Param
8383
(
8484
[Parameter(Mandatory=$true,HelpMessage="The project file to update the ClickOnce Version in.")]
85-
[string]$ProjectFilePath = '',
85+
[string]$ProjectFilePath = [string]::Empty,
8686

8787
[Parameter(Mandatory=$false,HelpMessage="The new version number to use for the ClickOnce application.")]
8888
[ValidatePattern('(?i)(^(\d+(\.\d+){2,3})$)')]
@@ -101,10 +101,10 @@ Param
101101
[switch]$UpdateMinimumRequiredVersionToCurrentVersion = $false,
102102

103103
[Parameter(Mandatory = $false, HelpMessage="The Publish URL to update to.")]
104-
[string]$PublishUrl = '',
104+
[string]$PublishUrl = [string]::Empty,
105105

106106
[Parameter(Mandatory = $false, HelpMessage="The Install URL to update to.")]
107-
[string]$InstallUrl = ''
107+
[string]$InstallUrl = [string]::Empty
108108
)
109109

110110
# If we can't find the project file path to update, exit with an error.
@@ -115,9 +115,9 @@ if (!(Test-Path $ProjectFilePath -PathType Leaf))
115115
}
116116

117117
# If there are no changes to make, just exit.
118-
if ([string]::IsNullOrEmpty($Version) -and $BuildSystemsBuildId -lt 0 -and !$IncrementProjectFilesRevision -and !$UpdateMinimumRequiredVersionToCurrentVersion -and !$InstallUrl -and !$PublishUrl)
118+
if ([string]::IsNullOrEmpty($Version) -and $BuildSystemsBuildId -lt 0 -and !$IncrementProjectFilesRevision -and !$UpdateMinimumRequiredVersionToCurrentVersion -and [string]::IsNullOrEmpty($InstallUrl) -and [string]::IsNullOrEmpty($PublishUrl))
119119
{
120-
Write-Warning "None of the following parameters were provided, so nothing will be changed: Version, BuildSystemsBuildId, IncrementProjectFilesRevision, UpdateMinimumRequiredVersionToCurrentVersion, InstallUrl and PublishUrl"
120+
Write-Warning "None of the following parameters were provided, so nothing will be changed: Version, BuildSystemsBuildId, IncrementProjectFilesRevision, UpdateMinimumRequiredVersionToCurrentVersion, InstallUrl, and PublishUrl"
121121
return
122122
}
123123

@@ -246,22 +246,20 @@ foreach ($clickOncePropertyGroup in $clickOncePropertyGroups)
246246
$numberOfClickOncePropertyGroupsProcessed++
247247
Write-Verbose "Processing ClickOnce property group $numberOfClickOncePropertyGroupsProcessed of $numberOfClickOncePropertyGroups in file '$ProjectFilePath'."
248248

249-
# If publish url is provided, update it
250-
$publishUrl = $PublishUrl
251-
if (![string]::IsNullOrEmpty($publishUrl))
249+
# If publish url is provided, update it.
250+
if (![string]::IsNullOrEmpty($PublishUrl))
252251
{
253-
Write-Verbose "Publish Url is '$publishUrl'"
254-
Write-Output "Updating PublishUrl to be '$publishUrl'"
255-
Set-XmlNodesElementTextValue -xml $xml -node $clickOncePropertyGroup -elementName 'PublishUrl' -textValue "$publishUrl"
252+
Write-Verbose "Publish Url is '$PublishUrl'"
253+
Write-Output "Updating PublishUrl to be '$PublishUrl'"
254+
Set-XmlNodesElementTextValue -xml $xml -node $clickOncePropertyGroup -elementName 'PublishUrl' -textValue "$PublishUrl"
256255
}
257256

258-
# If install url is provided, update it
259-
$installUrl = $InstallUrl
260-
if (![string]::IsNullOrEmpty($installUrl))
257+
# If install url is provided, update it.
258+
if (![string]::IsNullOrEmpty($InstallUrl))
261259
{
262-
Write-Verbose "Install Url is '$installUrl'"
263-
Write-Output "Updating Install Url to be '$installUrl'"
264-
Set-XmlNodesElementTextValue -xml $xml -node $clickOncePropertyGroup -elementName 'InstallUrl' -textValue "$installUrl"
260+
Write-Verbose "Install Url is '$InstallUrl'"
261+
Write-Output "Updating Install Url to be '$InstallUrl'"
262+
Set-XmlNodesElementTextValue -xml $xml -node $clickOncePropertyGroup -elementName 'InstallUrl' -textValue "$InstallUrl"
265263
}
266264

267265
# If the Version to use was not provided, get it from the project file.

0 commit comments

Comments
 (0)