Visual-Studio Manifest Tool doesn't accept mul

2019-09-18 11:11发布

TL;DR (How) is it possible to get Visual Studio (2010 - 2015) to accept multiple manifest files (to merge) via the actual Additional Manifest Files GUI / props option (and not via workarounds)?


Simplified walk through:

My C++ application embeds an additional manifest file (containing Private Assembly info) via the Visual-C++ Setting: Cfg Properties > Manifest Tool > Input and Output > Additional Manifest Files

C++ Property Page of Visual Studio 2015 test project

This works as expected.

Now, I need to add/merge in a second manifest file. Since the option is called "Additional Manifest File_s_", and this is a multi-line edit box, I tried adding the second file to be merged here:

additional manifest files edit dialog

VS 2015 the tells me:

1>LINK : fatal error LNK1104: cannot open file 'private-assem.manifest my-compat.manifest'

VS 2010 tells me:

2>private-assem.manifest my-compat.manifest : general error c1010070: Failed to load and parse the manifest. Das System kann die angegebene Datei nicht finden.

what is of note here is that both tools show the two files concatenated as one, and indeed, looking at the command line, we see: (note the quotes)

/manifest "private-assem.manifest my-compat.manifest" /verbose /out:"Debug\ConsoleApplication2.exe.embed.manifest" /nologo "Debug\ConsoleApplication2.exe.embed.manifest.res"

command line of mt.exe and further looking into the mt.exe help we see:

C:\Program Files (x86)\Microsoft Visual Studio 14.0>mt /?
Microsoft (R) Manifest Tool version 6.3.9600.17336
Copyright (c) Microsoft Corporation 2012.
All rights reserved.

Usage:
-----
mt
    [ -manifest <manifest1 name> <manifest2 name> ... ]
...

Note that the manifest file options are space separated and thus what VS passes to mt.exe is humbug, because it encloses both files in a single quote string.

Question

Is there any way to make the Additional Manifest Files option actually work for multiple files? Or am I doing something wrong?

Background / Workaround

I can think of the following possible workarounds:

  • Try to hack something together via pre-link steps and manual invocation of mt.exe (not tried: horrible)
  • Actually add the manifest file(s) as file items to the VS project: This will work, but:

    The actual situation arose when combining multiple .props property sheets into a single project, where one specced a private assembly and the other specced the application compatibility declaration. So the settings do not reside on the actual project itself, but on property sheets that are included in the project.

I'm also including the tag in the question, as I'm

  1. not sure what is to blame for this - VS or MSBuild
  2. maybe there's a possibility hacking the .propsor .vcxproj files to make this work

1条回答
淡お忘
2楼-- · 2019-09-18 12:13

Hans' comment was spot on:

... a space is not a file separator. Put semicolons between the file names.

Adding a seimcolon ; after each .manifest filename in the properties does the trick. VS / MSBuild (whoever) will the quote the /manifestoption correctly.

That is, instead of specifying:

  <ItemDefinitionGroup>
    <Manifest>
      <AdditionalManifestFiles>somefile.manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>
    </Manifest>
  </ItemDefinitionGroup>

all property sheet files (indeed all Additional Manifest Files settings) can (and should) append a semicolon to each filename (also do this when only speccing a single one, so that it will be combined correctly for multiple property sheets):

  <AdditionalManifestFiles>somefile.manifest; %(AdditionalManifestFiles)</AdditionalManifestFiles>
                                           ^^^
查看更多
登录 后发表回答