How to update WPF browser application manifest and xbap file with ‘mage.exe’
I created a WPF browser application MyApp then published it by ClickOnce in VS2008.
Published folder like this:
PublishedFolderMyApp.xbap
PublishedFoldersetup.exe
PublishedFolderApplication FilesMyApp_0_0_0_1 MyApp.xbap
PublishedFolderApplication FilesMyApp_0_0_0_1 MyApp.exe.manifest
PublishedFolderApplication FilesMyApp_0_0_0_1 MyApp.exe.deploy
PublishedFolderApplication FilesMyApp_0_0_0_1otherDependedLib.dll.deploy
…
Now, I usually need to modify app.config because I need modify DB connection string and services addresses etc. But after published to application server, I don’t want to republish the version with VS2008. So I find mage.exe tool.
I put mage.exe and MyApp.pfx in “PublishedFolder”
Then I do like so:
mage -Update "Application FilesMyApp_0_0_0_1 MyApp.exe.manifest"
mage -Sign "Application FilesMyApp_0_0_0_1 MyApp.exe.manifest" -CertFile MyApp.pfx -Password "test"
mage -Update MyApp.xbap -appm "Application FilesMyApp_0_0_0_1 MyApp.exe.manifest"
mage -Sign MyApp.xbap -CertFile MyApp.pfx -Password "test"
When I run update manifest command, I got "Error MSB3113: Could not find file "otherDependedLib.dll"... ".
My dependent dlls all added ".deploy" for client download.
But update success and I found hash value and sign name value had been changed in MyApp.exe.manifest and MyApp.xbap.
Then I browser the application in IE after cleaned buffer with “mage -cc”.
But I get next error:
ERROR SUMMARY
Below is a summary of the errors, details of these errors are listed later in the log.
* An exception occurred while downloading the manifest. Following failure messages were detected:
+ Downloading http://localhost/MyApp.exe.manifest did not succeed.
+ The remote server returned an error: (404) Not Found.
Maybe I did some wrong options in mage step, who can tell me the correct method. Thank you!
use a script to remove .deploy first then sign the add it back before signing the xbap
rename *.deploy *.
以上是一个老外在利用脚本发布XBAP中重签名的方法,结合红字部分可以解决问题,经过多方搜索和分析及试验,以下脚本可以完成自动发布并在线安装成功:
@echo 编译XBAP相关 @echo 清理APP缓存 "C:Program Files (x86)Microsoft SDKsWindowsv8.1AinNETFX 4.5.1 Toolsmage.exe" -cc @echo 编译XBAP项目 @cd AppBrowserOfHmi RMDIR /s /q "binDebug" %SystemRoot%Microsoft.NETFrameworkv4.0.30319MSBuild.exe BrowserOfHmi.csproj /target:publish /t:Build /property:Configuration=Debug /l:FileLogger,Microsoft.Build.Engine;logfile=BrowserOfHmi.log @echo Close notepad to continue... @if errorlevel 1 @notepad BrowserOfHmi.log cd.. cd.. @echo 清理旧发布文件 RMDIR /s /q "..BuildInstallPackagesBrowserXbapApplication FilesBrowserOfHmi_1_0_0_0" md "..BuildInstallPackagesBrowserXbapApplication FilesBrowserOfHmi_1_0_0_0" @echo 拷贝新发布文件 xcopy "AppBrowserOfHmiindebugapp.publish*.*" "..BuildInstallPackagesBrowserXbap" /s /h /y /d:1-1-1999 @echo 去掉.deploy rename "..BuildInstallPackagesBrowserXbapApplication FilesBrowserOfHmi_1_0_0_0*.deploy" "*." rename "..BuildInstallPackagesBrowserXbapApplication FilesBrowserOfHmi_1_0_0_0Icon*.deploy" "*." rename "..BuildInstallPackagesBrowserXbapApplication FilesBrowserOfHmi_1_0_0_0zh-Hans*.deploy" "*." @echo 重新签名 "C:Program Files (x86)Microsoft SDKsWindowsv8.1AinNETFX 4.5.1 Toolsmage.exe" -Update "..BuildInstallPackagesBrowserXbapApplication FilesBrowserOfHmi_1_0_0_0BrowserOfHmi.exe.manifest" "C:Program Files (x86)Microsoft SDKsWindowsv8.1AinNETFX 4.5.1 Toolsmage.exe" -Sign "..BuildInstallPackagesBrowserXbapApplication FilesBrowserOfHmi_1_0_0_0BrowserOfHmi.exe.manifest" -CertFile "AppBrowserOfHmiBrowserOfHmi.pfx" -Password "action98" "C:Program Files (x86)Microsoft SDKsWindowsv8.1AinNETFX 4.5.1 Toolsmage.exe" -Update "..BuildInstallPackagesBrowserXbapBrowserOfHmi.xbap" -appc "Application FilesBrowserOfHmi_1_0_0_0BrowserOfHmi.exe.manifest" -appm "..BuildInstallPackagesBrowserXbapApplication FilesBrowserOfHmi_1_0_0_0BrowserOfHmi.exe.manifest" "C:Program Files (x86)Microsoft SDKsWindowsv8.1AinNETFX 4.5.1 Toolsmage.exe" -Sign "..BuildInstallPackagesBrowserXbapBrowserOfHmi.xbap" -CertFile "AppBrowserOfHmiBrowserOfHmi.pfx" -Password "action98" @echo 增加.deploy ren "..BuildInstallPackagesBrowserXbapApplication FilesBrowserOfHmi_1_0_0_0*.dll" "*.dll.deploy" ren "..BuildInstallPackagesBrowserXbapApplication FilesBrowserOfHmi_1_0_0_0zh-Hans*.dll" "*.dll.deploy" ren "..BuildInstallPackagesBrowserXbapApplication FilesBrowserOfHmi_1_0_0_0*.exe" "*.exe.deploy" ren "..BuildInstallPackagesBrowserXbapApplication FilesBrowserOfHmi_1_0_0_0icon*.ico" "*.ico.deploy" pause