Pergunta

Hi I am running following command from my post build event:

C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\mt.exe -manifest "$(ProjectDir)$(TargetName).exe.manifest" -updateresource:"$(TargetDir)$(TargetName).exe;#1"

It is failing with Exited with code 9009... I don't understand why this happens; any suggestions?

Foi útil?

Solução

Try adding quotes around the mt.exe path, e.g.:

"C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\mt.exe"

Also, make sure that path is valid.

Hope this helps. I've been beating my head against code 9009 all day and a full quoted path seem to make it work.

Outras dicas

Exit code 9009 is a file not found error. The spaces that exist in your path to the post build command cause errors in a command prompt unless you include quotes around the entire path and executable name. Essentially, in your post-build command, it is trying to execute C:\Program with the arguments:

  • Files\Microsoft
  • SDKs\Windows\v7.0A\bin\mt.exe
  • -manifest "$(ProjectDir)$(TargetName).exe.manifest"
  • -updateresource:"$(TargetDir)$(TargetName).exe;#1"

Since obviously you don't have a file called Program residing in your root directory, this entire command fails. Encapsulating the path and executable in quotes will cause the entire expression to be evaluated as a single command, so everything should work fine if you change the post-build command to:

"C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\mt.exe" -manifest "$(ProjectDir)$(TargetName).exe.manifest" -updateresource:"$(TargetDir)$(TargetName).exe;#1"

Or use for VisualStudio x86 in Windows x64

"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\mt.exe"

Here is a potential solution:

You can use the Post build event functionality of Visual Studio to do this typing the command above: mt.exe -manifest app.manifest -outputresource:myapplication.exe;#1. This probably won't work and Visual Studio will give you an error like "...exited with code 9009...".

You have to edit the csproj file using for example the notepad and uncomment the XML tags related to the Target Name="AfterBuild" (you can find them at the end of the file usually). Then, place the tags related to the PostBuildEvent within the tags related to the AfterBuild and then, reload the project and compile. It will produce a .exe file that needes to be execute with Administrator permissions.

Until reading this thread, I foolishly assumed VS would know where mt.exe lives. +1 to @james

Since there's no built-in macro for the current SDK, I relied on the system envar, windowssdkdir

 "%windowssdkdir%\bin\mt.exe"
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top