1

My .props file contains an import of "$(VCTargetsPath12)Microsoft.Cpp.mfcDynamic.props", but in one project which I include the .props file, it already uses that file and I get the following warning:

D:\Projects\UnitTest\ab32\ab32.props(4,5): warning MSB4011: "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.mfcDynamic.props" cannot be imported again. It was already imported at "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Common.props (445,5)". This is most likely a build authoring error. This subsequent import will be ignored. [D:\Projects\UnitTest\ab32\ab32.vcxproj]

I saw this suggestion, but it doesn't work in this case as it is a system one that I will not modify. Though I did try:

<Import Project="$(VCTargetsPath12)Microsoft.Cpp.mfcDynamic.props" Condition=" '$(_PropertySheetDisplayName)' != 'Dynamic Link to MFC' " />

But it didn't work. Suggestions?

Community
  • 1
  • 1
Adrian
  • 10,246
  • 4
  • 44
  • 110
  • If that property sheet modifies other things (itemgroups, ...) you could check on those instead? – stijn Nov 25 '15 at 09:34
  • @stijn, how do I check those? – Adrian Nov 25 '15 at 17:26
  • mfcDynamic adds _AFXDLL to the preprocessor definitions so something like `@(ClCompile->'%(PreprocessorDefinitions)'->Contains('_AFXDLL'))` can be used to check that, but afaik only inside a target so I don't know directly how to do that on the project level, sorry.. – stijn Nov 26 '15 at 20:02
  • @stijn, where did you find that information? – Adrian Nov 30 '15 at 14:58
  • You mean that it defines _AFXDLL? I just opened the property sheet in a text editor. – stijn Nov 30 '15 at 15:15
  • @stijn No. The @ syntax and what can be put within the parenthesis. – Adrian Nov 30 '15 at 16:01
  • The first `->` is a 'transform': https://msdn.microsoft.com/en-us/library/ms171476.aspx so this creates a new item list, the second `->` invokes an 'item function' on each element of the list, the 'Contains' function of .Net String in this case: https://msdn.microsoft.com/en-us/library/ee886422.aspx – stijn Nov 30 '15 at 19:15
  • @stijn cool. I'll look it up. – Adrian Nov 30 '15 at 19:30
  • @stijn, this sounded like a good idea, but it didn't work. I get the following error: `A reference to an item list at position 1 is not allowed in this condition "@(ClCompile->'%(PreprocessorDefinitions)'->Contains('_AFXDLL'))".` and I'm not sure what it means. – Adrian Dec 18 '15 at 17:12
  • Not sure exactly, but this can detect _AFXDLL properly: https://gist.github.com/stinos/05d93f9b89e1cc7d5930 As I said though, it can only do that at the Target level so I doubt it's useful. – stijn Dec 19 '15 at 11:21

0 Answers0