Adding a new target type to msbuild: How do I refer to the itemname in the task rules?
- by jmucchiello
I'm trying to add a task to build the COM proxy DLL after building the main DLL. So I created the following in a .target file:
<Target Name="ProxyDLL"
Inputs="$(IntDir)%(WHATGOESHERE)_i.c;$(IntDir)dlldata.c"
Outputs="$(OutDir)%(WHATGOESHERE)ps.dll"
AfterTargets="Link">
<CL Sources="$(IntDir)%(WHATGOESHERE)_i.c;$(IntDir)dlldata.c" />
</Target>
And reference it from the .vcxproj file as
<ItemGroup>
<ProxyDLL Include="FTAccountant" />
</ItemGroup>
So the FTAccountant.DLL file is created through the normal build process and then when attempts to compile the proxy stubs it creates these command lines:
cl /c dir\_i.c dir\dlldata.c
And of course it can't find _i.c. The first attempt, I put %(Filename) in the WHATGOESHERE space and I got this error:
C:\ActivePay\Build\Proxy DLL.targets(6,3): error MSB4095: The item metadata
%(Filename) is being referenced without an item name. Specify the item name by
using %(itemname.Filename).
So I changed it to %(itemname.Filename) and that is an empty string. How to get the value specified in the task's Include attribute and use it within the task?