Mage.exe: Updating the Manifest File for ClickOnce Deployment

While working on ClickOnce Deployment, i was intended to update the Manifest and application[vsto] files for updating the file references and Paths.

Manifest file holds the files references and Path for the resources it tries to pick during running the ClickOnce application. So during deployment they need to changed. We cannot change directly because, manifest and application files internally recongnizes whether file got changed some other authority and if it finds any change it gets corrupted.

For better perfomring the acts, we use Mage tool to update the Manifest and application files for clickonce
Following are the properties used in the code samples
SET LOGFILENAME=GenerateManifest.log

SET APPDISPLAYNAME=%1
SET PROURL=%2
SET CERTFILE=%3
SET TARGETVDIR=%4
SET APPVERSION=%5
SET VERSION=%6

echo Script For Auto Manifest Generation >> %LOGFILENAME%

REM SET TARGETVDIR=%TARGETVDIR:~1,-1%
cd “%TARGETVDIR%”
ECHO.

ECHO To Load the default properties
rem call “%programfiles%Microsoft Visual Studio 8VCvcvarsall.bat” x86

sometimes happens that after you publish, the files are created with .deploy extension. we need to change them

ECHO Generating Application Manifest
ECHO Updating the Deploy file >> %LOGFILENAME%
REN “%TARGETVDIR%ApplicationFiles%APPDISPLAYNAME%_%APPVERSION%My.Test.dll.deploy” My.Test.dll

Change the all files extension that manifest is looking at
REN “%TARGETVDIR%ApplicationFiles%APPDISPLAYNAME%_%APPVERSION%ResourcesBooting.gif.deploy” Booting.gif

ECHO Updating the manifest
mage -Update “%TARGETVDIR%ApplicationFiles%APPDISPLAYNAME%_%APPVERSION%%APPDISPLAYNAME%.dll.manifest” -fd “%TARGETVDIR%ApplicationFiles%APPDISPLAYNAME%_%APPVERSION%” -CertFile %CERTFILE% >> %LOGFILENAME%

%CERTFILE% – is the Certificate [pfx] for signing the file to be encrypted.

Later updating the files for deploy
REN “%TARGETVDIR%ApplicationFiles%APPDISPLAYNAME%_%APPVERSION%My.Test.dll” My.Test.dll.deploy

REN “%TARGETVDIR%ApplicationFiles%APPDISPLAYNAME%_%APPVERSION%ResourcesBooting.gif” Booting.gif.deploy

This complets the updating the Manifest

For creation of application or vsto perform the similar steps
mage -Update “%TARGETVDIR%%APPDISPLAYNAME%.vsto” -CertFile %CERTFILE% -AppManifest “ApplicationFiles%APPDISPLAYNAME%_%APPVERSION%%APPDISPLAYNAME%.dll.manifest” -AppCodebase “ApplicationFiles%APPDISPLAYNAME%_%APPVERSION%%APPDISPLAYNAME%.dll.manifest”>> %LOGFILENAME%

I can call this from the command prompt by placing the above code in the GenerateManifest.cmd

GenerateManifest.cmd [APPNAME] [PROURL] [CERTFILE] [TARGETVDIR] [APPVERSION] [VERSION]>> %LOGFILENAME%

Other Way to get the application
mage -Update %TARGETVDIR%%APPDISPLAYNAME%.application -pub MyCompany -providerUrl %PROURL% -AppCodeBase “Application Files%APPDISPLAYNAME%.exe.manifest” -AppManifest “Application Files%APPDISPLAYNAME%.exe.manifest” >> %LOGFILENAME%

Leave a Reply