How to find corrupted file for Continous Integration

Tomasz Sikora asked on September 1, 2017 10:40

My CI is failing because some XML file is corrupted. There's an exception like this "There is no Unicode byte order mark. Cannot switch to Unicode." But I cannot find out which file is causing this issue because there is no such information in stack trace of inner exceptions. Is there some way to find this corrupted file?

Recent Answers


Tomasz Sikora answered on September 1, 2017 12:21

I found out how to find this file with wrong encoding. I've written simple C# program that uses the same method that CI seems to be using (by looking at stacktrace). It broke just on the corrupted file and I could see it's location.

static void Main(string[] args)
    {
        var path = @"path_to_your_app_data\CIRepository";
        string[] filenames = Directory.GetFiles(path, "*.xml", SearchOption.AllDirectories);
        var document = new XmlDocument();
        foreach (var fileName in filenames)
        {
            document.Load(fileName);
            Console.WriteLine(fileName);
        }
    }
1 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on September 1, 2017 14:18

Might be a good suggestion to send Kentico to have this simple checking on the CI module before attempting to process and maybe spit out an event log record on the record(s) that fail.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.