ClickOnce Deployment and MAGE

Today, I solved a problem that I’ve been annoyed with for a while.
In fairness, I haven’t been fighting it that hard, but I had to find a solution today, and as they say, need is the mother of invention…
So, here’s the scenario…
We have developed an application that is deployed via ClickOnce publishing. This application talks to a Web Service which handles all the database interaction.
Fine, it works on my machine.
When deploying to a different server, clearly the link to the WebService can’t use localhost or gavinr-pc1; so as a good developer, I stored the link to the Web Service in the config file. However… when updating this config file by hand on the server, the application fails to start on a client machine claiming (quite correctly) that…
File, XXX.exe.config, has a different computed hash than specified in manifest.
So, my workaround to date has involved rebuilding the app on the target server. Not ideal.
The issue here is that the ClickOnce deployment manifest is basically an XML file which lists all files involved in the application. Besides the file name, it also stores a computed hash value which is generated at Publish time in Visual Studio. (This is to ensure that the correct files are downloaded when the client requests the app.)
So, any change to application files in the app post Publish will cause this issue.
The fix is to manually update the ClickOnce deployment manifest file, and then reassociate the deployment manifest with the application manifest.
Quite a mouthful.
It involves using a tool called mage.exe, which is a stand-alone command line tool available in the Visual Studio SDK.
I’ve included the commands in the batch file that need to be run once the config file has been updated…
REM Set the working directory
cd C:XXXAPP_1_3_1_4
REM Create a new Application Manifest (I did try using the -u switch to update the existing one, didn’t work. Found creating a new one more reliable.)
c:mage.exe -New Application -ToFile XXX.exe.manifest -Name XXX -Version -FromDirectory C:XXXAPP_1_3_1_4
REM Sign this new Application Manifest
c:mage.exe -s XXX.exe.manifest -cf C:XXXAPPKey.pfx -pwd YYYY
REM Update the Base Deployment Manifest with the new Application Manifest and Sign Again
c:mage.exe -u c:XXXAPP.application -appm XXX.exe.manifest -appc APP_1_3_1_4XXX.exe.manifest
c:mage.exe -s c:XXXAPP.application -cf c:XXXAPPKey.pfx -pwd YYYY
  1. #1 by Unknown on October 15, 2008 - 9:03 pm

    Hi,Do you need advertising displays, screen advertisings, digital sign, digital signages and LCDs? Please go have explored and developed the international market with professionalism. We have built a widespread marketing network, and set up a capable management team dedicated to provide beyond-expectation services to our customers.
    amberdigital Contact Us[icchbidbaihceb]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: