C# 如何移动 ClickOnce 部署包
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/174764/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to move a ClickOnce deployment package
提问by HAdes
I have a collection of ClickOnce packages in a publish folder on a network drive and need to move them all to another server (our DR machine).
我在网络驱动器上的发布文件夹中有一组 ClickOnce 包,需要将它们全部移动到另一台服务器(我们的 DR 机器)。
After copy/pasting the whole directory and running the setups on the new machine I get an error message stating that it cannot find the old path:
复制/粘贴整个目录并在新机器上运行设置后,我收到一条错误消息,指出它找不到旧路径:
Activation of ...MyClickOnceApp.application resulted in exception. Following failure messages were detected:
+ Downloading file://oldMachine/c$/MyClickOnceApp.application did not succeed.
+ Could not find a part of the path '\\oldMachine\c$\MyClickOnceApp.application'.
...MyClickOnceApp.application 的激活导致异常。检测到以下失败消息:
+ 下载 file://oldMachine/c$/MyClickOnceApp.application 没有成功。
+ 找不到路径“\\oldMachine\c$\MyClickOnceApp.application”的一部分。
Once I change the installation URLto point at my new machine, I get another error:
一旦我将安装URL更改为指向我的新机器,我就会收到另一个错误:
Manifest XML signature is not valid.
+ The digital signature of the object did not verify.
清单 XML 签名无效。
+ 对象的数字签名未验证。
I've tried using MageUI.exe, to modify the deployment URL, but it asks for a certificate, which I don't have.
我已经尝试使用MageUI.exe来修改部署 URL,但它要求提供我没有的证书。
What am I doing wrong and how do I successfully move published ClickOnce packages?
我做错了什么,如何成功移动已发布的 ClickOnce 包?
采纳答案by HAdes
I found a solution:
我找到了一个解决方案:
Firstly, using MageUI, I changed the "Start Location" under "Deployment Options". On saving, it prompted me to sign with a key, which I created there and then. I then ran the setup.exe
file, and it worked without fail.
首先,使用 MageUI,我更改了“部署选项”下的“开始位置”。保存时,它提示我使用我在那里创建的密钥进行签名。然后我运行了该setup.exe
文件,它没有失败。
After checking which files had changed, I realised it was only the one file: the application manifest file (myAppName.application
). The only things that changed in the file were the deployment providerand the signature(which is what I changed in MageUI).
在检查了哪些文件发生了更改后,我意识到只有一个文件:应用程序清单文件 ( myAppName.application
)。文件中唯一更改的是部署提供程序和签名(这是我在 MageUI 中更改的内容)。
Once I realised this was how to do it, I used the command line version of MageUI called Mage.exe
, which comes with the SDK.
一旦我意识到这是如何做到的,我Mage.exe
就使用了 SDK 附带的 MageUI 命令行版本。
Below is the batch file I created to do all of this on the command line:
下面是我创建的批处理文件,用于在命令行上执行所有这些操作:
REM Set the enviroment
call "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"REM Update the deployment provider URL
mage -Update %1.application -pu %2REM Sign the manifest with our key
mage -Sign %1.application -CertFile C:\AppKey.pfx -Password myPw
REM 设置环境
调用“C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat”REM 更新部署提供程序 URL
mage -Update %1.application -pu %2REM 使用我们的密钥
法师签署清单-Sign %1.application -CertFile C:\AppKey.pfx -Password myPw
I can now use this to run against all of my published applications in a quick and easy way. I hope this helps.
我现在可以使用它以快速简便的方式运行我发布的所有应用程序。我希望这有帮助。
回答by Darrel Miller
I believe that you do have a certificate. You need one to create a ClickOnce deployment. Visual Studio may have autocreated a self-signed one for you. I'm not too familiar with the process, hopefully someone with a more definitive answer will chip in. Also, have you tried the MageUI tool, maybe it will be more obvious what you need to do using a GUI.
我相信你确实有证书。您需要一个来创建 ClickOnce 部署。Visual Studio 可能已经为您自动创建了一个自签名的。我对这个过程不太熟悉,希望有更明确答案的人会参与进来。此外,您是否尝试过 MageUI 工具,也许使用 GUI 需要做的事情会更明显。
回答by Carl
I would expect to have to do the following:
我希望必须执行以下操作:
- Copy current folder contents to new location
- For each app:-
- Change 'Installation folder' to the new location
- Publish as a new version
- Change 'Publishing folder' to the new location
- Publish as a new version
- 将当前文件夹内容复制到新位置
- 对于每个应用程序:-
- 将“安装文件夹”更改为新位置
- 作为新版本发布
- 将“发布文件夹”更改为新位置
- 作为新版本发布
New setups run from the new folder should work and existing ones should update to look in the correct place.
从新文件夹运行的新设置应该可以工作,现有的应该更新以查找正确的位置。
All this is untested, but I'm pretty sure that's what I did previously...
所有这些都未经测试,但我很确定这就是我以前所做的......
Edit:
编辑:
Obviously, you'll have to run these in parallel for a certain amount of time, but as it's an internal app the worst that will happen when you finally switch over to the new location is that you'll have to inform the user of the new location to obtain a 'fixed' app
显然,您必须在一定时间内并行运行这些程序,但由于它是一个内部应用程序,当您最终切换到新位置时,最糟糕的情况是您必须通知用户获取“固定”应用程序的新位置
回答by codeConcussion
Without getting into too much detail, this should get you going.
无需涉及太多细节,这应该可以帮助您前进。
ClickOnce manifests must be signed with a certificate for security reasons. You can purchase a code signing certificate or generate a test one. The main drawback of a test certificate is that your application publisher will appear as "Unknown" rather than your company's name.
出于安全原因,必须使用证书对 ClickOnce 清单进行签名。您可以购买代码签名证书或生成测试证书。测试证书的主要缺点是您的应用程序发布者将显示为“未知”而不是您公司的名称。
In Visual Studio, open your project's properties and go to the "Signing" tab, select "Sign the ClickOnce manifests", and "Create Test Certificate". Next, click "More Details" to bring up a dialog and click "Install Certificate". This will run you through a wizard to get your test cert in your store. Make sure you put it in the "Personal" store.
在 Visual Studio 中,打开项目的属性并转到“签名”选项卡,选择“签署 ClickOnce 清单”和“创建测试证书”。接下来,单击“更多详细信息”以打开一个对话框,然后单击“安装证书”。这将引导您完成一个向导,以在您的商店中获取您的测试证书。确保将其放在“个人”商店中。
Now you can use MageUI to edit your manifests. Any time you save it will prompt you to sign the manifests but you should now be able to select the test cert you just stored. Always edit/sign the application manifest before editing/signing the deployment manifest. This is confusing because the application manifest isn'tthe file with the .applicationextension.
现在您可以使用 MageUI 来编辑您的清单。任何时候保存它都会提示您签署清单,但您现在应该能够选择刚刚存储的测试证书。在编辑/签署部署清单之前,始终编辑/签署应用程序清单。这令人困惑,因为应用程序清单不是带有.application扩展名的文件。
Good luck!
祝你好运!