Versioning of Xml configuration files (C# project)

G

Guest

Hey everyone,

I'm currently writing software for a project that uses a lot of Xml files
for configuration. The project is written in C#/.NET. Each such xml file has
a schema defined for it (Xsd file). This schema is not used at run-time. What
we do is use XPath expressions to query for required information (nodes).

We are currently still in development, but we have a few deployments to test
the software. These deployments each have their own configuration (eg for
coordinates).

The problem comes when an upgrade of the software is distributed. Upgrading
the binaries (software) is trivial: just copy. However upgrading the
configuration (xml-)files automatically is another story. The information
that is in the configuration files should stay the same. New information
should be inserted in the configuration files, preferably automatically.
Information that is no longer needed should be retained (this to facilitate a
downgrade of the software, for which I do not intend to write software).
Information elements that did not exist in an earlier version, is queried for
at the time of upgrade or has a default, and should then be inserted.

I would like to know what other people (would) do in this situation. Are
there any tools to facilitate this sort of upgrades? Any .NET libraries that
could help?

With kind regards,
PS: Sorry if this post is a little off-topic.
 
W

Wayne

Most installers will allow you to run a process during the install. You
could always write an object that represents your xml, and desterilize the
XML, and in the "set" for each property check for null, if it's null set to
a default value, then serialize the object back to XML. This would require
that your object keep any properties that you are going to want to keep in
your xml doc for the downgrade possibility.

Then you would have your install run an app that you write to load the file,
desterilize the data to an object, serialize the data, and save the file.

--
Thanks
Wayne Sepega
Jacksonville, Fl


"When a man sits with a pretty girl for an hour, it seems like a minute. But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top