Since looking around over the web I didn’t find any reference to this particular case, I think it’s worth writing it here. I tracked down this issue recently together with a developer that wanted to package “many” files within a single .CAB (1000+). He was using a quite old version of CabWiz.exe, launched through an application he wrote. So, as the initial troubleshooting step, I tried to reproduce the issue with the CabWiz.exe shipped with Visual Studio 2008: same problem.
Above all, this error can arise from CabWiz (which is internally invoked by VS2008 when creating Smart Device CAB Projects) also if you’re using ‘%’ in registry keys, as my friend Chris reported in his How to avoid hardcoding file paths within CAB file registry settings, in order to add registry values that refer to the location of files installed as part of the application.
So I thought: ok, he’s hitting the known limit of 998 files that could be packaged in a CAB… Wrong: the problem happened also when using much less files, say 300… I’m still talking about C:\Program Files\Microsoft Visual Studio 9.0\SmartDevices\SDK\SDKTools\CabWiz.exe, version 4.0.4332.0.
After running some tests, I reached a magic number: 262. With 262 files VS2008 could create a Smart Device CAB successfully, with 263 files it gave error “x.inf contains DirIDs, which are not supported“. At this point I noticed that in the .INF file that VS2008 creates and gives to CabWiz.exe, it wrote an entry under [DestinationDirs] for each added file, even if the target folder on the device is the same, as it was in my case. By manually editing the INF (using some applications that automated lines-creation…), I could successfully create a CAB for 263+ files, specifying only one entry under [DestinationDirs]. So, another limit I wasn’t aware of is: VS2008’s CabWiz can parse up to 262 different entries under [DestinationDirs].
Now: Windows Mobile 6 SDKs ship with a newer version of CabWiz.exe, v4.5.5102.0 and, very interestingly, it overcame not only the limitation about 998 files, but also the one about 262 entries under [DestinationDirs]. So the “simple” solution in this case was to download one of the 2 Windows Mobile 6 SDKs and use that CabWiz.exe (C:\Program Files\Windows Mobile 6 SDK\Tools\CabWiz).
Playing with files under C:\Program Files\Microsoft Visual Studio 9.0 is not recommended (and probably “not supported”), however for testing purposes I replaced C:\Program Files\Microsoft Visual Studio 9.0\SmartDevices\SDK\SDKTools\CabWiz.exe and CabWiz.ddf with the ones under C:\Program Files\Windows Mobile 6 SDK\Tools\CabWiz, and now my VS2008 can continue creating one entry under [DestinationDirs] for each file, independently if the target folder will the be same, but now it successfully creates the CAB. I imagine there are still some limits, but this may be a topic of another post…