I have a situation where I need to copy a few specific files in a MSBuild script, but they may or may not exist. If they don't exist it's fine, I don't need them then. But the standard <copy>
task throws an error if it cannot find each and every item in the list...
Use the Exists condition on Copy task.
<CreateItem Include="*.xml"> <Output ItemName="ItemsThatNeedToBeCopied" TaskParameter="Include"/> </CreateItem> <Copy SourceFiles="@(ItemsThatNeedToBeCopied)" DestinationFolder="$(OutputDir)" Condition="Exists('%(RootDir)%(Directory)%(Filename)%(Extension)')"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With