Skip to content

Commit cd77829

Browse files
committed
Updated script to display a warning message when taking the modulus of the Revision.
1 parent e19f9bd commit cd77829

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

ReadMe.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,35 @@ Setting the MinimumRequiredVersion property forces the ClickOnce application to
1717

1818
# Examples
1919

20-
1. Update a project file's ClickOnce version.
20+
Update a project file's ClickOnce version.
2121
```
2222
& .\Set-ProjectFilesClickOnceVersion.ps1 -ProjectFilePath "C:\SomeProject.csproj" -Version '1.2.3.4'
2323
```
2424

2525
---
2626

27-
2. Update just the Revision part of a project file's ClickOnce version.
27+
Update just the Revision part of a project file's ClickOnce version.
2828
```
2929
& .\Set-ProjectFilesClickOnceVersion.ps1 -ProjectFilePath "C:\SomeProject.csproj" -Revision 12345
3030
```
3131

3232
---
3333

34-
3. Increment the Revision of a project file's ClickOnce version.
34+
Increment the Revision of a project file's ClickOnce version.
3535
```
3636
& .\Set-ProjectFilesClickOnceVersion.ps1 -ProjectFilePath "C:\SomeProject.csproj" -IncrementProjectFilesRevision
3737
```
3838

3939
---
4040

41-
4. Update a project file's ClickOnce Minimum Required Version to match its current version.
41+
Update a project file's ClickOnce Minimum Required Version to match its current version.
4242
```
4343
& .\Set-ProjectFilesClickOnceVersion.ps1 -ProjectFilePath "C:\SomeProject.csproj" -UpdateMinimumRequiredVersionToCurrentVersion
4444
```
4545

4646
---
4747

48-
5. 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.
48+
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.
4949
```
5050
& .\Set-ProjectFilesClickOnceVersion.ps1 -ProjectFilePath "C:\SomeProject.csproj" -Version '1.2.3' -IncrementProjectFilesRevision -UpdateMinimumRequiredVersionToCurrentVersion
5151
```

Set-ProjectFilesClickOnceVersion.ps1

+10-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
5757
.NOTES
5858
Author: Daniel Schroeder
59-
Version: 1.0.0
59+
Version: 1.0.1
6060
#>
6161

6262
Param
@@ -240,7 +240,15 @@ foreach ($propertyGroup in $clickOncePropertyGroups)
240240
}
241241
}
242242

243-
$Revision %= 65535 # Make sure the revision version part is not greater than the allowed value (16-bit int).
243+
# Make sure the revision version part is not greater than the allowed value (16-bit int).
244+
[int]$maxVersionPartValueAllowed = 65535
245+
if ($Revision -gt $maxVersionPartValueAllowed)
246+
{
247+
Write-Warning "The Revision value '$Revision' to use for the last part of the version number is greater than the max allowed value of '$maxVersionPartValueAllowed'. The modulus will be used for the revision instead. If this results in your ClickOnce deployment not downloading the latest update and giving an error message like 'Cannot activate a deployment with earlier version than the current minimum required version of the application.' then you will need to increment the Build part of the ClickOnce <ApplicationVersion> value stored in the project file."
248+
$Revision %= $maxVersionPartValueAllowed
249+
}
250+
251+
# Create the version number to use for the ClickOnce version.
244252
$newVersionNumber = "$majorMinorBuild.$Revision"
245253
Write-Output "Updating version number to be '$newVersionNumber'."
246254

0 commit comments

Comments
 (0)