. . . .

My ClickOnce Deployment

posted 21 December 2006
ClickOnce, Microsofts new deployment mechanism, introduced in .Net framework 2.0 is just neat. Given a directive to make an application ClickOnce deployable I had to devise a way. Let me explain....

ClickOnce is primarily designed to have a development shop post their binaries to a web server and deployed to a clients box from that server. My charter was to make this application installable to a clients box, and hosted from that such that all clients would ping that box for installs and updates. This posed a problem due to the signing required for ClickOnce manifests and the application requiring configuration when it installed on that server computer.

My resolution was to have a standard MSI based installation which copied all of the required files for the application to the server machine, then using a bat file which called mage.exe generate and sign the manifests.

My bat file:

@echo off

if(%1) == "" goto error
if(%2) == "" goto error
if(%3) == "" goto error
if(%4) == "" goto error
if(%6) == "" goto error
if(%7) == "" goto error
if(%8) == "" goto error

echo ***Manifest Signing Application***

chdir %7
set var=%3
set var=%var:"=%

set product=%1
SET product=###%product%###
SET product=%product:"###=%
SET product=%product:###"=%
SET product=%product:###=%

set mfPath="%var%%product%.exe.manifest"
set appPath="%var%%product%.application"
set frmDir=%var:~0,-1%
if exist %mfPath% del /F %mfPath%
if exist %appPath% del /F %appPath%

mage.exe -New Application -ToFile %mfPath% -Name "%product%" -Version %2 -FromDirectory "%frmDir%"

cscript insert.vbs %mfPath% app.ico

if "%~5" == "" goto NoPassword

mage.exe -Sign %mfPath% -CertFile %4 -password %5
goto continue

mage.exe -Sign %mfPath% -CertFile %4


mage.exe -New Deployment -ToFile %appPath% -Name "%product%" -Version %2 -AppManifest %mfPath% -providerUrl %6 -Install true

set desc=""
cscript replace.vbs %appPath% " "

exit 1

Has this been problematic? Absolutely, mainly due to configuration of the app.config file after the app has been installed. This is more of an overlook as the System.Deployment along with the System.Configuration namespaces allow for modification of the app.config file during runtime.