如何在安装过程中修改.NET配置文件? [英] How to modify .NET config files during installation?

查看:247
本文介绍了如何在安装过程中修改.NET配置文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的是app.config文件来存储一些值(路径映射数据库,数据连接选择)。这些设置不同,在用户的机器,我想安装程序来设置他们的权利。是否有可以使用.NET配置文件在安装过程中的工作,让我创造一些对话,这将有助于我填写这些值的安装程序?

I use the app.config file to store some values (path to a mapping database, data connection selections). These settings differ on the user machines and I would like the installer to set them right. Is there an installer that can work with .NET config files during setup and allow me to create some dialogs that would help me fill in these values ?

我知道这个问题可能类似于:<一href="http://stackoverflow.com/questions/75546/initializing-userconfig-or-appexeconfig-during-install">Initializing user.config或app.exe.config在安装过程中,但我不局限于VS 2008的安装项目,我想更改配置文件中的设置。

I know this question may be similar to : Initializing user.config or app.exe.config during install, but I am not limited to VS 2008 setup project and I want to change the settings in the config files.

编辑:我看到使用维克斯是一种选择,但我觉得像开裂核桃用大锤。这可能是唯一的解决办法,但我还是希望简单的东西。

I see that using WIX is one option, but I feel like cracking a walnut with a sledgehammer. It may be the only solution, but I still hope for something simple.

推荐答案

我们使用WIX改变应用程序的配置文件。它的作品真的很好,你需要添加wixUtilExtension.dll的参考。

We use WIX to change the application's configuration file. It works really well, you'll need to add wixUtilExtension.dll in the reference.

维克斯示例:

<Component Id="ChangeConfig" Guid="[YOUR_GUID_HERE]">
   <File Id="App.config" Name="MyApplication.exe.config" Vital="yes" KeyPath="yes" Source="[Path to project dir]\app.config" />
   <util:XmlFile Id="AppConfigSetConnStr" Action="setValue" Permanent="yes" File="[#App.config]"        	
        ElementPath="/configuration/connectionStrings/add[\[]@name='MyDatabaseName'[\]]" Name="connectionString" 
        Value="Your Connection string values here" />

</Component>

这实际上取决于你正在使用的是什么创造了安装程序,你在使用?
有alook在 WIX教程

It actually depends on what you are using to create the installer, What are you using ?
Have alook at the WIX Tutorial.

这篇关于如何在安装过程中修改.NET配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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