Windows SDK for Windows 7 and .NET Framework 3.5 SP1
Windows 7用のWindows SDKもインストールして見た。
というか、そのリリースノートを見ていたら、「Visual Studio 2008 SP1 on Windows 7」で書いた件(mt.exe : general error c101008d: Failed to write the updated manifest...)について言及されていた。
5.3.6 Problem Running mt.exe on Windows 7 Beta The use of mt.exe to add a manifest resource to a PE image file (.EXE, .DLL, etc.) that does not already contain a resource (.rsrc) section in it may fail on Windows 7 Beta. The problem does not occur on Windows XP, Windows Vista, and Windows Server 2008, nor does it occur on Windows 7 Beta when manipulating PE image files that already contain a resource section. Workarounds: 1. Use mt.exe on Windows XP, Windows Vista or Windows Server 2008 instead of Windows 7 Beta, or 2. If using Windows 7 Beta, use an external manifest file or ensure the PE image has a non-zero length resource section.
なんと。リソースがリンクされていれば良いらしい。通りで、一部のプロジェクトはうまく行くわけだ。そして、回避方法としては、1はまぁ、その通りだが、2の回避方法がおもしろい。
a. External Manifest File: For .EXE files, the manifest need not be embedded as a resource. Rather, it may simply be placed next to the .EXE. I.e., for ‘hello.exe’, the manifest ‘hello.exe.manifest’, when placed next to it, has the same effect as if the manifest were embedded as a resource. This is true only for .EXE files.
.exe.manifestを.exeの横に置きなさいと・・・。
いやいや、それちょっと嫌な感じだし。
そして、極めつけが、
b. Create a Non-Zero-Length Empty Resource Section: If it is imperative that mt.exe later be used to embed a manifest, and the PE image file in question cannot otherwise be guaranteed to have a resource section, then an empty resource script may be used. Despite that the script is empty, the resultant resource section will not be zero-length, and mt.exe can then be used. For example: i. cl.exe /c hello.c ii. echo. > hello.rc iii. rc.exe /r hello.rc iv. link.exe /out:hello.exe hello.obj hello.res v. mt.exe -outputresource:hello.exe;1 -manifest: hello.exe.manifest vi. (the file hello.exe now exists with hello.exe.manifest embedded)
おおっと、rcファイルって空でもコンパイルできるのか。echo.>っていわば、touchでファイルを作る的な感じ。これも知らなかった。知らないこと尽くしですが、ある意味では、ローテクな。でも、この方法だと、Visual Studioからはできるのか?mt.exeが実行されるのって、Post-buildのプロセスよりも後だっけ?
ちょっとだけ疑問がありますが、まぁ、問題の理由がわかってすっきりした。
この際、Windows 7用のアプリには、常にバージョン情報をつけるようにしようと思う。