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
Copy file name to clipboardExpand all lines: ReadMe.md
+14-4Lines changed: 14 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,15 +8,18 @@ Setting the MinimumRequiredVersion property forces the ClickOnce application to
8
8
9
9
# Script Parameters
10
10
***ProjectFilePath** (required) - Path of the .csproj and .vbproj file to process.
11
-
11
+
12
12
***Version** - The Version to update the ClickOnce version number to. This version must be of the format Major.Minor.Build or Major.Minor.Build.Revision. The Build and Revision parts will be overridden by the BuildSystemsBuildId parameter, if it is provided. The Revision parts will be overriden by the IncrementProjectFilesRevision parameter, if it is provided.
13
13
14
14
***BuildSystemsBuildId** - The build system's unique and auto-incrementing Build ID. This will be used to generate the Build and Revision parts of the new Version number. This will override the Build and Revision specified in the Version parameter, if it was provided. This parameter cannot be used with the IncrementProjectFilesRevision parameter.
15
-
15
+
16
16
***IncrementProjectFilesRevision** - If this switch is provided, the Revision from the project file will be incremented and used in the new ClickOnce Version. This will override the Revision specified in the Version parameter, if it was provided. This parameter cannot be used with the BuildSystemsBuildId parameter.
17
-
17
+
18
18
***UpdateMinimumRequiredVersionToCurrentVersion** - If this switch is provided, the ClickOnce MinimumRequiredVersion will be updated to match the new Version. Setting the MinimumRequiredVersion property forces the ClickOnce application to update automatically without prompting the user.
19
19
20
+
***PublishUrl** - If this switch is provided, the ClickOnce PublishUrl will be updated. The publish url format is \\fileshare\foldername
21
+
22
+
***InstallUrl** - If this switch is provided, the ClickOnce InstallUrl will be updated. The install url format is http://fileshare/foldername
20
23
21
24
# Examples
22
25
Update a project file's ClickOnce version to the specified version.
@@ -52,4 +55,11 @@ Update a project file's ClickOnce version, ignoring the Revision part and increm
Copy file name to clipboardExpand all lines: Set-ProjectFilesClickOnceVersion.ps1
+84-43Lines changed: 84 additions & 43 deletions
Original file line number
Diff line number
Diff line change
@@ -2,14 +2,14 @@
2
2
<#
3
3
.SYNOPSIS
4
4
This script updates the ClickOnce version in a project file (.csproj or .vbproj), and may update the MinimumRequiredVersion to be this same version.
5
-
5
+
6
6
.DESCRIPTION
7
7
This script updates the current ClickOnce version in a project file (.csproj or .vbproj), and may update the MinimumRequiredVersion to be this same version.
8
8
Setting the MinimumRequiredVersion property forces the ClickOnce application to update automatically without prompting the user.
9
-
9
+
10
10
.PARAMETERProjectFilePath
11
11
(required) Path of the .csproj and .vbproj file to process.
12
-
12
+
13
13
.PARAMETERVersion
14
14
The Version to update the ClickOnce version number to. This version must be of the format Major.Minor.Build or Major.Minor.Build.Revision.
15
15
The Build and Revision parts will be overridden by the BuildSystemsBuildId parameter, if it is provided.
@@ -19,44 +19,61 @@
19
19
The build system's unique and auto-incrementing Build ID. This will be used to generate the Build and Revision parts of the new Version number.
20
20
This will override the Build and Revision specified in the Version parameter, if it was provided.
21
21
This parameter cannot be used with the IncrementProjectFilesRevision parameter.
22
-
22
+
23
23
.PARAMETERIncrementProjectFilesRevision
24
24
If this switch is provided, the Revision from the project file will be incremented and used in the new ClickOnce Version.
25
25
This will override the Revision specified in the Version parameter, if it was provided.
26
26
This parameter cannot be used with the BuildSystemsBuildId parameter.
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 the Build and Revision parts of a project file's ClickOnce version, based on a unique, auto-incrementing integer, such as a build system's Build ID.
Update a project file's ClickOnce version, ignoring the Revision part and incrementing the Revision stored in the file, and update the Minimum Required Version to be this new 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,17 +115,17 @@ 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,13 +246,31 @@ 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 we should be using the BuildSystemsBuildId for the Build and Revision.
250
291
if ($BuildSystemsBuildId-gt-1)
251
292
{
252
293
# Use a calculation for the Build and Revision to prevent the Revision value from being too large, and to increment the Build value as the BuildSystemsBuildId continues to grow larger.
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