Protect files from wyupdate deletion

I would like to know how can I protect new files (included on a previous update) from deletion when my application is updating to a new version.

Example: I included a new configuration file for my application on a previous update. I want to release a new update for that application but I want the existing users to preserve the settings they have wrote onto this configuration file.

If I add the configuration file again, wyupdate will replace the original (user-modified) configuration file with the default configuration included in it.

If I remove the configuration file from the update, wyupdate will delete this configuration file.

If you want to exclude the file from updates, then remove it from the current version and the old versions. This way when wyUpdate updates your app it will just ignore the config file.

If you just remove it from the current version but leave it in the older version, then when wyBuild builds the updates it will read this as "there used to be a file, now there's not. wyUpdate should delete this file on update".

How do you deliver new config files?

Let's say your config file is named "YouApp.config" and it may or not may exist on your users' machines (depending on what version they're upgrading from). This means you want to distribute this file and use it as the default config for a user, but you don't want to overwrite the file if it already exists.

There are a few ways to do this. By far the easiest is to add the file as "YourApp-sample.config". Then, either on the first run of your app or as part of your update, copy the "-sample" file to "YourApp.config" if that file doesn't already exist.

Does this make sense?

Thank you for the quick reply Sam.

The "-sample" config file solution work greats for a single or small number of configuration files within the application, but it's a no go option for us since we're talking about a considerable amount of files, shared among multiples assemblies. Plus these files were deployed a couple months ago.

Because the number of configuration files are quite considerable, the update method should simply check if a particular file does exists already and either always overwrite it, or create it if it does not exists or skip the file if it does exists.

Right now we're facing this problem with configuration files but we're trying to implement a solution that will work in any situation, any file type we want to add later into the application but do not want the updater to overwrite it after it has been placed, without having to implement a custom post-update routine each time it is needed.

A simple "do not overwrite if file already exists" option would be the best way considering the scenario we're currently facing.

Let me know if this can be done within wybuild.

Plus these files were deployed a couple months ago.

You can still apply this concept to your new version. Simply remove the config files from previous versions in wyBuild so the config files aren't deleted on update. Then add the *-sample.config files to the new version. Pseudo-code for your program would look like this:

if (!File.Exists("YourApp.config"))    File.Copy("YourApp-sample.config", "YourApp.config");


// ... the rest of your normal code

This way the updater can update changes to the *-sample.config file without harming the user's current configuration.

Because the number of configuration files are quite considerable, the update method should simply check if a particular file does exists already and either always overwrite it, or create it if it does not exists or skip the file if it does exists.

Well, we can't add this as the default behavior for obvious reasons. But we'll consider adding an option in wyBuild 2.7 to mark files as "add once".

Right now we're facing this problem with configuration files but we're trying to implement a solution that will work in any situation, any file type we want to add later into the application but do not want the updater to overwrite it after it has been placed, without having to implement a custom post-update routine each time it is needed.

I can see the need for configuration files. But what else would your users modify? Dlls or exes?

I think this mfigueroa's feature is a good idea. Other than configuration files (which is a scenario we have), I can think of things like an embedded database (or other bits of data files) that you may ship with an application and that are updated by the user, rather than built from scratch by the application. It's not a good strategy, but I've been in a situation in the past where a prebuilt database was deployed & user maintained across updates.

Thank you for the quick reply Sam.

I have implemented the "-sample" copy implementation to all the configuration files.

Well, we can't add this as the default behavior for obvious reasons. But we'll consider adding an option in wyBuild 2.7 to mark files as "add once".

I can see the need for configuration files. But what else would your users modify? Dlls or exes?

As FrederikB said, the "add once" option can be really useful for embedded databases (e.g. sql compact, firebird, raima, extremedb, turbodb, etc.) that get deployed over an update.

I know this post is old, but:

+1 for an "add once" feature, or whatever you want to call it, so I can add file(s) in one version and when I don't include them in a later version they are not deleted.

Thats definitely most useful feature..

we have planned to implement your updater, and in Few version we will add few files.. and in another few version we wont add those files.

Lets say,

V1. A.dll,B.dll,C.dllV2 A.dll, D.dllV3. E.dll, F.dll

IF a user is upgrading from V1 to V3, he will endup having just E.dll and F.dll.. but actually he should have A,B,C,D,E,F.

this is how it should do.. any insights?

Add all files to every version in wyBuild. Let wyBuild decide which files to patch, which files to include as a whole, and which files to delete. Just follow the step-by-step walkthrough.

Specifically step 6 where it says "Drag all the files into wyBuild from inside this "1.1" folder you just copied."