This error can occurr when you have special characters, like (^ ~), on file names defined on the feature.xml or ir elementmanifest.xml.
Today i found a new reason to provoke this error. If we define two files with the same name and in the same folder on the feature.xml, elementmanifest.xml and on solution.ddf the wsp file created will have two files with the same and that will also cause this error.