ClickOnce:如何通过安装程序*向我的应用程序传递查询字符串值? [英] ClickOnce: How do I pass a querystring value to my app *through the installer*?

查看:76
本文介绍了ClickOnce:如何通过安装程序*向我的应用程序传递查询字符串值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的公司目前为所有客户构建单独的MSI,即使该应用程序在各个方面都是100%相同的(唯一的例外是app.config中的ID).

My company currently builds separate MSI's for all of our clients, even though the app is 100% the same across the board (with a single exception, an ID in the app.config).

我想向他们展示我们可以使用ClickOnce一次发布,只需为每个客户端的安装程序添加查询字符串参数即可.

I would like to show them that we can publish in once place with ClickOnce, and simply add a query string parameter for each client's installer.

示例: http://mysite.com/setup. exe?ID = 1234-56-7890

Example: http://mysite.com/setup.exe?ID=1234-56-7890

我遇到的问题是上述内容("ID = 1234 ...")没有传递给"myapplication.application".相反,发生的事情是,该应用程序已成功安装,并且在具有激活上下文的情况下首次运行,但是"ActivationUri"不包含任何查询字符串值.

The issue that I'm having is that the above ("ID=1234...") is not being passed along to the "myapplication.application". What is happening instead is, the app is being installed successfully, and it is running the first time with an activation context, but the "ActivationUri" does not contain any query string values.

是否可以将查询字符串值从安装程序URL 传递到应用程序的启动URL?如果可以,怎么办?

Is there a way to pass query string values FROM THE INSTALLER URL to the application's launch URL? If so, how?

推荐答案

经过大量搜索(并讨论)后,答案很简单,即当前版本的ClickOnce不能那样工作.安装程序不会在首次运行时将该URL传递给应用程序.

After much searching (and discussing), the answer is simply that the current version of ClickOnce doesn't work that way. The installer does not pass the URL onto the application up it's first run.

以下是我为解决此问题所做的事情(效果很好).

  • 更改我的安装程序包,以使所有必需的文件都解压缩并松散(如使用CAB文件或将其嵌入安装程序中一样).

  • Change my setup package to have all of the required files uncompressed and loose (as apposed to using a CAB file, or embedding them in the installer).

制作一个ASP.NET应用程序(使用路由进行URL处理),该应用程序侦听对"mysite.com/Installer/00123/Setup.exe"的请求

Make an ASP.NET application (using Routing for URL handling) that listens for a request to "mysite.com/Installer/00123/Setup.exe"

  • 注意:路由应侦听"/Installer/{ID}/*",其中{ID}是5位数字.
  • 实际上没有名为"00123"的目录,而是使用ASP.NET路由来提取这些请求,然后将其映射到包含安装程序文件的实际目录中.

然后我劫持了该请求(解析setup.exe以找到告诉安装程序在哪里可以找到其余文件的嵌入式URL ...然后,我用请求URL替换"/00000/"用户转到的位置-在这种情况下为"00123".

I then hijack the request (parse the setup.exe to find the embedded URL that tells the installer program where to find the rest of the files... I then replace "/00000/" with the request URL that the user went to - in this case "00123".

  • 在请求每个文件时,我知道要发送文件的哪个版本",因为ClickOnce安装程序将在搜索"mysite.com/Installer/00123/SomeFile.dll"(或其他内容).
  • li>

您可以使用GUID而不是使用5位数的ID,具体取决于您.

Instead of using a 5-digit ID, you could use a GUID... it's up to you.

此解决方案非常适合我们的组织...我们目前有37个客户,需要对其安装程序包进行独特的自定义,但是我们只需要实际构建和发布 ONE 安装程序包,只需使用上面的劫持方法.

This solution works great for our organization... we currently have 37 clients who require unique customizations to their installer package, but we only have to actually build and publish ONE installer package and simply use the hijack method above.

这时,我们有一些占位符可以互换,这样就可以轻松地为所需数量的客户端自定义安装程序.

At this point we have placeholders that we swap out so that it's easy to customize installers for as many clients as we want.

示例:在app.config文件中,我们具有displayName ="{OrgName}",该名称将自动替换为数据库中的值之一.

Example: in the app.config file we have displayName="{OrgName}" which is automatically replaced by one of the values in the database.

这篇关于ClickOnce:如何通过安装程序*向我的应用程序传递查询字符串值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆