ClickOnce – Automatically update version

I often have to update Dynamics NAV ClickOnce applications and I got tired of updating the version in the two manifest files, that is why I updated my batch file to do it for me.

I keep my ClickOnce application files in c:\inetpub\wwwroot\xxx. When I need to make changes I edit or add files to that folder. When any change are made to the ClickOnce application files you need to update the manifest files using mage.exe. To do that I use this batch file (run as administrator)

SET /p VERSION=<c:\clickonce\NAV2016Demo.version.txt
SET /A VERSION=%VERSION%+1
>c:\clickonce\NAV2016Demo.version.txt ECHO %VERSION%
SET VERSION=9.0.0.%VERSION%
ECHO %VERSION%
CD C:\inetpub\wwwroot\ClickOnce\NAV2016demo\Deployment\ApplicationFiles
DEL /Q web.config
c:\clickonce\mage.exe -update Microsoft.Dynamics.Nav.Client.exe.manifest -FromDirectory . -version %VERSION%
CD C:\inetpub\wwwroot\ClickOnce\NAV2016demo\Deployment
c:\clickonce\mage.exe -update Microsoft.Dynamics.Nav.Client.application -appmanifest ApplicationFiles\Microsoft.Dynamics.Nav.Client.exe.manifest -appcodebase https://2016install01.domain.dk/NAV2016demo/Deployment/ApplicationFiles/Microsoft.Dynamics.Nav.Client.exe.manifest -version %VERSION% -minVersion %VERSION%
COPY c:\clickonce\web.config C:\inetpub\wwwroot\ClickOnce\NAV2016demo\Deployment\ApplicationFiles\
PAUSE

This will update the manifest files and increment the version and minimum required version by 1.

Please note that the current version is read from the file C:\ClickOnce\NAV2016Demo.version.txt file and not directly from the manifest files (too complicated for me ;-))

Also note that the version will be set to 9.0.0.x where x is the number that is incremented. You can of course modify this any way you like.