开发者

Avoid existing files being overwritten when newer version is installed

I have a VS2008 windows application project (WinProject) which is deployed by the installation project (InstallationProject) which inturn has the property RemovePreviousVersions set to True.

In my app for each configuration made开发者_运维技巧 by an user, the winapp writes the configurations into an xml file (stored in C:\Application Name\Files\ folder) which also includes the path where the config was saved.

Now when I build new versions of the installer,This folder and the files are overwritten since i the flag AlwaysCreate is set to True.

My question is how can i avoid these older files from being overwritten and at the same time shall get the updated file from the installer.

Ex: Contents of the file

  <PriceFiles>
    <Name>arr</Name>
    <Path>C:\NewTool\arr.xml</Path>
    <UserDefined>true</UserDefined>
  </PriceFiles>
  <ReferenceProjects>
    <Name>studio</Name>
    <Path>C:\NewTool\ReferenceProjects\6cd3a9e9-ad65-475e-953b-128915a496cd.xml</Path>
    <UserDefined>true</UserDefined>
    <CreatedBy>Admin</CreatedBy>
  </ReferenceProjects>

Thanks in advance


Probably you should write your config files to ApplicationData folder. You can get the path to it:

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)


Is there a reason not to use the built in user configuration settings?

In terms of stopping these files from being overwritten, I don't think there is a way to do it with a default MSI setting.

Do you want to do a merge between the configuration settings already on the machine and the ones being installed and update the config file with any settings that don't exist on the machine? or do you just want to avoid these files being overwritten and have the other parts of the app installed?

The easiest option I can think of would be to not have the config files in the installer at all, and have the application handle that case and create them if it can't find them.

Otherwise you would probably need to do some sort of post-install script that modifies or installs the config files if they don't exist.

One note to make is that my knowledge of MSIs is far from exhaustive, so there could be a way to not overwrite particular files.


Yes there is a reason behind for not using the built in Configuration Settings for config my application before installation.

Actually the job i need to perform is both of what you had guessed ... i.e "create the config file with default content if the file don't exist on the machine" "merge the configuration settings if the file is already on the machine "

Should i be using the Custom Installer for this validation ??

Regards Vatsa


Avoid existing files being overwritten when newer version is installed

Usually whenever we add an external files to Application folder in Setup and Deployment, click on their properites and select the option called Permanent: True and Exclude: False. This will not overwrite the existing files(in installation path).

Also, if you want to make the Myproduct.exe.config permanent then you can add this file to the Application folder in Setup and Deployment and tune their properties as I said before. This prevent the overwriting of the Myproduct.exe.config. I tried this, worked for me. But when I build my project, I used to get the warning as Two or more objects have the same target location ('[targetdir]\Myproduct.exe.config').

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜