使用 InstallShield 2011 设置更改 app.config 中的连接字符串
我正在创建一个 InstallShield 2011 基本 MSI 安装程序项目。
我正在尝试根据设置中数据库登录对话框中的用户选择来更改 app.config 中的连接字符串。如何将这些连接字符串设置应用到我尝试安装的 Windows 应用程序的 app.config 中的连接字符串条目?
XML 文件更改是正确的起点。由于更改连接字符串是一项常见任务,我希望有一个最佳实践来完成此任务。
-- 编辑 --
有两个主要困难:
如何引用 InstallShield 中将在构建时创建的文件? App.config 被复制到 MyAppName.config。我不想再次将应用程序名称硬连接到此位置的设置中。
配置文件中的连接字符串由实体框架使用,因此包含比 InstallShield 数据库选择给出的更多信息。如果我只想更改连接字符串的
Server
和InitialCatalog
属性,我必须修补配置文件元素中的属性。看起来 XML 文件更改仅支持替换整个元素或属性。
I'm creating an InstallShield 2011 basic MSI installer project.
I'm trying to change the connection string in my app.config according to the user selections from the database login dialog made in the setup. How can I apply these connection string settings to the connection string entry in the app.config of my windows application I'm trying to install?
XML File Change is the right place to start from. Since changing the connection string is a common task my hope was that there is a best practice to do exactly this task.
-- edit --
There are two main difficulties:
How do I reference a file in InstallShield which will be created on build? The App.config gets copied to MyAppName.config. I don't want to hardwire the application name into the setup at this place again.
The connection string in the config file is used by Entity framework, thus contains more information than given by the database selection from InstallShield. I have to patch an attribute within an element of the config file, if I just want to change the
Server
andInitialCatalog
properties of the connection string. It looks like XML File Change only supports replacing of an entire element or attribute.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,XML 文件更改就是为此目的而设计的。在定义 XPath 和元素/属性值时,您可以将用户的选择作为属性值。对我来说,这是 InstallShield 工作得很好并且如描述的那样的领域之一。
As far as I remember, the XML File Changes is designed for this purpose. You can place the user's choice as a property value when defining your XPath and element/attribute values. For me, it was one of the areas of InstallShield which worked quite good and as described.