开发者

How can you merge config files in a visual studio setup project?

开发者 https://www.devze.com 2023-04-06 08:11 出处:网络
I created a visual studio 开发者_C百科setup project. I want this project to install the output from another project into the path given by the user in the installation folder component. That is alread

I created a visual studio 开发者_C百科setup project. I want this project to install the output from another project into the path given by the user in the installation folder component. That is already working.

Now I want the installer to check if the output is already installed (perhaps that is going to work with the registry?). If it is already installed, some data from the old app.config should be merged into the new app.config (like connection data entries).

Is there a way to do this?

I found custom actions, but the code from my project does not seem to run:

http://msdn.microsoft.com/de-de/library/d9k65z2d.aspx

I simply try to write into the config file:

string path2Conf = "C:\\Program Files\\Proj\\app.conf";
StreamWriter sw = new StreamWriter(path2Conf);
sw.WriteLine("Hallo1298347645");

But after the installation there is not such a string in the config.

Edit: I added the custom action to install.


This is not supported by Visual Studio. Also, you can't do it through custom actions because a Visual Studio setup project doesn't support running actions before the upgrade starts. You would need to backup the original information before installing your new XML.

If this issue is a show stopper, a solution is to use another setup authoring tool which supports XML updates or at least offers more control over custom actions.

If you want a free tool I recommend WiX. It has a steep learning curve but it gets the job done.

0

精彩评论

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

关注公众号