public bool Execute()
        {
            TaskLogger logger = new TaskLogger(BuildEngine);

            try
            {
                FileInfo projectFile = new FileInfo(ProjectPath);
                FileInfo configFile  = null;

#if NET35
                IEnumerable <string> allFiles = Directory.GetFiles(projectFile.DirectoryName);
#else
                IEnumerable <string> allFiles = Directory.EnumerateFiles(projectFile.DirectoryName);
 #endif

                foreach (string file in allFiles)
                {
                    string filename = file.ToLowerInvariant();

                    if (filename.EndsWith("app.config") || filename.EndsWith("web.config"))
                    {
                        string contents = File.ReadAllText(file);
                        if (contents.Contains("TrinitySettings namespace=\"Semiodesk.Trinity.Test\")"))
                        {
                            configFile = new FileInfo(file);
                            break;
                        }
                    }

                    if (filename.EndsWith("ontologies.config"))
                    {
                        configFile = new FileInfo(file);
                    }
                }

                if (configFile != null)
                {
                    Program program = new Program(logger);
                    program.SetConfig(configFile);
                    program.LoadConfigFile();

                    // TODO: Make ontologies folder configurable in Trinity settings.
                    if (string.IsNullOrEmpty(IntermediatePath))
                    {
                        IntermediatePath = projectFile.Directory.FullName;
                    }
                    else
                    {
                        IntermediatePath = Path.Combine(projectFile.DirectoryName, IntermediatePath);
                    }

                    string targetFile = Path.Combine(IntermediatePath, "Ontologies.g.cs");
                    program.SetTarget(targetFile);

                    int status = program.Run();

                    OutputFiles = new TaskItem[] { new TaskItem(targetFile) };

                    return(status == 0);
                }
                else
                {
                    logger.LogMessage("No app.config or web.config file found in project directory: {0}.", projectFile.DirectoryName);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                logger.LogError(string.Format("An error occured during the generation of the ontologies.g.cs file.\n" + ex.Message + "\n" + ex.StackTrace));

                return(false);
            }
        }