Let's say I have an ItemGroup defined as follows:
<ItemGroup>
<ReactorFile Include="MyExecutable\bin\x86\Release\MyExecutable.exe"/>
<ReactorFile Include="MyLibrary\bin\x86\Release\MyLibrary*.dll"/>
</ItemGroup>
Defined a PropertyGroup:
<PropertyGroup>
<ReactorUnObfuscatedFileExt>.unobfuscated</ReactorUnObfuscatedFileExt>
</PropertyGroup>
I also have defined a Target in another file:
<Target Name="CopyUnprotectedFiles">
<!-- Copy unobfuscated file to "unobfuscated file".unobfuscated -->
<Copy
SourceFiles="@(ReactorFile)"
DestinationFiles="@(ReactorFile -> '%(Filename)%(Extension)$(ReactorUnObfuscatedFileExt)"
SkipUnchangedFiles="false"
/>
</Target>
Unfortunately due to my lack of experience in MSBuild I did it wrong. Could somebody please correct it for me?
I have figured it out:
Adding a %(RelativeDir) Item Metadata was the solution.
Maybe other will use it as an example. Corrected fragment is:
<Target Name="CopyUnprotectedFiles">
<!-- Copy unobfuscated file to "unobfuscated file".unobfuscated -->
<Copy
SourceFiles="@(ReactorFile)"
DestinationFiles="@(ReactorFile -> '%(RelativeDir)%(Filename)%(Extension)$(ReactorUnObfuscatedFileExt)')"
SkipUnchangedFiles="false"
/>
</Target>