0

I have a VS2019 C++ project environment where a plug-in adds CPP items to the build list. Unfortunately these items inherit the global CPP build settings. Specifically the precompiled header setting. I have to manually alter the settings for these items and I think there must be a way to add a few lines to the project to filter for these items. The items all have the substring _xxx added so if I had file blah.blob the plug in inserts blah_xxx.cpp and adds it to the ClCompile itemlist.

I want to do something like

<ItemGroup 

    <Clcompile Condition="%(ClCompile)" contains "_xxx" >

        %(ClCompile.PreCompiledHeaders)="NotUsing" </ClCompile>

</ItemGroup>

I think if I stick this late enough in the project it will have the desired effect. I suppose I could also alter the properties, but I think most props files are injected before the project behavior, so this item change needs to be in the project, or injected as a task that occurs prior to ClCompile.

I think I will eventually stumble on the answer, but figure the MSBUILD gurus could provide some direction. I have the Inside the Microsoft Build Engine book, and while a terrific resource, I'm always struggling a bit to get to the solution I want.

Ross Youngblood
  • 502
  • 1
  • 3
  • 16
  • 1
    Property functions may not appear within metadata value. So contains cannot be used for metadata "%(ClCompile)". Maybe this link(https://stackoverflow.com/questions/8129831/msbuild-condition-evaluate-property-contains) can help you about the problem – Jingmiao Xu-MSFT Jul 26 '22 at 07:18
  • Thanks for the link. The REGEX solution should do what I want. My vague idea of an approach now involves injecting a Target prior to ClCompile that will modify the item list metadata as required. I was thinking that the only way to get per item evaluation was within a target. – Ross Youngblood Jul 27 '22 at 16:34

0 Answers0