I'm trying to make a .targets
file
for my NuGet package, which will link to a proper .lib
file
depending on the C++ runtime library of a project. This
answer recommends to use %(ClCompile.RuntimeLibrary)
metadata
for this. But I cannot use metadata in condition of the <ItemDefinitionGroup> node.
When trying to run MSBuild with the following test script:
<?xml version="1.0" encoding="us-ascii"?><Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><ItemGroup><ClCompile Include="main.cpp"><RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary></ClCompile></ItemGroup><ItemDefinitionGroup Condition="'%(ClCompile.RuntimeLibrary)'=='MultiThreadedDebugDLL'"><Link><AdditionalDependencies>yaml-cpp-MDd.lib;%(AdditionalDependencies)</AdditionalDependencies></Link></ItemDefinitionGroup></Project>
I have the following error: "error MSB4191: The reference to custom metadata "RuntimeLibrary" at position 1 is not allowed in this condition "'%(ClCompile.RuntimeLibrary)'=='MultiThreadedDebugDLL'"."
How can I workaround this issue?