开发者

Change the connection string in app.config with InstallShield 2011 setup

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 and InitialCatalog properties of the connection string. It looks like XML File Change only supports replacing of an entire element or attribute.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜