Add pattern tasks and cinvoke