You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Added the ability to pass in either the publish url or install
url and it will update the csproj file. If no parameter is provided
they will remain the same
- Switched around some right side null comparisons to left ones
due to warning encountered from VS Code and after doing a little research.
Found this article https://rencore.com/blog/powershell-null-comparison/
- Added tests for the publish url and install parameters
- Added test for using both the Version parameter and the BuildId
parameter. Passing in 1.0.0.0 as the Version and along with a BuildId
the version will keep the hardcoded major/minor(1.0) and update the
build/revision(0.0) with the autogenerated id
Copy file name to clipboardExpand all lines: Set-ProjectFilesClickOnceVersion.ps1
+49-8Lines changed: 49 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,12 @@
29
29
If this switch is provided, the ClickOnce MinimumRequiredVersion will be updated to match the new Version.
30
30
Setting the MinimumRequiredVersion property forces the ClickOnce application to update automatically without prompting the user.
31
31
32
+
.PARAMETERPublishUrl
33
+
If this string is provided, it will update the PublishUrl. If it is not provided, the PublishUrl will remain what it is currently. This should be a UNC type file path (e.g. \\servername\foldername)
34
+
35
+
.PARAMETERInstallUrl
36
+
If this string is provided, it will update the InstallUrl. If it is not provided the InstallUrl will remain what it is currently. This should be a URL type path (e.g. http://servername/foldername)
37
+
32
38
.EXAMPLE
33
39
Update a project file's ClickOnce version to the specified version.
Update a project file's ClickOnce version using both Version and a unique, auto-incrementing integer, such as a build system's Build ID. This will keep the major and minor versions you specify but update the build and revision (e.g. 1.0.1.5745)
[Parameter(Mandatory=$false,HelpMessage="The Publish URL to update to.")]
104
+
[string]$PublishUrl='',
105
+
106
+
[Parameter(Mandatory=$false,HelpMessage="The Install URL to update to.")]
107
+
[string]$InstallUrl=''
85
108
)
86
109
87
110
# If we can't find the project file path to update, exit with an error.
@@ -92,16 +115,16 @@ if (!(Test-Path $ProjectFilePath -PathType Leaf))
92
115
}
93
116
94
117
# If there are no changes to make, just exit.
95
-
if ([string]::IsNullOrEmpty($Version) -and$BuildSystemsBuildId-lt0-and!$IncrementProjectFilesRevision-and!$UpdateMinimumRequiredVersionToCurrentVersion)
118
+
if ([string]::IsNullOrEmpty($Version) -and$BuildSystemsBuildId-lt0-and!$IncrementProjectFilesRevision-and!$UpdateMinimumRequiredVersionToCurrentVersion-and!$InstallUrl-and!$PublishUrl)
96
119
{
97
-
Write-Warning"None of the following parameters were provided, so nothing will be changed: Version, BuildSystemsBuildId, IncrementProjectFilesRevision, UpdateMinimumRequiredVersionToCurrentVersion"
120
+
Write-Warning"None of the following parameters were provided, so nothing will be changed: Version, BuildSystemsBuildId, IncrementProjectFilesRevision, UpdateMinimumRequiredVersionToCurrentVersion, InstallUrl and PublishUrl"
# If no ClickOnce deployment settings were found throw an error.
213
-
if ($clickOncePropertyGroups-eq$null-or$clickOncePropertyGroups.Count-eq0)
236
+
if ($null-eq$clickOncePropertyGroups-or$clickOncePropertyGroups.Count-eq0)
214
237
{
215
238
throw"'$ProjectFilePath' does not appear to have any ClickOnce deployment settings in it. You must publish the project at least once to create the ClickOnce deployment settings."
216
239
}
@@ -223,6 +246,24 @@ foreach ($clickOncePropertyGroup in $clickOncePropertyGroups)
223
246
$numberOfClickOncePropertyGroupsProcessed++
224
247
Write-Verbose"Processing ClickOnce property group $numberOfClickOncePropertyGroupsProcessed of $numberOfClickOncePropertyGroups in file '$ProjectFilePath'."
225
248
249
+
# If publish url is provided, update it
250
+
$publishUrl=$PublishUrl
251
+
if (![string]::IsNullOrEmpty($publishUrl))
252
+
{
253
+
Write-Verbose"Publish Url is '$publishUrl'"
254
+
Write-Output"Updating PublishUrl to be '$publishUrl'"
if ($output.Contains("Updating minimum required version to be '5.6.7.8'.")) { Write-Host"Passed" } else { throw"Test $testNumber failed. Output was '$output'." }
63
+
64
+
Write-Host ("{0}. Use major/minor of version number parameter and Build Id parameter...."-f++$testNumber)
0 commit comments