Visual Studio 部署项目:允许用户在运行时选择配置文件

发布于 2024-10-07 18:13:15 字数 300 浏览 0 评论 0原文

我有一个用 VS2008 构建的 Windows 服务。该服务通过 MSI 安装在目标计算机上,我使用 Visual Studio 中的安装和部署项目构建了该服务。当 MSI 运行时,它将所需的二进制文件复制到目标目录,并在服务控制管理器中安装服务。

我设置了项目,以便它们在目标目录中创建一个“Configs”目录。每种类型的环境(Dev、QA、Prod)都有一个配置文件。

按照目前的情况,安装完成后,用户必须转到 Configs 目录并将所需的配置复制到基本目标目录。这是造成混乱和一些错误的根源。

我希望 MSI 文件提示用户输入

I have a Windows service I built with VS2008. The service is installed on the target machine via and MSI, which I built using a Setup and Deployment project in Visual Studio. When the MSI is run, it copies the binaries needed to the target directory and installs the service in the service control manager.

I have the projects set up so that they create a "Configs" directory in the target directory. There is one configuration file for each type of environment (Dev, QA, Prod).

As it currently stands, when the installation is complete, the user must go to the Configs directory and copy the desired configuration to the base target directory. This is a source of confusion and a few errors.

I would like the MSI file to prompt the user for the

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜宝宝 2024-10-14 18:13:15

我已经在设置项目中成功完成了相同的服务部署所需功能。

首先,您需要在安装项目的“文件系统”中的应用程序文件夹下添加“Configs”目录。

其次,查看“用户界面”设计器。在这里您需要添加一个新对话框。我所做的是添加一个带有两个单选按钮的对话框(选择开发或生产)。我将其放置在设置菜单序列中的“欢迎”对话框之后。

选择新对话框并在“属性”窗口中添加所需内容。在我的正文中,我告诉用户“选择部署选项”。从那里您可以为每个选择设置值。我的 Button1Label 属性读取为“开发”,Button1Value 为 1。按钮 2 为“生产”,值为 2。我将其命名为 ButtonProperty “部署”。

最后,将每个配置文件添加到“应用程序文件夹”下的文件系统 -> “配置”。
这里的关键操作是将每个配置文件与部署选项联系起来。对于开发配置文件,它的 Condition 属性将是:

DEPLOY=1

类似地,生产配置 Condition 属性将是:

DEPLOY=2

它很简单,但它完全符合您需要的功能。这对于安装项目来说很难做到。它们缺乏很多功能。

I've accomplished the same need functionality in setup projects for my service deployments successfully.

First, you'll need add your "Configs" directory under the Application Folder in "File System" of your setup project.

Second, view the "User Interface" designer. Here you will need to add a new dialog. What I did was add a dialog with two radio buttons (choices being development or production). I placed mine after the "Welcome" dialog in the setup menu sequence.

Select your new dialog and add what you need in the Properties window. In my body text, I tell the user to "Select a deployment option". From there you set values for each choice. My Button1Label property reads as "Development" with a Button1Value of 1. Button 2 is "Production" with a value of 2. I named the ButtonProperty "DEPLOY".

Finally, add each config file to the File System under "Application Folder" -> "Configs".
The key action here is tying each config file to a deployment option. For a development config file it's Condition property would be:

DEPLOY=1

Similarily the production config Condition property would be:

DEPLOY=2

It's simple but it does exactly what you need it to do. Which is hard to do with setup projects. They lack a whole lot of functionality.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文