码迷,mamicode.com
首页 > 移动开发 > 详细

How to update WPF browser application manifest and xbap file with ‘mage.exe’

时间:2015-12-30 15:23:39      阅读:707      评论:0      收藏:0      [点我收藏+]

标签:

老外参考文章1

老外参考文章2

I created a WPF browser application MyApp then published it by ClickOnce in VS2008.

Published folder like this:

PublishedFolder\MyApp.xbap

PublishedFolder\setup.exe

PublishedFolder\Application Files\MyApp_0_0_0_1\ MyApp.xbap

PublishedFolder\Application Files\MyApp_0_0_0_1\ MyApp.exe.manifest

PublishedFolder\Application Files\MyApp_0_0_0_1\ MyApp.exe.deploy

PublishedFolder\Application Files\MyApp_0_0_0_1\otherDependedLib.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 Files\MyApp_0_0_0_1\ MyApp.exe.manifest"

mage -Sign    "Application Files\MyApp_0_0_0_1\ MyApp.exe.manifest" -CertFile MyApp.pfx -Password "test"

mage -Update MyApp.xbap -appm "Application Files\MyApp_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 SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\mage.exe" -cc 

@cd App\BrowserOfHmi
RMDIR /s /q "bin\Debug"
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\MSBuild.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 "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\"
md "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\"

@echo 拷贝发布文件
xcopy "App\BrowserOfHmi\bin\debug\*.dll" "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\" /s /h /y /d:1-1-1999
xcopy "App\BrowserOfHmi\bin\debug\*.exe" "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\" /s /h /y /d:1-1-1999
xcopy "App\BrowserOfHmi\bin\debug\*.manifest" "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\" /s /h /y /d:1-1-1999
xcopy "App\BrowserOfHmi\bin\debug\*.xbap" "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\" /s /h /y /d:1-1-1999
xcopy "App\BrowserOfHmi\icon\*.*" "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\icon\" /s /h /y /d:1-1-1999

RMDIR /s /q "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\app.publish\"
RMDIR /s /q "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\de\"
RMDIR /s /q "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\en\"
RMDIR /s /q "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\es\"
RMDIR /s /q "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\fr\"
RMDIR /s /q "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\it\"
RMDIR /s /q "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\ja\"
RMDIR /s /q "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\ko\"
RMDIR /s /q "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\zh-Hant\"

@echo 重新签名
"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\mage.exe" -Update "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\BrowserOfHmi.exe.manifest"

"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\mage.exe" -Sign    "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\BrowserOfHmi.exe.manifest" -CertFile "App\BrowserOfHmi\BrowserOfHmi.pfx" -Password "action98"

"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\mage.exe" -Update "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\BrowserOfHmi.xbap" -appc "Application Files\BrowserOfHmi_1_0_0_0\BrowserOfHmi.exe.manifest" -appm "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\BrowserOfHmi.exe.manifest"

"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\mage.exe" -Sign     "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\BrowserOfHmi.xbap" -CertFile "App\BrowserOfHmi\BrowserOfHmi.pfx" -Password "action98"

@echo 增加.deploy
ren "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\*.dll" "*.dll.deploy"
ren "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\zh-Hans\*.dll" "*.dll.deploy"
ren "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\*.exe" "*.exe.deploy"
ren "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\icon\*.ico" "*.ico.deploy"

@echo 拷贝xbap
copy "..\Build\Install\Packages\Browser\Xbap\Application Files\BrowserOfHmi_1_0_0_0\BrowserOfHmi.xbap" "..\Build\Install\Packages\Browser\Xbap\BrowserOfHmi.xbap"  /Y

pause

上面的去掉.deploy我暂时没用,如果用了可以节省一些代码,读者可以自己试验下。

How to update WPF browser application manifest and xbap file with ‘mage.exe’

标签:

原文地址:http://www.cnblogs.com/zjoch/p/5088912.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!