1

I want to, for example, enable showing includes (\showIncludes from C++ compiler Advanced configurations) for some project via MSbuild command line. Can I make it somehow without changing the project properties?

The following command line I tried doesn't work:

MSBuild.exe /p:Configuration=Debug /p:Platform=x64 /p:ShowIncludes=true "myproj.vcxproj" -t:Rebuild

Anton Serov
  • 174
  • 2
  • 12
  • Possible duplicate of [How to set PreProcessorDefinitions as a task propery for the msbuild task](https://stackoverflow.com/questions/15141429/how-to-set-preprocessordefinitions-as-a-task-propery-for-the-msbuild-task) that question is for preprocessor definitions, but the principle for other compiler/linker/... options is the same – stijn Nov 27 '19 at 19:18
  • @stijin, so how can I use this information particularly for setting "showIncludes" flag? Did you try it or you thing that it should work in theory? – Anton Serov Nov 28 '19 at 12:26
  • No I didn't try, but I know it works in practice because I've used it for all kinds of compiler flags. In this answer https://stackoverflow.com/a/17446623/128384, all you have to do is replace the line `True`. *edit* just tried, works. – stijn Nov 28 '19 at 13:10
  • Thanks, but (as I understand) you propose modifying a config file? A problem is to define that flag via a command line, without editing any files (if it ever possible) – Anton Serov Nov 28 '19 at 14:09
  • 1
    It's been a while since I checked, but unless something changed in msbuild, it is not possible without using a file. Which is actually almost orthogonal to 'using commandline' because it's not too hard to create e.g. a Powershell commandline which creates the Directory.build.props file, calls msbuild, then deletes the config file again. And you can make this generic, e.g. if the file contains `$(ClOptions) %(AdditionalOptions)` then you can use `msbuild /p:ClOptions=/showIncludes` (and note you only need one such file, in the project root or even higher) – stijn Nov 28 '19 at 15:08

1 Answers1

0

Yes, here are docs. You need to pass /showIncludes:

MSBuild.exe /p:Configuration=Debug /p:Platform=x64 /showIncludes "myproj.vcxproj" -t:Rebuild

Example

borievka
  • 636
  • 5
  • 13
  • Thank you for the answer. But this didn't work for me. This is what I got after executing with the parameter: MSBUILD: error MSB1001: Unknown key Key: /showIncludes – Anton Serov Nov 26 '19 at 12:42
  • 1
    your example with MSVC works but is not relevant to the question. Since I want to set the key via the MSBuild command line particularly, not with MSVC. – Anton Serov Nov 26 '19 at 12:48